Skip to content

Add Game.make_outcome, and represent absent outcomes by a null outcome - #1084

Merged
tturocy merged 16 commits into
gambitproject:masterfrom
d-kad:make_outcome
Aug 28, 2026
Merged

tturocy merged 16 commits into
gambitproject:masterfrom
d-kad:make_outcome

Conversation

@d-kad

@d-kad d-kad commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Issues closed by this PR

Description of the changes in this PR

This PR implements Game.make_outcome and the null-outcome representation from #1061.
The removal of Game.add_outcome/Game.delete_outcome, and the implicit deletion that depends on it are to follow.

Absent outcomes are represented internally by a per-game null outcome, so nodes and contingencies never hold
a null pointer and payoff calculations need no null guards.
From calling code, a node or contingency with no outcome now reports that outcome rather than None;
it has label and number of None, zero payoffs, and compares unequal to everything including itself,
following the treatment of missing values in pandas.
Null outcomes do not appear when iterating over a game's outcomes, and assigning a payoff to
one raises UndefinedOperationError.

Game.make_outcome creates an outcome and attaches it to a set of nodes (extensive) or contingencies (strategic)
in a single operation, treating them as an equivalence class (cf. Game.make_infoset and Game.make_event).
Payoffs are given as a mapping over all of the game's players. An outcome all of whose references are
taken over by the operation is removed from the game; its label may then be reused (cf. Game.make_infoset).

Game.new_table no longer creates an outcome for every contingency; outcomes are created as they are needed.
Game.from_arrays and Game.from_dict are unaffected, as supplying payoffs creates the outcomes which hold them.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@d-kad d-kad self-assigned this Aug 26, 2026
@d-kad d-kad added this to the gambit-17.0.0.beta.1 milestone Aug 26, 2026
@d-kad
d-kad requested a review from tturocy August 26, 2026 10:22
@tturocy

tturocy commented Aug 26, 2026

Copy link
Copy Markdown
Member

@d-kad @rahulsavani I've done a first review of this and it's in good shape. To this importantly I have added some new GUI features in the strategic form that try to hint at outcome structure and also allow editing of the outcome structure.

Here's a game that's useful for trying it out, featuring both multiple-cell outcomes and also some "null" outcomes

NFG 1 R "Outcome structure demo" { "Row player" "Column player" }

{ { "A" "B" "C" "D" }
{ "W" "X" "Y" "Z" }
}
"4x4 game exercising shared, singleton, and absent outcomes"

{
{ "Corners" 5, 5 }
{ "Diagonal" 8, 2 }
{ "Top row (B,C)" 1, 9 }
{ "Solo" 6, 6 }
}
1 0 4 1 3 2 0 0 3 0 2 0 1 0 0 1

Please have a go, views welcome

@d-kad

d-kad commented Aug 27, 2026

Copy link
Copy Markdown
Contributor Author

Had a go everything I tried works nicely, liked the hover highlighting feature especially!

Multi-cell merge across non-adjacent cells didn't work on macOS.
⌘-click would collaps the selection to one cell; pushed a fix ⌘/Ctrl-click now adds the clicked
contingency's block.

@tturocy

tturocy commented Aug 28, 2026

Copy link
Copy Markdown
Member

Had a go everything I tried works nicely, liked the hover highlighting feature especially!

Multi-cell merge across non-adjacent cells didn't work on macOS. ⌘-click would collaps the selection to one cell; pushed a fix ⌘/Ctrl-click now adds the clicked contingency's block.

This is a good idea. I have extended it also so that gesture is now a toggle, doesn't just add but can also be used to remove the contingency.

@tturocy
tturocy merged commit 36ff716 into gambitproject:master Aug 28, 2026
14 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.

2 participants