def main(): game = GameState.new_game(19) checkpoint_p = Path('./checkpoints/').resolve().joinpath('betago.params') ctx = mx.gpu() agent = BetaGoAgent.create(checkpoint_p, ctx) #for i in range(3): # human_move = 'A%d' % (i+1) # print(human_move) # point = point_from_coords(human_move.strip()) # print(point) # move = Move.play(point) # game = game.apply_move(move) # move = agent.select_move(game) # game = game.apply_move(move) # print_board(game.board) while not game.is_over(): # before each move, clear screen print(chr(27) + "[2J") # <2> print_board(game.board) if Player.black == game.next_player: human_move = input('-- ') point = point_from_coords(human_move.strip()) move = Move.play(point) else: move = agent.select_move(game) game = game.apply_move(move) print_board(game.board) winner = game.winner() if winner is None: print("It's a draw.") else: print('Winner: ' + str(winner))
def _play(self): while not self._stopped: if self._game_state.next_player == self._our_color: self._play_our_move() else: self._play_their_move() print(chr(27) + "[2J") print_board(self._game_state.board) print("Estimated result: ") print(compute_game_result(self._game_state))
def main(): board_size = 3 game = GameState.new_game(board_size) bots = { Player.black: DepthBrunedAgent(3, capture_diff), Player.white: DepthBrunedAgent(3, capture_diff), } while not game.is_over(): # sleep 300ms so that bot moves are not printed too fast time.sleep(0.3) # before each move, clear screen print(chr(27) + "[2J") # <2> bot_move = bots[game.next_player].select_move(game) print_board(game.board) print_move(game.next_player, bot_move) game = game.apply_move(bot_move) print_board(game.board) winner = game.winner() if winner is None: print("It's a draw.") else: print('Winner: ' + str(winner))
def main(): board_size = 5 game = GameState.new_game(board_size) bot = MCTSAgent(num_rounds=500, temperature=1.4) while not game.is_over(): # before each move, clear screen print(chr(27) + "[2J") # <2> print_board(game.board) if Player.black == game.next_player: human_move = input('-- ') point = point_from_coords(human_move.strip()) move = Move.play(point) else: move = bot.select_move(game) game = game.apply_move(move) print_board(game.board) winner = game.winner() if winner is None: print("It's a draw.") else: print('Winner: ' + str(winner))