Skip to content

remove use of poker.efg in test suite#608

Merged
tturocy merged 3 commits intomasterfrom
de-duplicate_simple_poker_game_in_test_suite
Nov 17, 2025
Merged

remove use of poker.efg in test suite#608
tturocy merged 3 commits intomasterfrom
de-duplicate_simple_poker_game_in_test_suite

Conversation

@rahulsavani
Copy link
Copy Markdown
Member

resolves #606

@rahulsavani rahulsavani requested a review from tturocy November 12, 2025 19:40
@rahulsavani
Copy link
Copy Markdown
Member Author

poker.efg is still used in the user guide. I left it in tests/test_games, but now realise that for the user guide it likely reads it from contrib/games. We then may want to delete poker.efg from tests/test_games.

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.

We should have just one version of this game. It is at the moment awkward that we have games in tests/test_games and in contrib/games. But we will need to sort that out later, and I expect it will gradually come out in the was as we build out tests for algorithms and solution concepts.

We should decide which version we want to have, because there are several issues here:

  • We want a version that uses rational fractions rather than decimal representation. The decimal representation version would be very old (when "floating point" payoffs were permitted). We want to encourage the use of rational payoffs where it makes sense to do so.

  • I believe Myerson (1991) likely gets priority on this game as written, I do not have an earlier citation and there is none in his textbook. However two issues to consider:

    • Myerson treats Red (high card) followed by Fold as a win for the informed player. This is consistent with the narrative exposition in the book, but is not consistent with how "poker" works. Alternatively, the version of this game used in Reiley's classroom experiment follows the "normal" rules of poker.
    • Myerson does not actually give the players human names. However the names Fred and Alice are consistent with his textbook, as he uses male pronouns for odd-numbered players and female for even-numbered ones.
  • We also need a name for the game. Calling this 2-card poker is not accurate. In Myerson's description, the deals are "red" and "black" because they're dealt from a standard deck of cards but only the suit colour matters for payoffs. Further, calling it 2-card poker makes it sound more like e.g. Borel or von Neumann's versions, where each player gets a "card" (a draw from the uniform distribution).

Tagging @edwardchalstrey1 because this interacts with the relevant tutorial.

@rahulsavani
Copy link
Copy Markdown
Member Author

Yes, that all makes sense @tturocy.

Happy to make the required further changes once we agree what we want to do.

Note this is not the only example of duplication between contrib/games and tests/test_games:

cat duplicates.txt
1732067649 429 ./games/poker.efg
1732067649 429 ./test_games/poker.efg
1954241526 939 ./games/2x2.agg
1954241526 939 ./test_games/2x2.agg
2764097499 358 ./games/e01.efg
2764097499 358 ./test_games/e01.efg
3644076083 110 ./games/e02.nfg
3644076083 110 ./test_games/e02.nfg
3794749701 273 ./games/e02.efg
3794749701 273 ./test_games/e02.efg
3831085167 147 ./games/zero.nfg
3831085167 147 ./test_games/zero.nfg
872932573 1542 ./games/cent3.efg
872932573 1542 ./test_games/cent3.efg

@tturocy
Copy link
Copy Markdown
Member

tturocy commented Nov 13, 2025

Right, that is something we know about. :) But in those cases there's just one version of the file (as far as I know), just kept in two places.

The way out of that would be to have something like a "library of standard games" which could be packaged and imported directly - something we've talked about before, perhaps we need to start thinking about articulating that as a facility and a project to do...

@rahulsavani
Copy link
Copy Markdown
Member Author

The decimal representation version would be very old (when "floating point" payoffs were permitted)

The myerson_2_card_poker.efg is the one with floating point, and then only for the chance probabilities:

c "" 1 "(0,1)" { "RED" 0.500000 "BLACK" 0.500000 } 1 "Outcome 3" { -1, 1 }

I have just checked and all tests (on this branch) still pass with this changed to rational probabilities, i.e.:

c "" 1 "(0,1)" { "RED" 1/2 "BLACK" 1/2 } 1 "Outcome 3" { -1, 1 }

Thus, we just need to decide on game naming/actions labels etc. and I can update myerson_2_card_poker.efg and the tests (only in terms of action labels, and the file name) accordingly.

@edwardchalstrey1
Copy link
Copy Markdown
Member

Tagging @edwardchalstrey1 because this interacts with the relevant tutorial.

In the tutorial the efg file isn't used as the game is constructed via the code so not to worry

@tturocy
Copy link
Copy Markdown
Member

tturocy commented Nov 13, 2025

Yes @edwardchalstrey1, but it would be good that the game we build there matches the saved file, just for the avoidance of any confusion!!! :)

@rahulsavani
Copy link
Copy Markdown
Member Author

@tturocy: The tests now only use stripped_down_poker.efg, which is faithful to Reiley et al in terms of action labels and payoffs. The reuse of action labels ("Fold" and "Bet" in particular) means that a couple of tests were simply dropped, since they relied on the uniqueness of said labels. I don't think that's a problem. I didn't want to drop some other tests that used infoset labels, so I inserted the infoset labels from the old myerson_2_card_poker.efg into stripped_down_poker.efg, which was adapted from poker.efg which had empty infoset labels.

@edwardchalstrey1 : For after this is settled on any merged into the tests:

contrib/games still contains poker.efg, and tests/test_userguide.py still contains test_myerson_poker(). If you could update both of these when you update the user guide that would be great (putting stripped_down_poker.efg in contrib/games, and, assuming we keep test_userguid.py, updating it to create the right game, exactly as in the updated user guide, not mentioning Myerson at all, but Reiley et al (2008).

@rahulsavani rahulsavani requested a review from tturocy November 14, 2025 13:22
@edwardchalstrey1
Copy link
Copy Markdown
Member

edwardchalstrey1 commented Nov 17, 2025

assuming we keep test_userguide.py

@rahulsavani I actually dropped this test and replaced it with a new one that checks all tutorials can be run without error, which doesn't need to be updated when any new tutorials are added or existing ones changed, looks like Reiley et al (2008) is cited correctly as well Edit: actually it mentions them both, so should I drop the Myerson citation?

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.

This addresses well the immediate issue of duplication. We can take for further discussion the best way to manage having a catalogue of standard games.

@edwardchalstrey1
Copy link
Copy Markdown
Member

Also the resultant EFG from tutorial 3 has slightly different labels for players, actions and payoff nodes, and lacks the full title . I propose I should update the tutorial version to have the proper title and standardisation of "Fold" (vs "Pass"), but perhaps better to keep the terminal node labels referencing the player that wins e.g. "Alice wins big" (indifferent over the actual names of course 😄).

Tutorial 3 EFG:

EFG 2 R "One card poker" { "Alice" "Bob" }
""

c "" 1 "" { "King" 1/2 "Queen" 1/2 } 0
p "" 1 1 "" { "Raise" "Fold" } 0
p "" 2 1 "" { "Meet" "Pass" } 0
t "" 1 "Alice wins big" { 2, -2 }
t "" 2 "Alice wins" { 1, -1 }
t "" 4 "Bob wins" { -1, 1 }
p "" 1 2 "" { "Raise" "Fold" } 0
p "" 2 1 "" { "Meet" "Pass" } 0
t "" 3 "Bob wins big" { -2, 2 }
t "" 2 "Alice wins" { 1, -1 }
t "" 4 "Bob wins" { -1, 1 }

New stripped down poker EFG from this PR:

EFG 2 R "A simple Poker game" { "Fred" "Alice" }
"Stripped-Down Poker: a simple game of one-card poker from Reiley et al (2008)."

c "" 1 "(0,1)" { "King" 1/2 "Queen" 1/2 } 0
p "" 1 1 "(1,1)" { "Bet" "Fold" } 0
p "" 2 1 "(2,1)" { "Call" "Fold" } 0
t "" 1 "Win Big" { 2, -2 }
t "" 2 "Win" { 1, -1 }
t "" 4 "Lose" { -1, 1 }
p "" 1 2 "(1,2)" { "Bet" "Fold" } 0
p "" 2 1 "(2,1)" { "Call" "Fold" } 0
t "" 3 "Lose Big" { -2, 2 }
t "" 2 "Win" { 1, -1 }
t "" 4 "Lose" { -1, 1 }

@tturocy tturocy merged commit ecc2577 into master Nov 17, 2025
28 checks passed
@tturocy tturocy deleted the de-duplicate_simple_poker_game_in_test_suite branch November 17, 2025 11:37
@edwardchalstrey1
Copy link
Copy Markdown
Member

Also, what is the difference between: p "" 1 1 "" { "Raise" "Fold" } 0 and p "" 1 1 "(1,1)" { "Raise" "Fold" } 0, what does the "(1,1)" do?

@tturocy
Copy link
Copy Markdown
Member

tturocy commented Nov 17, 2025

Also, what is the difference between: p "" 1 1 "" { "Raise" "Fold" } 0 and p "" 1 1 "(1,1)" { "Raise" "Fold" } 0, what does the "(1,1)" do?

That field is an explicit information set label. It is possibly dubious to be labelling these in that way given the broader discussion about how we order information sets in "canonicalisation" - but for present purposes it's good enough. When we have our standardised games library this will become moot.

@tturocy
Copy link
Copy Markdown
Member

tturocy commented Nov 17, 2025

Also the resultant EFG from tutorial 3 has slightly different labels for players, actions and payoff nodes, and lacks the full title . I propose I should update the tutorial version to have the proper title and standardisation of "Fold" (vs "Pass"), but perhaps better to keep the terminal node labels referencing the player that wins e.g. "Alice wins big" (indifferent over the actual names of course 😄).

Tutorial 3 EFG:

EFG 2 R "One card poker" { "Alice" "Bob" }
""

c "" 1 "" { "King" 1/2 "Queen" 1/2 } 0
p "" 1 1 "" { "Raise" "Fold" } 0
p "" 2 1 "" { "Meet" "Pass" } 0
t "" 1 "Alice wins big" { 2, -2 }
t "" 2 "Alice wins" { 1, -1 }
t "" 4 "Bob wins" { -1, 1 }
p "" 1 2 "" { "Raise" "Fold" } 0
p "" 2 1 "" { "Meet" "Pass" } 0
t "" 3 "Bob wins big" { -2, 2 }
t "" 2 "Alice wins" { 1, -1 }
t "" 4 "Bob wins" { -1, 1 }

New stripped down poker EFG from this PR:

EFG 2 R "A simple Poker game" { "Fred" "Alice" }
"Stripped-Down Poker: a simple game of one-card poker from Reiley et al (2008)."

c "" 1 "(0,1)" { "King" 1/2 "Queen" 1/2 } 0
p "" 1 1 "(1,1)" { "Bet" "Fold" } 0
p "" 2 1 "(2,1)" { "Call" "Fold" } 0
t "" 1 "Win Big" { 2, -2 }
t "" 2 "Win" { 1, -1 }
t "" 4 "Lose" { -1, 1 }
p "" 1 2 "(1,2)" { "Bet" "Fold" } 0
p "" 2 1 "(2,1)" { "Call" "Fold" } 0
t "" 3 "Lose Big" { -2, 2 }
t "" 2 "Win" { 1, -1 }
t "" 4 "Lose" { -1, 1 }

Ah, that's a good catch. Yes, it would be good to be consistent. Neither other source uses personal names for players, but I think it's nice to do so here especially in the tutorial just because it makes it more accessible. "Alice" and "Bob" are of course more comp sci figures; I have no idea where "Fred" and "Alice" may have come from.

Let's go with "Alice" and "Bob" universally perhaps just to be consistent both internally and with the "folk" naming?

@rahulsavani
Copy link
Copy Markdown
Member Author

Yes, it is what I mentioned in my comment to Ted above: I added these infoset labels to keep a test parametrization we had before using this game. I think you can just drop these infoset labels from the tutorial, and leave them only in the tests version. I could also do 2 versions in the tests, one with and one without infoset labels, but I think that is not a must.

Please do copy the labels of players and actions in the tutorial to match the new test version, which exactly mirrors Reiley et al. Fine to have player names in the outcome labels for who wins/loses.

Myerson's game is different in an important way in terms of payoffs, and also in terms of action/player labels. We might just want to mention it as a similar variant in a "footnote" on the tutorial, with the main reference to Reiley et al.

@rahulsavani
Copy link
Copy Markdown
Member Author

rahulsavani commented Nov 17, 2025

Ah was typing at the same time as Ted.

Let's go with "Alice" and "Bob" universally perhaps just to be consistent both internally and with the "folk" naming?

@tturocy , shall I update the test version to use Alice and Bob then?

@tturocy
Copy link
Copy Markdown
Member

tturocy commented Nov 17, 2025

Ah was typing at the same time as Ted.

Let's go with "Alice" and "Bob" universally perhaps just to be consistent both internally and with the "folk" naming?

@tturocy , shall I update the test version to use Alice and Bob then?

If we're in agreement then let's ensure we're consistent with this naming everywhere (in games/contrib too - there's a few versions of poker kicking around there and let's sort that).

While you're doing this, maybe go ahead also and do a different naming scheme for the information sets? Just because we have the potential confusion about the (player, id) naming scheme for infosets (because in the GUI you can currently set it to display identifiers of that format even though they are not part of the game labels)

@rahulsavani
Copy link
Copy Markdown
Member Author

I am happy using Alice/Bob everywhere, so let's go for that.

I didn't like the infoset labels, but wasn't sure on the best alternative labels. How about:

"Deal", "Alice King", "Alice Queen", "Bob"

Or any other suggestions?

@tturocy
Copy link
Copy Markdown
Member

tturocy commented Nov 17, 2025

Maybe "Alice has King", "Alice has Queen", "Bob's response" or something like that? Wouldn't want to overload "Bob" to mean both a player and an information set.

@rahulsavani
Copy link
Copy Markdown
Member Author

rahulsavani commented Nov 17, 2025

@tturocy @edwardchalstrey1

strippped_down_poker.efg and corresponding tests updated as follows:

  • Player names from Fred/Alice to Alice/Bob
  • New infoset labels: "Deal", "Alice has King", "Alice has Queen", "Bob's response".

@tturocy: I hadn't noticed that you had already merged this before I just pushed these final changes to player/info set names; please let me know if you need me to do anything further before you get this onto master.

@edwardchalstrey1
Copy link
Copy Markdown
Member

@tturocy @edwardchalstrey1

strippped_down_poker.efg and corresponding tests updated as follows:

  • Player names from Fred/Alice to Alice/Bob
  • New infoset labels: "Deal", "Alice has King", "Alice has Queen", "Bob's response".

@tturocy: I hadn't noticed that you had already merged this before I just pushed these final changes to player/info set names; please let me know if you need me to do anything further before you get this onto master.

Hi @rahulsavani I added these commits in a new PR where I was updating the tutorial to match it, see Q on node labelling: #621

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.

TEST: Duplicated game (simple poker) in test suite

3 participants