Skip to content

Add GameSubgame class and subgame API#919

Merged
tturocy merged 19 commits into
gambitproject:masterfrom
d-kad:GameSubgame
Jun 5, 2026
Merged

Add GameSubgame class and subgame API#919
tturocy merged 19 commits into
gambitproject:masterfrom
d-kad:GameSubgame

Conversation

@d-kad
Copy link
Copy Markdown
Contributor

@d-kad d-kad commented Jun 3, 2026

Issues closed by this PR

Description of the changes in this PR

Adds GameSubgameRep (C++) and Subgame (Python), a first-class object representing a subgame, building on the subgame-root detection (#584).

On Subgame: .root, .parent, .children, and .difference (infosets in this subgame but not in any of its child subgames).

On Game: .subgames (in postorder) and .minimal_subgame(infoset) (returns the smallest Subgame containing a given infoset).

Parent/child relations live on the Subgame object rather than on GameRep, for consistency with node.parent, infoset.player, etc.; collection-level queries stay on Game.

The subgame caches (postorder vector m_subgamePostorder + by-root lookup map m_subgameByRoot) are merged into a private SubgameData struct with a validity flag.
m_subgameByRoot makes IsSubgameRoot() O(1) -- closes an old TODO.

Not implemented: GetInfosets(subgame, player) from the description of #585difference is the closest piece (unfiltered by player) — will be shipped separately as this PR is pretty big already.

Supersedes #909

@d-kad d-kad added this to the gambit-16.7.0 milestone Jun 3, 2026
@d-kad d-kad self-assigned this Jun 3, 2026
@d-kad d-kad added c++ Items which involve writing in C++ enhancement cython Items which involve coding in Cython labels Jun 3, 2026
@d-kad d-kad requested a review from tturocy June 3, 2026 14:54
@tturocy tturocy merged commit 30440b0 into gambitproject:master Jun 5, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Items which involve writing in C++ cython Items which involve coding in Cython enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Implement concept of GameSubgameRep in C++/GameSubgame in Python

2 participants