tweaked mcts score evaluation: considered steps when scoring the board

This commit is contained in:
2024-01-24 18:12:32 +01:00
parent 5645657fdd
commit 7011a9a6e8
3 changed files with 9 additions and 7 deletions

View File

@@ -30,21 +30,23 @@ class MCTSNode:
self.children.append(child_node)
return child_node
def _rollout(self, rollout_depth: int = 100) -> float:
def _rollout(self, rollout_depth: int = 20) -> int:
"""
Rolls out the node by simulating a game for a given depth.
Sometimes this step is called 'simulation' or 'playout'.
:return: the score of the rolled out game
"""
copied_board = self.board.copy()
steps = 1
for i in range(rollout_depth):
if copied_board.is_game_over():
break
m = engine.pick_move(copied_board)
copied_board.push(m)
steps += 1
return eval.score_manual(copied_board)
return eval.score_manual(copied_board) // steps
def _backpropagate(self, score: float) -> None:
"""