def wholeGame(i): board = p3_t3.Board() state0 = board.starting_state() if len(sys.argv) != 3: print("Need two player arguments") exit(1) p1 = sys.argv[1] if p1 not in players: print("p1 not in " + players.keys().join(",")) exit(1) p2 = sys.argv[2] if p2 not in players: print("p2 not in " + players.keys().join(",")) exit(1) player1 = players[p1] player2 = players[p2] print("") print("Round %d, fight!" % i) i += 1 state = state0 last_action = None current_player = player1 while not board.is_ended(state): last_action = current_player(board, state) state = board.next_state(state, last_action) current_player = player1 if current_player == player2 else player2 print("Finished!") print() final_score = board.points_values(state) winner = 'draw' if final_score[1] == 1: winner = 1 elif final_score[2] == 1: winner = 2 print("The %s bot wins round %s! %s" % (winner, i, str(final_score))) return winner
elif board.is_legal(state, action): return action else: print( "Please input moves as space-separated lists of numbers. Remember that you can only move in the board corresponding to your opponent's last move!" ) return get_human_input(board, state) players = dict(human=get_human_input, random_bot=random_bot.think, rollout_bot=rollout_bot.think, mcts_vanilla=mcts_vanilla.think, mcts_modified=mcts_modified.think) board = p3_t3.Board() state0 = board.starting_state() if len(sys.argv) != 3: print("Need two player arguments") exit(1) p1 = sys.argv[1] if p1 not in players: print("p1 not in " + players.keys().join(",")) exit(1) p2 = sys.argv[2] if p2 not in players: print("p2 not in " + players.keys().join(",")) exit(1)