Spaces:
Running
Running
Upload ai/agents/rust_mcts_agent.py with huggingface_hub
Browse files- ai/agents/rust_mcts_agent.py +20 -0
ai/agents/rust_mcts_agent.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import engine_rust
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class RustMCTSAgent:
|
| 5 |
+
def __init__(self, sims=1000):
|
| 6 |
+
self.sims = sims
|
| 7 |
+
|
| 8 |
+
def choose_action(self, gs: engine_rust.PyGameState):
|
| 9 |
+
# The Rust engine can run MCTS internally and set the move
|
| 10 |
+
# But we might want to just get the action index.
|
| 11 |
+
# Actually PyGameState has step_opponent_mcts which executes it.
|
| 12 |
+
# We'll use a wrapper that returns the suggested action.
|
| 13 |
+
pass
|
| 14 |
+
|
| 15 |
+
def get_best_move_incremental(self, gs: engine_rust.PyGameState, sims_per_step=100):
|
| 16 |
+
# This will be used for the "Live Update" feature
|
| 17 |
+
# We need to expose a way to get MCTS stats from Rust
|
| 18 |
+
# Currently the Rust bindings don't expose the search tree.
|
| 19 |
+
# I might need to update the Rust bindings to return the action values.
|
| 20 |
+
pass
|