def gen_probdist(self, game_state, player): """ Generates a correct move probability distribution for the next move, using the gen_probdist_raw(). Correct means that it zeroes out probability of playing incorrect move, such as move forbidden by ko, suicide and occupied points. Stores the dist and the player. :return: a numpy array of floats of shape (board.side, board.side), or None for pass the array is normalized to 1 """ dist = self.gen_probdist_raw(game_state, player) if dist is not None: correct_moves = analyze_board.board2correct_move_mask( game_state.board, player) if game_state.ko_point: correct_moves[game_state.ko_point[0]][ game_state.ko_point[1]] = 0 # compute some debugging stats of the incorrect moves first incorrect_dist = (1 - correct_moves) * dist logging.debug("%s incorrect moves\n%s" % (self, utils.dist_stats(incorrect_dist))) # keep only correct moves dist = correct_moves * dist s = dist.sum() if s > 0.0: dist = dist / dist.sum() else: logging.debug("No valid moves, PASSING.") dist = None self.last_dist = dist self.last_player = player return self.last_dist
def gen_probdist(self, game_state, player): """ Generates a correct move probability distribution for the next move, using the gen_probdist_raw(). Correct means that it zeroes out probability of playing incorrect move, such as move forbidden by ko, suicide and occupied points. Stores the dist and the player. :return: a numpy array of floats of shape (board.side, board.side), or None for pass the array is normalized to 1 """ dist = self.gen_probdist_raw(game_state, player) if dist is not None: correct_moves = analyze_board.board2correct_move_mask(game_state.board, player) if game_state.ko_point: correct_moves[game_state.ko_point[0]][game_state.ko_point[1]] = 0 # compute some debugging stats of the incorrect moves first incorrect_dist = (1 - correct_moves) * dist logging.debug("%s incorrect moves\n%s"%(self, utils.dist_stats(incorrect_dist))) # keep only correct moves dist = correct_moves * dist s = dist.sum() if s > 0.0: dist = dist / dist.sum() else: logging.debug("No valid moves, PASSING.") dist = None self.last_dist = dist self.last_player = player return self.last_dist
def get_label_correct(s, player): return analyze_board.board2correct_move_mask(s.board, player)