From 80a96e246d196dc6321dbaae891d23b7eee55ed0 Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Thu, 12 Mar 2026 10:49:03 +0000 Subject: [PATCH 1/8] Move Bagwell 1995 game to catalog. --- catalog/bagwell1995.efg | 29 +++++++++++++++++++++++++++++ contrib/games/bagwell.efg | 18 ------------------ doc/samples.rst | 12 ------------ 3 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 catalog/bagwell1995.efg delete mode 100644 contrib/games/bagwell.efg diff --git a/catalog/bagwell1995.efg b/catalog/bagwell1995.efg new file mode 100644 index 000000000..58889c664 --- /dev/null +++ b/catalog/bagwell1995.efg @@ -0,0 +1,29 @@ +EFG 2 R "Bagwell (GEB 1995) commitment and (un)observability" { "Player 1" "Player 2" } +"This is a Stackelberg-type game with imperfectly observed commitment, following the +analysis of Bagwell [^Bag1995]. The outcomes and payoffs are the same as in Bagwell's +model. This example sets the probability that the follower 'correctly' observes the +leader's action as .99 (99/100). The key result is that the only pure-strategy +equilibrium that survives if observability is imperfect is the one in which players +choose the actions that would form an equilibrium if the game was a *simultaneous-move* +game. There is an equilibrium in which the 'Stackelberg' action is played with high +probability, but strictly less than one. + +[^Bag1995]: Bagwell, Kyle (1995) Commitment and observability in games. + _Games and Economic Behavior_ 8: 271-280. +" + +p "" 1 1 "" { "S" "C" } 0 +c "" 1 "" { "s" 99/100 "c" 1/100 } 0 +p "" 2 1 "" { "S" "C" } 0 +t "" 1 "SS" { 5, 2 } +t "" 2 "SC" { 3, 1 } +p "" 2 2 "" { "S" "C" } 0 +t "" 1 "SS" { 5, 2 } +t "" 2 "SC" { 3, 1 } +c "" 2 "" { "s" 1/100 "c" 99/100 } 0 +p "" 2 1 "" { "S" "C" } 0 +t "" 3 "CS" { 6, 3 } +t "" 4 "CC" { 4, 4 } +p "" 2 2 "" { "S" "C" } 0 +t "" 3 "CS" { 6, 3 } +t "" 4 "CC" { 4, 4 } diff --git a/contrib/games/bagwell.efg b/contrib/games/bagwell.efg deleted file mode 100644 index 9ac3f034c..000000000 --- a/contrib/games/bagwell.efg +++ /dev/null @@ -1,18 +0,0 @@ -EFG 2 R "Bagwell Commitment and Unobservability Example" { "Player 1" "Player 2" } -"Stackelberg game with imperfectly observed commitment, from Bagwell (1993)" - -p "" 1 1 "" { "S" "C" } 0 -c "" 1 "" { "s" 99/100 "c" 1/100 } 0 -p "" 2 1 "" { "S" "C" } 0 -t "" 1 "SS" { 5, 2 } -t "" 2 "SC" { 3, 1 } -p "" 2 2 "" { "S" "C" } 0 -t "" 1 "SS" { 5, 2 } -t "" 2 "SC" { 3, 1 } -c "" 2 "" { "s" 1/100 "c" 99/100 } 0 -p "" 2 1 "" { "S" "C" } 0 -t "" 3 "CS" { 6, 3 } -t "" 4 "CC" { 4, 4 } -p "" 2 2 "" { "S" "C" } 0 -t "" 3 "CS" { 6, 3 } -t "" 4 "CC" { 4, 4 } diff --git a/doc/samples.rst b/doc/samples.rst index e70591203..c495fd211 100644 --- a/doc/samples.rst +++ b/doc/samples.rst @@ -21,18 +21,6 @@ Sample games International Journal of Game Theory 32(4): 443-453. `_ -:download:`bagwell.efg <../contrib/games/bagwell.efg>` - Stackelberg leader game with imperfectly observed commitment, - from `Bagwell, Kyle (1993) Commitment and observability in games. - Games and Economic Behavior 8: 271-280. - `_ - -:download:`bayes2a.efg <../contrib/games/bayes2a.efg>` - A twice-repeated Bayesian game, with two players, each having two - types and two actions. This game also illustrates the use of payoffs - at nonterminal nodes in Gambit, which can substantially simplify the - representation of multi-stage games such as this. - :download:`cent3.efg <../contrib/games/cent3.efg>` A three-stage centipede game, featuring an exogenous probability that one player is an altruistic type, who always passes. From bc5138e89a9874fb71e220abdc1182e8476a9206 Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Thu, 12 Mar 2026 10:49:53 +0000 Subject: [PATCH 2/8] Remove mentions of games we are not going to put in catalog just now. --- doc/samples.rst | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/doc/samples.rst b/doc/samples.rst index c495fd211..c3f669c17 100644 --- a/doc/samples.rst +++ b/doc/samples.rst @@ -1,16 +1,6 @@ Sample games ~~~~~~~~~~~~ -:download:`2x2x2.nfg <../contrib/games/2x2x2.nfg>` - A three-player normal form game with two strategies per player. - This game has nine Nash equilibria, - which is the maximal number of regular Nash equilibria possible - for a game of this size. See - `McKelvey, Richard D. and McLennan, Andrew (1997). - The maximal number of regular totally mixed Nash equilibria. - Journal of Economic Theory 72(2): 411-425. - `_ - :download:`2x2x2-nau.nfg <../contrib/games/2x2x2-nau.nfg>` A three-player normal form game with two strategies per player. This game has three pure strategy equilibria, two @@ -41,12 +31,6 @@ Sample games response equilibrium correspondence can have a "backward-bending" segment on the principal branch. -:download:`montyhal.efg <../contrib/games/montyhal.efg>` - The famous - `Monty Hall problem - `_: if Monty offers - to let you switch doors, should you? - :download:`nim.efg <../contrib/games/nim.efg>` This is a Nim-like game, which is a useful example of the value of backward induction. @@ -77,14 +61,7 @@ Sample games strong hand counts for a win for that player, so folding is only weakly rather than strictly dominated in this case. -:download:`4cards.efg <../contrib/games/4cards.efg>` - A slightly more complex poker example, contributed by Alix Martin. - :download:`spence.efg <../contrib/games/spence.efg>` A version of Spence's classic job-market signaling game. This version comes from `Joel Watson's Strategy textbook `_. - - -These games, and others, ship in the standard Gambit source -distribution in the directory `contrib/games`. From a1da8e34b1e90f154b6540a45efc456f6bb15fbd Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Thu, 12 Mar 2026 11:01:30 +0000 Subject: [PATCH 3/8] Move 2smp back to contrib from catalog --- {catalog => contrib/games}/2smp.efg | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {catalog => contrib/games}/2smp.efg (100%) diff --git a/catalog/2smp.efg b/contrib/games/2smp.efg similarity index 100% rename from catalog/2smp.efg rename to contrib/games/2smp.efg From 3170568463917def1aef58bad5509762ec33eba5 Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Thu, 12 Mar 2026 11:11:23 +0000 Subject: [PATCH 4/8] Capture some details on game provenance. --- contrib/games/2x2x2-nau.nfg | 7 ++++++- contrib/games/loopback.nfg | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/contrib/games/2x2x2-nau.nfg b/contrib/games/2x2x2-nau.nfg index 0e7782693..0e9ca9eec 100644 --- a/contrib/games/2x2x2-nau.nfg +++ b/contrib/games/2x2x2-nau.nfg @@ -4,7 +4,12 @@ NFG 1 R "2x2x2 example with 3 pure, 2 incompletely mixed, and a continuum of com { "1" "2" } { "1" "2" } } -"" +"Example game from Nau et al [^Nau2004]. + +[^Nau2004]: Nau, Robert, Gomez Canovas, Sabrina, and Hansen, Pierre (2004). + On the geometry of Nash equilibria and correlated equilibria. + International Journal of Game Theory 32(4): 443-453 +" { { "" 0, 0, 2 } diff --git a/contrib/games/loopback.nfg b/contrib/games/loopback.nfg index 245276abf..81640d6c9 100644 --- a/contrib/games/loopback.nfg +++ b/contrib/games/loopback.nfg @@ -3,7 +3,9 @@ NFG 1 R "Backward-bending principal logit branch" { "Player 1" "Player 2" } { { "1" "2" } { "1" "2" } } -"This game has a backwards bend in the principal branch of the logit quantal response equilibrium correspondence." +"This game has a backwards bend in the principal branch of the logit quantal response equilibrium correspondence. +This is based on an example originally found by Richard McKelvey. +" { { "11" 6, 7 } From 76b4360e6494739fea46c6c74cf0b12d04b8564e Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Sun, 15 Mar 2026 18:07:17 +0000 Subject: [PATCH 5/8] Provide citation details and explanations for examples from Spence textbook. --- catalog/watson2013/exercise29_6.efg | 37 +++++++++++++++++++ .../watson2013/fig29_1.efg | 7 +++- contrib/games/pbride.efg | 18 --------- doc/samples.rst | 12 ------ 4 files changed, 43 insertions(+), 31 deletions(-) create mode 100644 catalog/watson2013/exercise29_6.efg rename contrib/games/spence.efg => catalog/watson2013/fig29_1.efg (65%) delete mode 100644 contrib/games/pbride.efg diff --git a/catalog/watson2013/exercise29_6.efg b/catalog/watson2013/exercise29_6.efg new file mode 100644 index 000000000..8ca0f7a3d --- /dev/null +++ b/catalog/watson2013/exercise29_6.efg @@ -0,0 +1,37 @@ +EFG 2 R "Princess Bride signaling game (from Watson)" { "Wesley" "Prince" } +"This game is Exercise 29.6 from Watson [^Wat13], based on a scene from +the Rob Reiner film, _The Princess Bride_: + +Wesley (the protagonist) confronts the evil prince Humperdinck. Wesley +is one of two types: weak or strong. Wesley knows whether he is weak or +strong, but the prince only knows that he is weak with probability 1/2 and +strong with probability 1/2. Wesley is lying in a bed in the prince's +castle when the prince enters the room. Wesley decides whether to get out +of bed or stay in bed. The prince observes Wesley's action but does not +observe Wesley's type. The prince then decides whether to fight or +surrender to Wesley. The payoffs are such that the prince prefers to fight +only with the weak Wesley, because otherwise the prince is an inferior +swordsman. Also, the weak Wesley must pay a cost to get out of bed. + +In the game in this file, the cost the weak Wesley pays to get out of bed +is set to 2. + +[^Wat13]: Watson, Joel. (2013) Strategy: An Introduction to Game Theory, + third edition. W. W. Norton & Company. +" + +c "" 1 "" { "Strong" 1/2 "Weak" 1/2 } 0 +p "" 1 1 "" { "Up" "Stay" } 0 +p "" 2 1 "" { "Surrender" "Fight" } 0 +t "" 1 "Outcome1" { 1, 0 } +t "" 2 "Outcome2" { 0, -2 } +p "" 2 2 "" { "Surrender" "Fight" } 0 +t "" 3 "Outcome3" { 1, 0 } +t "" 4 "Outcome4" { 0, -2 } +p "" 1 2 "" { "Up" "Stay" } 0 +p "" 2 1 "" { "Surrender" "Fight" } 0 +t "" 5 "Outcome5" { -1, 0 } +t "" 6 "Outcome6" { -3, 1 } +p "" 2 2 "" { "Surrender" "Fight" } 0 +t "" 7 "Outcome7" { 1, 0 } +t "" 8 "Outcome8" { -1, 1 } diff --git a/contrib/games/spence.efg b/catalog/watson2013/fig29_1.efg similarity index 65% rename from contrib/games/spence.efg rename to catalog/watson2013/fig29_1.efg index b37fb9b28..1ec266fa2 100644 --- a/contrib/games/spence.efg +++ b/catalog/watson2013/fig29_1.efg @@ -1,5 +1,10 @@ EFG 2 R "Job-market signaling game (version from Watson)" { "You" "Firm" } -"" +"This is a version of Spence's classic model of education being a job-market +signal, as presented in Figure 29.1 of Watson [^Wat13]. + +[^Wat13]: Watson, Joel. (2013) Strategy: An Introduction to Game Theory, + third edition. W. W. Norton & Company. +" c "" 1 "" { "High" 1/3 "Low" 2/3 } 0 p "" 1 1 "" { "E" "N" } 0 diff --git a/contrib/games/pbride.efg b/contrib/games/pbride.efg deleted file mode 100644 index 209a53de0..000000000 --- a/contrib/games/pbride.efg +++ /dev/null @@ -1,18 +0,0 @@ -EFG 2 R "Princess Bride signaling game (from Watson)" { "Wesley" "Prince" } -"" - -c "" 1 "" { "Strong" 1/2 "Weak" 1/2 } 0 -p "" 1 1 "" { "Up" "Stay" } 0 -p "" 2 1 "" { "Surrender" "Fight" } 0 -t "" 1 "Outcome1" { 1, 0 } -t "" 2 "Outcome2" { 0, -2 } -p "" 2 2 "" { "Surrender" "Fight" } 0 -t "" 3 "Outcome3" { 1, 0 } -t "" 4 "Outcome4" { 0, -2 } -p "" 1 2 "" { "Up" "Stay" } 0 -p "" 2 1 "" { "Surrender" "Fight" } 0 -t "" 5 "Outcome5" { -1, 0 } -t "" 6 "Outcome6" { -3, 1 } -p "" 2 2 "" { "Surrender" "Fight" } 0 -t "" 7 "Outcome7" { 1, 0 } -t "" 8 "Outcome8" { -1, 1 } diff --git a/doc/samples.rst b/doc/samples.rst index c3f669c17..a72fbd578 100644 --- a/doc/samples.rst +++ b/doc/samples.rst @@ -46,13 +46,6 @@ Sample games games. Games and Economic Behavior 79: 223-232. `_ -:download:`pbride.efg <../contrib/games/pbride.efg>` - A signaling game from - `Joel Watson's Strategy textbook - `_, - modeling the confrontation in The Princess Bride between Humperdinck - and Roberts in the bedchamber. - :download:`poker.efg <../contrib/games/poker.efg>` A simple game of one-card poker introduced in `Myerson, Roger (1991) Game Theory: Analysis of Conflict. @@ -60,8 +53,3 @@ Sample games A bit unusually for poker, the "fold" action by a player with a strong hand counts for a win for that player, so folding is only weakly rather than strictly dominated in this case. - -:download:`spence.efg <../contrib/games/spence.efg>` - A version of Spence's classic job-market signaling game. This version - comes from `Joel Watson's Strategy textbook - `_. From fe09d1ecb06f1093637e2d749d2374d6382ed00f Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Mon, 16 Mar 2026 12:24:46 +0000 Subject: [PATCH 6/8] Move Myerson poker into catalog; add Reiley et al stripped-down poker. --- catalog/myerson1991/fig2_1.efg | 30 ++++++++++++++++++++++++++++++ catalog/reiley2008/fig1.efg | 24 ++++++++++++++++++++++++ contrib/games/poker.efg | 14 -------------- contrib/games/poker.nfg | 18 ------------------ contrib/games/poker2.efg | 14 -------------- doc/samples.rst | 13 ------------- 6 files changed, 54 insertions(+), 59 deletions(-) create mode 100644 catalog/myerson1991/fig2_1.efg create mode 100644 catalog/reiley2008/fig1.efg delete mode 100644 contrib/games/poker.efg delete mode 100644 contrib/games/poker.nfg delete mode 100644 contrib/games/poker2.efg diff --git a/catalog/myerson1991/fig2_1.efg b/catalog/myerson1991/fig2_1.efg new file mode 100644 index 000000000..a95745147 --- /dev/null +++ b/catalog/myerson1991/fig2_1.efg @@ -0,0 +1,30 @@ +EFG 2 R "A simple Poker game" { "Fred" "Alice" } +"This is a simple game of one-card poker from Myerson [^Mye91], used as the +introductory example for game models. + +Note that as specified in the text, the game has the slightly unusual feature +that folding with the high (red) card results in the player winning rather than +losing. + +See also +-------- +reiley2008/fig1 + Another one-card poker game where folding with the high card is a loss rather + than a win. + + +[^Mye1991]: Myerson, Roger B. (1991) Game Theory: Analysis of Conflict. + Cambridge: Harvard University Press. +" + +c "" 1 "" { "Red" 1/2 "Black" 1/2 } 0 +p "" 1 1 "" { "Raise" "Fold" } 0 +p "" 2 1 "" { "Meet" "Pass" } 0 +t "" 1 "Win Big" { 2, -2 } +t "" 2 "Win" { 1, -1 } +t "" 2 "Win" { 1, -1 } +p "" 1 2 "" { "Raise" "Fold" } 0 +p "" 2 1 "" { "Meet" "Pass" } 0 +t "" 3 "Lose Big" { -2, 2 } +t "" 2 "Win" { 1, -1 } +t "" 4 "Lose" { -1, 1 } diff --git a/catalog/reiley2008/fig1.efg b/catalog/reiley2008/fig1.efg new file mode 100644 index 000000000..cb3e698a6 --- /dev/null +++ b/catalog/reiley2008/fig1.efg @@ -0,0 +1,24 @@ +EFG 2 R "Stripped-down poker (Reiley et al 2008)" { "Professor" "Student" } +"This is a one-card poker game used in [^Rei2008] as a teaching exercise. + +See also +-------- +myerson1991/fig2_1 + Another one-card poker game with slightly different rules. + +[^Rei2008]: Reiley, David H., Urbancic, Michael B, and Walker, Mark. (2008) + Stripped-Down Poker: A Classroom Game with Signaling and Bluffing. + _The Journal of Economic Education_ 4: 323-341. +" + +c "" 1 "" { "King" 1/2 "Queen" 1/2 } 0 +p "" 1 1 "" { "Bet" "Fold" } 0 +p "" 2 1 "" { "Call" "Fold" } 0 +t "" 1 "Professor Wins Big" { 2, -2 } +t "" 2 "Professor Wins" { 1, -1 } +t "" 4 "Professor Loses" { 1, -1 } +p "" 1 2 "" { "Bet" "Fold" } 0 +p "" 2 1 "" { "Call" "Fold" } 0 +t "" 3 "Professor Loses Big" { -2, 2 } +t "" 2 "Professor Wins" { 1, -1 } +t "" 4 "Professor Loses" { -1, 1 } diff --git a/contrib/games/poker.efg b/contrib/games/poker.efg deleted file mode 100644 index b55de5be1..000000000 --- a/contrib/games/poker.efg +++ /dev/null @@ -1,14 +0,0 @@ -EFG 2 R "A simple Poker game" { "Fred" "Alice" } -"This is a simple game of one-card poker from Myerson (1991)." - -c "" 1 "" { "Red" 1/2 "Black" 1/2 } 0 -p "" 1 1 "" { "Raise" "Fold" } 0 -p "" 2 1 "" { "Meet" "Pass" } 0 -t "" 1 "Win Big" { 2, -2 } -t "" 2 "Win" { 1, -1 } -t "" 2 "Win" { 1, -1 } -p "" 1 2 "" { "Raise" "Fold" } 0 -p "" 2 1 "" { "Meet" "Pass" } 0 -t "" 3 "Lose Big" { -2, 2 } -t "" 2 "Win" { 1, -1 } -t "" 4 "Lose" { -1, 1 } diff --git a/contrib/games/poker.nfg b/contrib/games/poker.nfg deleted file mode 100644 index 2c9f498fe..000000000 --- a/contrib/games/poker.nfg +++ /dev/null @@ -1,18 +0,0 @@ -NFG 1 R "A simple two person poker game in normal form" { "Player 1" "Player 2" } - -{ { "1" "2" "3" "4" } -{ "1" "2" } -} -"" - -{ -{ "" -1, 1 } -{ "" -0.5, 0.5 } -{ "" -0.5, 0.5 } -{ "" 0, 0 } -{ "" -1, 1 } -{ "" 0.5, -0.5 } -{ "" -2.5, 2.5 } -{ "" -1, 1 } -} -1 2 3 4 5 6 7 8 diff --git a/contrib/games/poker2.efg b/contrib/games/poker2.efg deleted file mode 100644 index 8d01ca636..000000000 --- a/contrib/games/poker2.efg +++ /dev/null @@ -1,14 +0,0 @@ -EFG 2 R "A Simple Poker Game with an initial ante" { "Player 1" "Player 2" } -"" - -c "" 1 "(0,1)" { "RED" 0.500000 "BLACK" 0.500000 } 1 "Outcome 3" { -1, 1 } -p "" 1 1 "(1,1)" { "RAISE" "FOLD" } 0 -p "" 2 1 "(2,1)" { "MEET" "PASS" } 0 -t "" 2 "Outcome 2" { 2, -2 } -t "" 3 "Outcome 1" { 1, -1 } -t "" 1 "Outcome 3" { -1, 1 } -p "" 1 2 "(1,2)" { "RAISE" "FOLD" } 0 -p "" 2 1 "(2,1)" { "MEET" "PASS" } 0 -t "" 4 "Outcome 4" { -2, 2 } -t "" 3 "Outcome 1" { 1, -1 } -t "" 1 "Outcome 3" { -1, 1 } diff --git a/doc/samples.rst b/doc/samples.rst index a72fbd578..42696d738 100644 --- a/doc/samples.rst +++ b/doc/samples.rst @@ -26,11 +26,6 @@ Sample games under strategic voting. American Political Science Review 92(1): 23-35. `_. -:download:`loopback.nfg <../contrib/games/loopback.nfg>` - A game due to McKelvey which illustrates that the logit quantal - response equilibrium correspondence can have a "backward-bending" - segment on the principal branch. - :download:`nim.efg <../contrib/games/nim.efg>` This is a Nim-like game, which is a useful example of the value of backward induction. @@ -45,11 +40,3 @@ Sample games learning: Heuristics and response time in perfect information games. Games and Economic Behavior 79: 223-232. `_ - -:download:`poker.efg <../contrib/games/poker.efg>` - A simple game of one-card poker introduced in - `Myerson, Roger (1991) Game Theory: Analysis of Conflict. - `_. - A bit unusually for poker, the "fold" action by a player with a - strong hand counts for a win for that player, so folding is only - weakly rather than strictly dominated in this case. From 3d64e03ea75eff7e04c907362f0a04a2e0b5c370 Mon Sep 17 00:00:00 2001 From: Theodore Turocy Date: Mon, 16 Mar 2026 12:47:31 +0000 Subject: [PATCH 7/8] Remove samples page - all have either been migrated to catalog, or issues raised (as appropriate) for further action in curating all of the examples from those sources --- doc/contents.rst | 1 - doc/index.rst | 1 - doc/samples.rst | 42 ------------------------------------------ 3 files changed, 44 deletions(-) delete mode 100644 doc/samples.rst diff --git a/doc/contents.rst b/doc/contents.rst index 4b49795cc..bc97c5f8e 100644 --- a/doc/contents.rst +++ b/doc/contents.rst @@ -10,7 +10,6 @@ Detailed table of contents pygambit tools gui - samples developer formats biblio diff --git a/doc/index.rst b/doc/index.rst index 65ed31ed4..c76eddd13 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -88,7 +88,6 @@ construction and analysis of finite extensive and strategic games. tools gui catalog - samples developer formats biblio diff --git a/doc/samples.rst b/doc/samples.rst deleted file mode 100644 index 42696d738..000000000 --- a/doc/samples.rst +++ /dev/null @@ -1,42 +0,0 @@ -Sample games -~~~~~~~~~~~~ - -:download:`2x2x2-nau.nfg <../contrib/games/2x2x2-nau.nfg>` - A three-player normal form game with two strategies per player. - This game has three pure strategy equilibria, two - equilibria which are incompletely mixed, and a continuum of - completely mixed equilibria. This game appears as an example in - `Nau, Robert, Gomez Canovas, Sabrina, and Hansen, Pierre (2004). - On the geometry of Nash equilibria and correlated equilibria. - International Journal of Game Theory 32(4): 443-453. - `_ - -:download:`cent3.efg <../contrib/games/cent3.efg>` - A three-stage centipede game, featuring an exogenous probability - that one player is an altruistic type, who always passes. - See, for example, - `McKelvey, Richard D. and Palfrey, Thomas R. (1992) An - experimental study of the centipede game. Econometrica 60(4): - 803-836. `_ - -:download:`condjury.efg <../contrib/games/condjury.efg>` - A three-person Condorcet jury game, after the analysis of - `Feddersen, Timothy and Pesendorfer, Wolfgang (1998) - Convicting the innocent: The inferiority of unanimous jury verdicts - under strategic voting. American Political Science Review 92(1): - 23-35. `_. - -:download:`nim.efg <../contrib/games/nim.efg>` - This is a Nim-like game, which is a useful example of the value - of backward induction. - This version starts with one pile of five stones, and allows the - two players to alternately take 1 or 2 stones. - The player to take the last stone wins. - The classic game of - `Nim `_ allows multiple piles, - and allows a player to remove any number of stones from a pile. - An interesting experimental study of Nim games is - `McKinney, C. Nicholas and Van Huyck, John B. (2013) Eureka - learning: Heuristics and response time in perfect information - games. Games and Economic Behavior 79: - 223-232. `_ From 82446c48f40e02149b82e126ba3606e2bbd11171 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 19 Mar 2026 11:56:16 +0000 Subject: [PATCH 8/8] Fix dev samples (#814) * initial test refactor * deduplicate game slugs * Update error handling in test_catalog_load_all_game_slugs * load 2smp game from contrib instead of catalog * Update Makefile.am * fix reiley game * correct ext --- Makefile.am | 12 +++--- catalog/reiley2008/fig1.efg | 2 +- doc/tutorials/04_creating_images.ipynb | 2 +- tests/test_catalog.py | 53 +++++++++++++++++--------- 4 files changed, 43 insertions(+), 26 deletions(-) diff --git a/Makefile.am b/Makefile.am index 84434fe9a..85fa72068 100644 --- a/Makefile.am +++ b/Makefile.am @@ -171,8 +171,6 @@ EXTRA_DIST = \ contrib/games/palf2.efg \ contrib/games/palf3.efg \ contrib/games/palf.efg \ - contrib/games/poker2.efg \ - contrib/games/poker.efg \ contrib/games/pvw2.efg \ contrib/games/pvw.efg \ contrib/games/sh3.efg \ @@ -188,6 +186,7 @@ EXTRA_DIST = \ contrib/games/work1.efg \ contrib/games/work2.efg \ contrib/games/work3.efg \ + contrib/games/2smp.efg \ contrib/games/2x2a.nfg \ contrib/games/2x2const.nfg \ contrib/games/2x2.nfg \ @@ -222,7 +221,6 @@ EXTRA_DIST = \ contrib/games/perfect1.nfg \ contrib/games/perfect2.nfg \ contrib/games/perfect3.nfg \ - contrib/games/poker.nfg \ contrib/games/sh3.nfg \ contrib/games/stengel.nfg \ contrib/games/sww1.nfg \ @@ -235,11 +233,15 @@ EXTRA_DIST = \ contrib/games/yamamoto.nfg \ contrib/games/zero.nfg \ src/README.rst \ - catalog/2smp.efg \ + catalog/bagwell1995.efg \ + catalog/myerson1991/fig2_1.efg \ catalog/myerson1991/fig4_2.efg \ + catalog/reiley2008/fig1.efg \ catalog/selten1975/fig1.efg \ catalog/selten1975/fig2.efg \ - catalog/selten1975/fig3.efg + catalog/selten1975/fig3.efg \ + catalog/watson2013/exercise29_6.efg \ + catalog/watson2013/fig29_1.efg core_SOURCES = \ src/core/core.h \ diff --git a/catalog/reiley2008/fig1.efg b/catalog/reiley2008/fig1.efg index cb3e698a6..9083ff0f6 100644 --- a/catalog/reiley2008/fig1.efg +++ b/catalog/reiley2008/fig1.efg @@ -16,7 +16,7 @@ p "" 1 1 "" { "Bet" "Fold" } 0 p "" 2 1 "" { "Call" "Fold" } 0 t "" 1 "Professor Wins Big" { 2, -2 } t "" 2 "Professor Wins" { 1, -1 } -t "" 4 "Professor Loses" { 1, -1 } +t "" 4 "Professor Loses" { -1, 1 } p "" 1 2 "" { "Bet" "Fold" } 0 p "" 2 1 "" { "Call" "Fold" } 0 t "" 3 "Professor Loses Big" { -2, 2 } diff --git a/doc/tutorials/04_creating_images.ipynb b/doc/tutorials/04_creating_images.ipynb index bd6e7e106..ec15e8f76 100644 --- a/doc/tutorials/04_creating_images.ipynb +++ b/doc/tutorials/04_creating_images.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "g = gbt.catalog.load(\"2smp\")" + "g = gbt.read_efg(\"../../contrib/games/2smp.efg\")" ] }, { diff --git a/tests/test_catalog.py b/tests/test_catalog.py index be4903a20..c010c2a51 100644 --- a/tests/test_catalog.py +++ b/tests/test_catalog.py @@ -4,31 +4,46 @@ import pygambit as gbt -def test_catalog_load_efg(): - """Test loading an extensive form game""" - g = gbt.catalog.load("selten1975/fig1") - assert isinstance(g, gbt.Game) - assert g.title == "Selten's horse (Selten IJGT 1975, Figure 1)" - - -# TODO: Reintroduce this test once we have a .nfg game in the catalog -# def test_catalog_load_nfg(): -# """Test loading a normal form game""" -# g = gbt.catalog.load("pd") -# assert isinstance(g, gbt.Game) -# assert g.title == "Two person Prisoner's Dilemma game" +@pytest.fixture +def game_slugs(): + """Fixture providing a set of all game slugs in the catalog.""" + game_slugs = set() + for resource_path in gbt.catalog._CATALOG_RESOURCE.rglob("*"): + if resource_path.is_file() and resource_path.suffix in gbt.catalog.READERS: + rel_path = resource_path.relative_to(gbt.catalog._CATALOG_RESOURCE) + slug = rel_path.with_suffix("").as_posix() + game_slugs.add(slug) + return game_slugs + + +def test_catalog_load_all_game_slugs(game_slugs): + """Test loading all valid game files in the catalog.""" + errors = [] + for slug in game_slugs: + try: + g = gbt.catalog.load(slug) + assert isinstance(g, gbt.Game), f"Expected gbt.Game, got {type(g)}" + except Exception as e: + errors.append(f"Slug '{slug}' failed with {type(e).__name__}: {e}") + + if errors: + pytest.fail(f"Errors loading {len(errors)} game(s):\n" + "\n".join(errors)) def test_catalog_load_invalid_slug(): - """Test loading an invalid game slug""" + """Test loading an invalid game slug.""" with pytest.raises(FileNotFoundError): gbt.catalog.load("invalid_slug") -def test_catalog_games(): - """Test games() function returns df of game slugs and titles""" +def test_catalog_games(game_slugs): + """Test games() function returns df of game slugs and titles.""" all_games = gbt.catalog.games() assert isinstance(all_games, pd.DataFrame) - assert len(all_games) > 0 - assert "myerson1991/fig4_2" in list(all_games.Game) - assert "Myerson (1991) Figure 4.2" in list(all_games.Title) + + # The games() function should return exactly the set of slugs found above + assert set(all_games["Game"]) == game_slugs + + # Test that standard columns are present + assert "Game" in all_games.columns + assert "Title" in all_games.columns