Created
February 4, 2019 15:22
-
-
Save mohsenheydari/852431848b4c32631c15ca1e54a4d693 to your computer and use it in GitHub Desktop.
MCTS - backpropagate 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
backpropagate(node, result) { | |
let tmpNode = node; | |
while(tmpNode !== null) { | |
tmpNode.state.visits++; | |
if (result != tmpNode.state.board.DRAW) { | |
if (tmpNode.state.player === result) { | |
tmpNode.state.wins++; | |
} | |
else { | |
tmpNode.state.wins--; | |
} | |
} | |
tmpNode = tmpNode.parent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment