Skip to content

Make Node.infoset, Node.outcome, Node.player lazy, node-anchored views (#946)#962

Merged
tturocy merged 12 commits into
gambitproject:masterfrom
d-kad:semi-algebra-of-games
Jul 1, 2026
Merged

Make Node.infoset, Node.outcome, Node.player lazy, node-anchored views (#946)#962
tturocy merged 12 commits into
gambitproject:masterfrom
d-kad:semi-algebra-of-games

Conversation

@d-kad

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

Copy link
Copy Markdown
Contributor

Closes #946

Description of the changes in this PR

Makes three node properties — Node.infoset, Node.outcome, and Node.player — return
lazy, node-anchored views (NodeInfoset, NodeOutcome, NodePlayer) that resolve on each
access rather than capturing a value at access time. A stored reference now tracks game
mutations and re-resolves to reflect the current tree, consistent with the already-lazy Node.children.

Each view resolves to None (and is falsy) when the relation is absent: a terminal node has
no infoset and no player; same for a node with no attached outcome. At a chance node,
Node.player resolves to the chance player (is_chance is True).

Node.parent remains eager as agreed.

Notes

  • The views are hashable (by their resolved object); transitional. No public resolve().
  • Infoset.__eq__, Outcome.__eq__, and Player.__eq__ now return NotImplemented on type
    mismatch (was plain False), so a real object and its view compare equal from either side.

@d-kad d-kad requested a review from tturocy June 25, 2026 14:50
Comment thread src/pygambit/node.pxi Outdated
Comment thread src/pygambit/node.pxi
Comment thread src/pygambit/node.pxi
Comment thread tests/test_node.py
Comment thread src/pygambit/node.pxi
@d-kad d-kad requested a review from tturocy June 26, 2026 13:20

@tturocy tturocy left a comment

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.

This looks positive, so let's proceed with .outcome and .player as discussed and combine them into one atomic change.

@d-kad d-kad added this to the gambit-16.7.0 milestone Jun 30, 2026
@d-kad d-kad self-assigned this Jun 30, 2026
@d-kad d-kad added python Items which involve coding in Python cython Items which involve coding in Cython labels Jun 30, 2026
@d-kad d-kad changed the title Make Node.infoset a lazy, node-anchored view (#946) Make Node.infoset, Node.outcome, Node.player lazy, node-anchored views (#946) Jun 30, 2026
@tturocy tturocy merged commit 1f6b4a1 into gambitproject:master Jul 1, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cython Items which involve coding in Cython python Items which involve coding in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[API]: Lazy evaluation of all relations between game elements

2 participants