MCPcopy
hub / github.com/algorithmicsuperintelligence/optillm / simulate

Method simulate

optillm/mcts.py:69–81  ·  view source on GitHub ↗
(self, node: MCTSNode)

Source from the content-addressed store, hash-verified

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}")

Callers 1

searchMethod · 0.95

Calls 4

is_terminalMethod · 0.95
generate_actionsMethod · 0.95
apply_actionMethod · 0.95
evaluate_stateMethod · 0.95

Tested by

no test coverage detected