Add multi-process self-play, eval workers, MCTS Cython port
Key changes for ISMCTS speed and correctness: - Cython port: HeuristicBot helpers (`heuristic_cy.pyx` + new `.pxd`) and ISMCTS searcher (`mcts.pyx`) now run as cdef. Both share a fast unified-action path through GameState's C interface to avoid Python round-trips on hot rollout/tree-walk paths. - Multi-process self-play and eval: `workers.py`, `eval_worker.py`, `interleaved_self_play.py`, plus trainer wiring with ProcessPoolExecutor + spawn context. Eval inside `evaluate.py` is parallel per opponent. - ISMCTS-specific eval (`evaluate.py`) runs MCTS at decision time so the metric matches deploy mode; `evaluation.eval_with_mcts` flag preserves backwards-compatible policy-only eval when needed. - Trainer logs progress per phase (self-play start/done, eval per opponent), and value loss is now scaled by `value_scale` so policy and value losses sit on comparable magnitudes. - Compact info-set key (`info_set.py`) using packed-struct format and child-key reuse during MCTS descent to cut per-step canonicalization. Tests: 19 ISMCTS suite passing, including parity (Cython-vs-Python sequential, batched-vs-sequential visit counts, push/pop round-trip). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,6 +30,10 @@ extensions = cythonize(
|
||||
"coolrl_lost_cities.games.classic.bots.heuristic_cy",
|
||||
["src/coolrl_lost_cities/games/classic/bots/heuristic_cy.pyx"],
|
||||
),
|
||||
Extension(
|
||||
"coolrl_lost_cities.games.classic.ismcts.mcts",
|
||||
["src/coolrl_lost_cities/games/classic/ismcts/mcts.pyx"],
|
||||
),
|
||||
],
|
||||
language_level=3,
|
||||
compiler_directives={
|
||||
|
||||
Reference in New Issue
Block a user