Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions tests/test_games/label-collision.efg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
EFG 2 R "label collision counterexample" { "Player 1" }
"Two 11-action information sets for one player: reduced strategies (1,11) and (11,1) both render label 111"

p "" 1 1 "" { "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" } 0
p "" 1 2 "" { "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" } 0
t "" 1 "" { 1 }
t "" 2 "" { 2 }
t "" 3 "" { 3 }
t "" 4 "" { 4 }
t "" 5 "" { 5 }
t "" 6 "" { 6 }
t "" 7 "" { 7 }
t "" 8 "" { 8 }
t "" 9 "" { 9 }
t "" 10 "" { 10 }
t "" 11 "" { 11 }
t "" 12 "" { 12 }
t "" 13 "" { 13 }
t "" 14 "" { 14 }
t "" 15 "" { 15 }
t "" 16 "" { 16 }
t "" 17 "" { 17 }
t "" 18 "" { 18 }
t "" 19 "" { 19 }
t "" 20 "" { 20 }
p "" 1 2 "" { "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" } 0
t "" 21 "" { 21 }
t "" 22 "" { 22 }
t "" 23 "" { 23 }
t "" 24 "" { 24 }
t "" 25 "" { 25 }
t "" 26 "" { 26 }
t "" 27 "" { 27 }
t "" 28 "" { 28 }
t "" 29 "" { 29 }
t "" 30 "" { 30 }
t "" 31 "" { 31 }
32 changes: 32 additions & 0 deletions tests/test_strategic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import io

import pytest

import pygambit as gbt
Expand Down Expand Up @@ -73,3 +75,33 @@ def test_game_get_min_payoff():
def test_game_get_max_payoff():
game = games.read_from_file("mixed_strategy.nfg")
assert game.max_payoff == 3


@pytest.mark.xfail(
reason="Generated reduced-strategy labels are not injective",
raises=AssertionError, strict=True,
)
def test_generated_strategy_labels_are_unique():
"""#981 established that a strategy label must be nonempty, valid, and
unique among a player's strategies. Labels generated for reduced
strategies bypass the check: two 11-action information sets yield
strategies (1, 11) and (11, 1), both rendering as "111"."""
g = games.read_from_file("label-collision.efg")
labels = [s.label for s in g.players["Player 1"].strategies]
dups = sorted({lab for lab in labels if labels.count(lab) > 1})
assert len(set(labels)) == len(labels), f"duplicate generated labels: {dups}"


@pytest.mark.xfail(
reason="Generated reduced-strategy labels are not injective; "
"duplicate labels break NFG re-read",
raises=ValueError, strict=True,
)
def test_game_with_duplicate_generated_labels_roundtrips_through_nfg():
"""WriteNfgFile serialises the duplicate generated labels;
ReadNfgFile then rejects its own output. FAILS on 16.7.0.

The game has two 11-action information sets for one player (imperfect
recall); reduced strategies (1, 11) and (11, 1) both render as "111"."""
g = games.read_from_file("label-collision.efg")
gbt.read_nfg(io.StringIO(g.to_nfg()))
Loading