Created
October 23, 2020 15:28
-
-
Save masouduut94/380b4eda46a4f98938afd3ebed92e1b6 to your computer and use it in GitHub Desktop.
simulation code of mcts agent.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@staticmethod | |
def roll_out(state: GameState) -> int: | |
""" | |
Simulate an entirely random game from the passed state and return the winning | |
player. | |
Args: | |
state: game state | |
Returns: | |
int: winner of the game | |
""" | |
moves = state.moves() # Get a list of all possible moves in current state of the game | |
while state.winner == GameMeta.PLAYERS['none']: | |
move = choice(moves) | |
state.play(move) | |
moves.remove(move) | |
return state.winner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment