tictactoe_play.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:mittmcts 作者: dbravender 项目源码 文件源码
def main():
    state = TicTacToeGame.initial_state()
    while True:
        if state.winner:
            TicTacToeGame.print_board(state)
            if state.winner is Draw:
                print('Draw!')
            elif state.winner:
                print(state.winner + ' wins')
            break
        if state.current_player == 'O':
            while True:
                TicTacToeGame.print_board(state)
                try:
                    move = int(input('Move:'))
                    state = TicTacToeGame.apply_move(state, move)
                    break
                except ValueError:
                    print('That is not a legal move')
        else:
            result = (MCTS(TicTacToeGame, state)
                      .get_simulation_result(100))
            state = TicTacToeGame.apply_move(state, result.move)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号