Esempio n. 1
0
def extract_moves(final_positions):
    winning_moves = []
    losing_moves = []
    for final_position in final_positions:
        positions_w_context = utils.take_n(
            strategies.POLICY_CUTOFF_DEPTH,
            sgf_wrapper.replay_position(final_position,extract_move_probs=True))
        winner = utils.parse_game_result(final_position.result())
        for pwc in positions_w_context:
            if pwc.position.to_play == winner:
                winning_moves.append(pwc)
            else:
                losing_moves.append(pwc)
    return load_data_sets.DataSet.from_positions_w_context(winning_moves,extract_move_prob=True),\
           load_data_sets.DataSet.from_positions_w_context(losing_moves,extract_move_prob=True)
def extract_moves(final_positions):
    winning_moves = []
    losing_moves = []
    #logger.debug(f'Game final positions{final_positions}')
    for final_position in final_positions:
        positions_w_context = utils.take_n(
            POLICY_CUTOFF_DEPTH,
            sgf_wrapper.replay_position(final_position,
                                        extract_move_probs=True))
        winner = utils.parse_game_result(final_position.result())
        #logger.debug(f'positions_w_context length: {len(positions_w_context)}')
        for pwc in positions_w_context:
            if pwc.position.to_play == winner:
                winning_moves.append(pwc)
            else:
                losing_moves.append(pwc)
    return load_data_sets.DataSet.from_positions_w_context(winning_moves, extract_move_prob=True),\
        load_data_sets.DataSet.from_positions_w_context(losing_moves, extract_move_prob=True)
Esempio n. 3
0
def get_winrate(final_positions):
    black_win = [
        utils.parse_game_result(pos.result()) == go.BLACK
        for pos in final_positions
    ]
    return sum(black_win) / len(black_win)