Skip to content

Refactor GameTreeRep::IsPerfectRecall with efficient single-pass algorithm; add new tests#532

Merged
tturocy merged 3 commits intogambitproject:masterfrom
d-kad:issue_484
Aug 5, 2025
Merged

Refactor GameTreeRep::IsPerfectRecall with efficient single-pass algorithm; add new tests#532
tturocy merged 3 commits intogambitproject:masterfrom
d-kad:issue_484

Conversation

@d-kad
Copy link
Copy Markdown
Contributor

@d-kad d-kad commented Jun 24, 2025

This pull request completely refactors the old GameTreeRep::IsPerfectRecall method

  • Replaced the old, nested-loop implementation with a linear-time, single-pass DFT algorithm.
  • The new implementation correctly handles games with Chance moves by initializing the history for the Chance player. This resolves a map::at key-not-found error that occurred when traversing games like Kuhn Poker.
  • Added a new, parameterized test suite covering both perfect and imperfect recall cases (namely, forgetting past action, forgetting past information, absent-mindedness)

Closes #484

@d-kad d-kad requested a review from tturocy June 24, 2025 14:23
@d-kad
Copy link
Copy Markdown
Contributor Author

d-kad commented Jun 24, 2025

@tturocy @rahulsavani you'll see there's some extra code in IsPerfectRecall that isn't needed for the check itself. I kept the print statements in for now so we can easily see the final status for each player and the last_action_for_node map it builds. At the moment, the code populates it because we may be using that data for the RSF refactoring later.
Happy to strip this down to just the bare essentials for a cleaner PR-checker if needed.

d-kad added 2 commits August 1, 2025 11:58
…erator class to zip actions and children; Improve BuildInfosetParents to treat correctly absent-mindedness
@d-kad d-kad force-pushed the issue_484 branch 2 times, most recently from 9e9f81f to 91c56e6 Compare August 1, 2025 16:04
@tturocy tturocy merged commit a72ead3 into gambitproject:master Aug 5, 2025
17 of 19 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: Improve implementation of IsPerfectRecall

2 participants