Skip to content

Commit 0534af4

Browse files
committed
add the mcts agent
1 parent c484e68 commit 0534af4

File tree

1 file changed

+27
-1
lines changed
  • visual-tree-search-backend/app/api/lwats/agents_async/SearchAgents

1 file changed

+27
-1
lines changed

visual-tree-search-backend/app/api/lwats/agents_async/SearchAgents/mcts_agent.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,30 @@ async def run(self, websocket=None) -> list[LATSNode]:
1717
"timestamp": datetime.utcnow().isoformat()
1818
})
1919

20-
pass
20+
best_node = await self.mcts_search(websocket)
21+
print_trajectory(best_node)
22+
return best_node
23+
24+
25+
# Performs Monte Carlo Tree Search starting from the root node with WebSocket updates.
26+
# Uses GPT-4 for node selection and reflection-based backpropagation.
27+
async def mcts_search(self, websocket=None):
28+
for i in range(self.config.iterations):
29+
await self.websocket_iteration_start(i, websocket=websocket)
30+
31+
print(f"Iteration {i}/{self.config.iterations} ...")
32+
33+
# Step 1: Node Selection
34+
# Selection: Use GPT-4 to select a promising path
35+
36+
37+
# Step 2: Node Expansion
38+
# Expansion: Expand the selected node if possible
39+
40+
41+
# Step 3: Node Simulation
42+
# Simulation: Evaluate the current path
43+
44+
45+
# Step 4: Backpropagation
46+
# # Reflection-based backpropagation

0 commit comments

Comments
 (0)