GAIGResearch / TabletopGames

MIT License
78 stars 55 forks source link

GLM heuristics with interactions #280

Closed hopshackle closed 4 months ago

hopshackle commented 5 months ago

A Pull Request for some improved MCTS testing, and infrastructure for Expert Iteration support.

1) This includes a small (genuinely!) refactor of MCTS to allow better accessibility for testing. Unit tests for the main selection rules have been added, plus some other key MCTS parameterisations.

2) The Rollout Termination functionality has been extended to MultiTree MCTS (this was an oversight); and an option for END_TURN added, for those games that do not have rounds. An option has been added (rolloutLengthPerPlayer = false as default) for MCTS to multiply the rolloutLength by the number of players; as in some games there is a clear proportionality here.

3) The major addition is for GLMHeuristics - these support Linear and Logistic functions as previously. The old AbstractStateHeuristic is replaced. The main change is that these can be parameterised by a sparse JSON file (sparse in the sense that coefficients need only be specified for the non-zero entries), and automatic support for any level of interactions between the individual features (e.g. for GOLD_IN_HAND:EARLY_GAME, separating the interacting features with colons).

4) Action/State/MCTSFeatureListeners upgraded to be able to record multiple targets (i.e. WIN and SCORE and ORDINAL...) instead of being restricted to just one.

5) MASTPlayer for rollout now fully paramateristable by MASTPLayerParams to support parameter tuning. On a related note, MASTPlus heuristic now allows an arbitrary IActionHeuristic to be layered with MAST...blending an 'expert' with MAST values. This seems to be more successful than either by themselves in some cases.