(self, node: MCTSNode)
| 67 | return selected_child |
| 68 | |
| 69 | def simulate(self, node: MCTSNode) -> float: |
| 70 | logger.debug(f"Starting simulation from node. Current query: {node.state.current_query}") |
| 71 | state = node.state |
| 72 | for i in range(self.simulation_depth): |
| 73 | if self.is_terminal(state): |
| 74 | logger.debug(f"Reached terminal state at depth {i}") |
| 75 | break |
| 76 | action = random.choice(self.generate_actions(state)) |
| 77 | state = self.apply_action(state, action) |
| 78 | logger.debug(f"Simulation step {i+1}. Action: {action[:50]}...") |
| 79 | value = self.evaluate_state(state) |
| 80 | logger.debug(f"Simulation complete. Final state value: {value}") |
| 81 | return value |
| 82 | |
| 83 | def backpropagate(self, node: MCTSNode, value: float): |
| 84 | logger.debug(f"Starting backpropagation. Initial value: {value}") |
no test coverage detected