Skip to content

Implement iteration over nodes in DFT order; expose it to Cython#531

Closed
d-kad wants to merge 2 commits intogambitproject:masterfrom
d-kad:issue_530
Closed

Implement iteration over nodes in DFT order; expose it to Cython#531
d-kad wants to merge 2 commits intogambitproject:masterfrom
d-kad:issue_530

Conversation

@d-kad
Copy link
Copy Markdown
Contributor

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

Introduced a new nested class, GameRep::Nodes, which acts as a standard C++ forward iterator.

  • This iterator performs a depth-first, pre-order traversal of the game tree, starting from the root.
  • The GameRep class is now directly iterable, through the addition of: begin() and end() methods
  • const overloads for both methods to ensure const-correctness in functions like IsPerfectRecall().

Closes #530

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

d-kad commented Jul 4, 2025

@tturocy I implemented node traversal in operator++ with a single children iterator on stack using exception catching mechanism (mirroring your Python code snippet for the PR-checker)

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.

As this looks to be converging well towards a solution please do squash on the next iteration and give a good candidate commit message.

…FT order. Change Python API to use the new nodes iterator. Add tests.
@tturocy
Copy link
Copy Markdown
Member

tturocy commented Jul 10, 2025

Merged as 89cbddc with some minor adjustments.

@tturocy tturocy closed this Jul 10, 2025
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.

Implement iteration over nodes in depth-first traversal order

2 participants