Created
February 4, 2019 15:09
-
-
Save mohsenheydari/d19bfa2597674f317b54f96e16db2aa7 to your computer and use it in GitHub Desktop.
MCTS - simulate method of TreeSearch class
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
simulate(node) { | |
let state = node.state.clone(); //Temp state | |
state.board = node.state.board.clone(); | |
//Play randomly until one player wins or game result in draw | |
while (!state.isTerminal) { | |
state.switchToNextPlayer(); | |
let action = state.getRandomAction(state.player); | |
state.applyAction(action); | |
} | |
return state.board.status; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment