Skip to content

Commit 55c3ecd

Browse files
authored
Require labels for game objects (#725)
This moves toward requiring unique, nontrivial labels for many game objects, as envisioned in issue #614. In addition, this adds a number of robustness checks for .efg files. Principally, this enforces that if information is repeated (information set or outcome details), these much match *exactly* the original definition. Documentation of the format has been updated to clarify this and a few other points.
1 parent b5ab74f commit 55c3ecd

15 files changed

Lines changed: 326 additions & 94 deletions

File tree

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
to detect if an information is absent-minded.
88

99
### Changed
10+
- Labels for players, outcomes, strategies, and actions are expected to be non-empty and unique within
11+
the relevant scope (games for players and outcomes, players for strategies, and information sets for
12+
actions). `pygambit` now issues a `FutureWarning` if a label is changed that does not conform to these
13+
expectations. There is now an optional flag `normalize_labels` to `read_*` which will automatically
14+
fill in non-confirming sets of labels. In version 16.6 these will be enforced; invalid label sets will
15+
generate an error and files will be normalized automatically on read. (#614)
1016
- Terminology for agent-form calculations on extensive games has been clarified. Mixed behavior profiles
1117
distinguish "agent" regret and liap values from their strategy-based analogs. Methods which compute
1218
using the agent-form - specifically `enumpure_solve` and `liap_solve`, now clarify this by being named

doc/formats.efg.rst

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@ The extensive game (.efg) file format
66
The extensive game (.efg) file format has been used by Gambit, with
77
minor variations, to represent extensive games since circa 1994. It
88
replaced an earlier format, which had no particular name but which had
9-
the conventional extension .dt1. It is intended that some new formats
10-
will be introduced in the future; however, this format will be
11-
supported by Gambit, possibly through the use of converter programs to
12-
those putative future formats, for the foreseeable future.
9+
the conventional extension .dt1.
1310

1411

1512
A sample file
1613
-------------
1714

18-
This is a sample file illustrating the general format of the file.
19-
This file is similar to the one distributed in the Gambit distribution
20-
under the name bayes1a.efg::
15+
This is a sample file illustrating the general format of the file::
2116

2217
EFG 2 R "General Bayes game, one stage" { "Player 1" "Player 2" }
2318
c "ROOT" 1 "(0,1)" { "1G" 0.500000 "1B" 0.500000 } 0
@@ -53,8 +48,6 @@ under the name bayes1a.efg::
5348
t "" 16 "Outcome 16" { 10.000000 0.000000 }
5449

5550

56-
57-
5851
Structure of the prologue
5952
-------------------------
6053

@@ -97,11 +90,9 @@ of one line per node.
9790
Each node entry begins with an unquoted character indicating the type
9891
of the node. There are three node types:
9992

100-
101-
102-
+ c for a chance node
103-
+ p for a personal player node
104-
+ t for a terminal node
93+
+ `c` for a chance node
94+
+ `p` for a personal player node
95+
+ `t` for a terminal node
10596

10697
Each node type will be discussed individually below. There are three
10798
numbering conventions which are used to identify the information
@@ -116,19 +107,21 @@ integer may be used to specify information sets for different players;
116107
this is not ambiguous since the player number appears as well.
117108
Finally, outcomes are also arbitrarily numbered in the file format in
118109
the same way in which information sets are, except for the special
119-
number 0 which indicates the null outcome.
110+
number 0 which is reserved to indicate the null outcome.
111+
Outcome 0 must not have a name or payoffs specified.
120112

121113
Information sets and outcomes may (and frequently will) appear
122114
multiple times within a game. By convention, the second and subsequent
123115
times an information set or outcome appears, the file may omit the
124116
descriptive information for that information set or outcome.
125117
Alternatively, the file may specify the descriptive information again;
126118
however, it must precisely match the original declaration of the
127-
information set or outcome. If any part of the description is omitted,
128-
the whole description must be omitted.
119+
information set or outcome. Any mismatch in repeated declarations
120+
is an error, and the file is not valid.
121+
If any part of the description is omitted, the whole description must be omitted.
129122

130123
Outcomes may appear at nonterminal nodes. In these cases, payoffs are
131-
interepreted as incremental payoffs; the payoff to a player for a
124+
interpreted as incremental payoffs; the payoff to a player for a
132125
given path through the tree is interpreted as the sum of the payoffs
133126
at the outcomes encountered on that path (including at the terminal
134127
node). This is ideal for the representation of games with well-
@@ -146,41 +139,28 @@ with the character c . Following this, in order, are
146139

147140
+ a text string, giving the name of the node
148141
+ a positive integer specifying the information set number
149-
+ (optional) the name of the information set
150-
+ (optional) a list of actions at the information set with their
142+
+ (optional) the name of the information set and a list of actions at the information set with their
151143
corresponding probabilities
152144
+ a nonnegative integer specifying the outcome
153-
+ (optional)the payoffs to each player for the outcome
154-
155-
145+
+ (optional) the name of the outcome and the payoffs to each player for the outcome
156146

157147
**Format of personal (player) nodes.** Entries for personal player
158148
decision nodes begin with the character p . Following this, in order,
159149
are:
160150

161-
162-
163151
+ a text string, giving the name of the node
164152
+ a positive integer specifying the player who owns the node
165153
+ a positive integer specifying the information set
166-
+ (optional) the name of the information set
167-
+ (optional) a list of action names for the information set
154+
+ (optional) the name of the information set and a list of action names for the information set
168155
+ a nonnegative integer specifying the outcome
169-
+ (optional) the name of the outcome
170-
+ the payoffs to each player for the outcome
171-
156+
+ (optional) the name of the outcome and the payoffs to each player for the outcome
172157

173158

174159
**Format of terminal nodes.** Entries for terminal nodes begin with
175160
the character t . Following this, in order, are:
176161

177-
178-
179162
+ a text string, giving the name of the node
180163
+ a nonnegative integer specifying the outcome
181-
+ (optional) the name of the outcome
182-
+ the payoffs to each player for the outcome
183-
184-
164+
+ (optional) the name of the outcome and the payoffs to each player for the outcome
185165

186166
There is no explicit end-of-file delimiter for the file.

0 commit comments

Comments
 (0)