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>
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
from setuptools import Extension, setup
|
|
|
|
try:
|
|
from Cython.Build import cythonize
|
|
except ImportError as exc: # pragma: no cover
|
|
raise RuntimeError("Cython is required to build coolrl-lost-cities") from exc
|
|
|
|
|
|
extensions = cythonize(
|
|
[
|
|
Extension(
|
|
"coolrl_lost_cities.games.classic.game",
|
|
["src/coolrl_lost_cities/games/classic/game.pyx"],
|
|
),
|
|
Extension(
|
|
"coolrl_lost_cities.games.classic.deep_cfr.cfr_math",
|
|
["src/coolrl_lost_cities/games/classic/deep_cfr/cfr_math.pyx"],
|
|
),
|
|
Extension(
|
|
"coolrl_lost_cities.games.classic.deep_cfr.encoding",
|
|
["src/coolrl_lost_cities/games/classic/deep_cfr/encoding.pyx"],
|
|
),
|
|
Extension(
|
|
"coolrl_lost_cities.games.classic.deep_cfr.traversal",
|
|
["src/coolrl_lost_cities/games/classic/deep_cfr/traversal.pyx"],
|
|
),
|
|
Extension(
|
|
"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={
|
|
"boundscheck": False,
|
|
"wraparound": False,
|
|
"cdivision": True,
|
|
"initializedcheck": False,
|
|
},
|
|
)
|
|
|
|
|
|
setup(ext_modules=extensions)
|