def get_cube_detlefko_conthist(state, player): cube = np.zeros((12, state.board.side, state.board.side), dtype='float32') string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties, enemy_liberties = friend * lib_count, enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties == 3 cube[3] = our_liberties >= 4 cube[4] = enemy_liberties == 1 cube[5] = enemy_liberties == 2 cube[6] = enemy_liberties == 3 cube[7] = enemy_liberties >= 4 cube[8] = empty * 1 if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[9][ko_row][ko_col] = 1 # watch out, history since it gives -1 for empty points history = np.exp(- 0.1 * raw_history(state.board, state.history)) cube[10] = friend * history cube[11] = enemy * history return cube
def get_cube_detlefko_conthist(state, player): cube = np.zeros((12, state.board.side, state.board.side), dtype='float32') string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties, enemy_liberties = friend * lib_count, enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties == 3 cube[3] = our_liberties >= 4 cube[4] = enemy_liberties == 1 cube[5] = enemy_liberties == 2 cube[6] = enemy_liberties == 3 cube[7] = enemy_liberties >= 4 cube[8] = empty * 1 if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[9][ko_row][ko_col] = 1 # watch out, history since it gives -1 for empty points history = np.exp(-0.1 * raw_history(state.board, state.history)) cube[10] = friend * history cube[11] = enemy * history return cube
def get_cube_tian_zhu_2015(state, player): """ Planes compatible with the Yuandong Tian, Yan Zhu, 2015 Better Computer Go Player with Neural Network and Long-term Prediction (arXiv:1511.06410) """ cube = np.zeros((25, state.board.side, state.board.side), dtype='float32') # count liberties string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # mask for different colors empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties >= 3 cube[3] = enemy_liberties == 1 cube[4] = enemy_liberties == 2 cube[5] = enemy_liberties >= 3 if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[6][ko_row][ko_col] = 1 cube[7] = friend * 1 cube[8] = enemy * 1 cube[9] = empty * 1 # watch out, history since it gives -1 for empty points history = np.exp(-0.1 * raw_history(state.board, state.history)) cube[10] = friend * history cube[11] = enemy * history # rank_planes enemy_rank = state.ranks.wr if player == 'b' else state.ranks.br # key maps: (30k, 1k) = (30, 1), (1d, 9d) = (0, -8), (1p, 9p) = (-9, ..) # in case of None rank, make all rank planes 0 enemy_rank_key = enemy_rank.key() if enemy_rank is not None else 1 for r in xrange(9): # one plane per dan, pros have all ones if enemy_rank_key == -r or enemy_rank_key < -8: cube[12 + r][:] = 1 cube[21] = static_planes.get_border_mark(state.board.side) cube[22] = np.exp(-0.5 * static_planes.get_sqd_from_center(state.board.side)) # distances from stones ~ cfg dist_friend, dist_enemy = analyze_board.board2dist_from_stones( state.board, player) cube[23] = empty * (dist_friend < dist_enemy) cube[24] = empty * (dist_friend > dist_enemy) return cube
def get_cube_tian_zhu_2015(state, player): """ Planes compatible with the Yuandong Tian, Yan Zhu, 2015 Better Computer Go Player with Neural Network and Long-term Prediction (arXiv:1511.06410) """ cube = np.zeros((25, state.board.side, state.board.side), dtype='float32') # count liberties string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # mask for different colors empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties >= 3 cube[3] = enemy_liberties == 1 cube[4] = enemy_liberties == 2 cube[5] = enemy_liberties >= 3 if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[6][ko_row][ko_col] = 1 cube[7] = friend * 1 cube[8] = enemy * 1 cube[9] = empty * 1 # watch out, history since it gives -1 for empty points history = np.exp(- 0.1 * raw_history(state.board, state.history)) cube[10] = friend * history cube[11] = enemy * history # rank_planes enemy_rank = state.ranks.wr if player == 'b' else state.ranks.br # key maps: (30k, 1k) = (30, 1), (1d, 9d) = (0, -8), (1p, 9p) = (-9, ..) # in case of None rank, make all rank planes 0 enemy_rank_key = enemy_rank.key() if enemy_rank is not None else 1 for r in xrange(9): # one plane per dan, pros have all ones if enemy_rank_key == -r or enemy_rank_key < -8: cube[12 + r][:] = 1 cube[21] = static_planes.get_border_mark(state.board.side) cube[22] = np.exp(-0.5 * static_planes.get_sqd_from_center(state.board.side)) # distances from stones ~ cfg dist_friend, dist_enemy = analyze_board.board2dist_from_stones(state.board, player) cube[23] = empty * (dist_friend < dist_enemy) cube[24] = empty * (dist_friend > dist_enemy) return cube
def get_cube_detlef(state, player): """ Planes compatible with the CNN kindly provided by Detlef Schmicker. See http://computer-go.org/pipermail/computer-go/2015-December/008324.html The net should (as of January 2016) be available here: http://physik.de/CNNlast.tar.gz Description: 1 2 3 > 4 libs playing color 1 2 3 > 4 libs opponent color Empty points last move second last move third last move forth last move """ cube = np.zeros((13, state.board.side, state.board.side), dtype='float32') # count liberties string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # mask for different colors empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties == 3 cube[3] = our_liberties >= 4 cube[4] = enemy_liberties == 1 cube[5] = enemy_liberties == 2 cube[6] = enemy_liberties == 3 cube[7] = enemy_liberties >= 4 cube[8] = empty * 1 # watch out, history gives -1 for empty points history = raw_history(state.board, state.history) cube[9] = 1 * (history == 1) cube[10] = 1 * (history == 2) cube[11] = 1 * (history == 3) cube[12] = 1 * (history == 4) return cube
def get_cube_detlef(state, player): """ Planes compatible with the CNN kindly provided by Detlef Schmicker. See http://computer-go.org/pipermail/computer-go/2015-December/008324.html The net should (as of January 2016) be available here: http://physik.de/CNNlast.tar.gz Description: 1 2 3 > 4 libs playing color 1 2 3 > 4 libs opponent color Empty points last move second last move third last move forth last move """ cube = np.zeros((13, state.board.side, state.board.side), dtype='float32') # count liberties string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # mask for different colors empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties == 3 cube[3] = our_liberties >= 4 cube[4] = enemy_liberties == 1 cube[5] = enemy_liberties == 2 cube[6] = enemy_liberties == 3 cube[7] = enemy_liberties >= 4 cube[8] = empty * 1 # watch out, history gives -1 for empty points history = raw_history(state.board, state.history) cube[9] = 1*(history == 1) cube[10] = 1*(history == 2) cube[11] = 1*(history == 3) cube[12] = 1*(history == 4) return cube
def get_cube_jm(state, player): cube = np.zeros((22, state.board.side, state.board.side), dtype='float32') string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # for liberties themselves lib_count_lib = analyze_board.lib_nbs_to_lib_count( state.board, string_lib.liberties_nb_count) empty, friend, enemy = analyze_board.board2color_mask(state.board, player) lib_liberties = empty * lib_count_lib our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = lib_liberties == 1 cube[1] = lib_liberties == 2 cube[2] = lib_liberties == 3 cube[3] = lib_liberties >= 4 cube[4] = our_liberties == 1 cube[5] = our_liberties == 2 cube[6] = our_liberties == 3 cube[7] = our_liberties >= 4 cube[8] = enemy_liberties == 1 cube[9] = enemy_liberties == 2 cube[10] = enemy_liberties == 3 cube[11] = enemy_liberties >= 4 cube[12] = empty * 1 cube[13] = friend * 1 cube[14] = enemy * 1 cube[15] = 1 # watch out, history gives -1 for empty points history = raw_history(state.board, state.history) cube[16] = 1 * (history == 1) cube[17] = 1 * (history == 2) cube[18] = 1 * (history == 3) cube[19] = 1 * (history == 4) if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[20][ko_row][ko_col] = 1 cube[21] = static_planes.get_exp_sqd_from_center(state.board.side, -0.5) return cube
def get_cube_jm(state, player): cube = np.zeros((22, state.board.side, state.board.side), dtype='float32') string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # for liberties themselves lib_count_lib = analyze_board.lib_nbs_to_lib_count(state.board, string_lib.liberties_nb_count) empty, friend, enemy = analyze_board.board2color_mask(state.board, player) lib_liberties = empty * lib_count_lib our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = lib_liberties == 1 cube[1] = lib_liberties == 2 cube[2] = lib_liberties == 3 cube[3] = lib_liberties >= 4 cube[4] = our_liberties == 1 cube[5] = our_liberties == 2 cube[6] = our_liberties == 3 cube[7] = our_liberties >= 4 cube[8] = enemy_liberties == 1 cube[9] = enemy_liberties == 2 cube[10] = enemy_liberties == 3 cube[11] = enemy_liberties >= 4 cube[12] = empty * 1 cube[13] = friend * 1 cube[14] = enemy * 1 cube[15] = 1 # watch out, history gives -1 for empty points history = raw_history(state.board, state.history) cube[16] = 1*(history == 1) cube[17] = 1*(history == 2) cube[18] = 1*(history == 3) cube[19] = 1*(history == 4) if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[20][ko_row][ko_col] = 1 cube[21] = static_planes.get_exp_sqd_from_center(state.board.side, -0.5) return cube
def get_cube_basic_7_channel(state, player): cube = np.zeros((7, state.board.side, state.board.side), dtype='uint8') # count liberties string_lib = analyze_board.board2string_lib(state.board) lib_count = analyze_board.liberties_count(state.board, string_lib) # mask for different colors empty, friend, enemy = analyze_board.board2color_mask(state.board, player) our_liberties = friend * lib_count enemy_liberties = enemy * lib_count cube[0] = our_liberties == 1 cube[1] = our_liberties == 2 cube[2] = our_liberties >= 3 cube[3] = enemy_liberties == 1 cube[4] = enemy_liberties == 2 cube[5] = enemy_liberties >= 3 if state.ko_point is not None: ko_row, ko_col = state.ko_point cube[6][ko_row][ko_col] = 1 return cube