Skip to content

ENH: Implement pure strategy node reachability check#632

Merged
tturocy merged 11 commits intogambitproject:masterfrom
d-kad:issue_629
Nov 25, 2025
Merged

ENH: Implement pure strategy node reachability check#632
tturocy merged 11 commits intogambitproject:masterfrom
d-kad:issue_629

Conversation

@d-kad
Copy link
Copy Markdown
Contributor

@d-kad d-kad commented Nov 20, 2025

Description.

This pull request introduces a new method, GameNode::IsStrategyReachable(), to determine if a given node in an extensive tree form can be reached by any pure strategy profile. A node is reachable if there exists at least one pure strategy profile where the resulting path of play passes through that node. A pure strategy requires the player to choose the same action at every member node of that information set. In games with absent-mindedness, a path of play may visit the same information set multiple times, making some of the ancestors of its member nodes unreachable.

The existing GameTreeRep::BuildInfosetParents() method already handles the logic for absent-minded revisiting information sets. This traversal will be leveraged to collect the set of reachable decision nodes.

Implementation Summary.
The implementation follows the design discussed in the issue:

  1. A new cache member m_reachableNodes is added to GameTreeRep
  2. The existing GameTreeRep::BuildInfosetParents() traversal is augmented to populate this set, reusing its logic for handling absent-mindedness.
  3. A new C++ method, GameNodeRep::IsStrategyReachable(), queries the cache
  4. The functionality is exposed to Python as a new read-only property, pygambit.Node.is_strategy_reachable

Closes #629

@tturocy tturocy self-requested a review November 20, 2025 11:54
Copy link
Copy Markdown
Member

@tturocy tturocy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally this really needs to be implemented as a set of nodes (or subtrees) which are not reachable. Un-reachability is the exceptional case not the usual case.


@pytest.mark.parametrize("game, expected_reachable_indices", [
# Games without Absent-Mindedness where all nodes are reachable.
(games.read_from_file("e02.efg"), set(range(7))),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A further thought on these tests. By definition all nodes are reachable in a game that does not have absent mindedness. This could be written as a different test that automatically just checks all nodes are reachable and that none of the information sets are absent-minded (once that feature is done).

@d-kad d-kad requested a review from tturocy November 24, 2025 13:51
@tturocy tturocy merged commit 010baa6 into gambitproject:master Nov 25, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ENH: Implement pure strategy node reachability check

2 participants