| 150 | return child_node |
| 151 | |
| 152 | def simulate(self, node: Node) -> float: |
| 153 | current_node = node |
| 154 | depth = 0 |
| 155 | logger.debug("Starting simulation") |
| 156 | while depth < self.max_depth: |
| 157 | if not current_node.children: |
| 158 | action = random.choice(self.actions) |
| 159 | current_node = self.expand(current_node, action) |
| 160 | else: |
| 161 | current_node = random.choice(current_node.children) |
| 162 | depth += 1 |
| 163 | value = self.evaluate(current_node) |
| 164 | logger.debug(f"Simulation complete. Final value: {value}") |
| 165 | return value |
| 166 | |
| 167 | def backpropagate(self, node: Node, value: float): |
| 168 | logger.debug("Starting backpropagation") |