SPEC-028: OpenSpiel games¶
- Status: Implemented
- Milestone: v0.17 "Game library"
- Owners: lead maintainer
1. Purpose¶
Writing a good world takes time, and most classic games have already been written, tested and studied. OpenSpiel has more than 120 of them: board games, poker, dice and card games, games with hidden information, chance, simultaneous moves, more than two players and cooperation. This spec makes any OpenSpiel game an AgentPlay world, so models can play them, people can play them (SPEC-027), and every tool that already exists works on them: tournaments, ratings, experiments, benchmarks and behaviour metrics.
Players see exactly what OpenSpiel says that player may see, and nothing more. A short list of
featured games also gets written rules and readable observations, because some of OpenSpiel's
own text is too terse for a model (Kuhn poker shows a player 011).
2. Terms¶
- OpenSpiel: Google DeepMind's library of games, the
open_spielpackage, imported aspyspiel. - Game name: an OpenSpiel registered game name, such as
kuhn_pokerorconnect_four. - Featured game: a game AgentPlay ships rules and a readable observation for (OSP-009).
- Chance node: a point in an OpenSpiel game where chance acts, such as a deal or a dice roll.
Keywords MUST, SHOULD and MAY follow RFC 2119.
3. Requirements¶
Using a game¶
- OSP-001 AgentPlay MUST include a built-in world
openspielwith configgame(a game name) and optionalparams(a map passed to OpenSpiel'sload_game, such as{players: 3}).use: openspiel/<game>MUST mean the same asuse: openspielwithconfig: {game: <game>}. - OSP-002 OpenSpiel MUST be an optional extra,
pip install "agentplaykit[openspiel]". Without it, using the world MUST stop before the run withconfig.missing_extra, naming the extra. Everything else in AgentPlay MUST keep working without it, on Python 3.8. - OSP-003 An unknown game name MUST be a
config.invaliderror with a "did you mean" hint from OpenSpiel's registered games. A parameter OpenSpiel rejects MUST be aconfig.invaliderror with OpenSpiel's message. Both MUST be reported byagentplaykit checkwithout running the game. - OSP-004 A game that AgentPlay cannot play MUST be refused with
config.invalidand the reason: mean-field games, games that give players neither an observation string nor an information-state string, and games with more players than agents in the scenario.
Players and turns¶
- OSP-005 The world's agent IDs MUST be the scenario's agent IDs in order: the first agent
is OpenSpiel player 0. A scenario with a different number of agents than the game's players
MUST be refused with
config.invalid, naming both numbers and theparamsthat change the number of players when the game has one. - OSP-006 Sequential games MUST give
to_act()the current player. Simultaneous games and simultaneous nodes MUST give every player with a legal move, and apply the moves together (ENV-006). - OSP-007 Chance nodes MUST be resolved by the world itself, before the next player's turn, by sampling OpenSpiel's chance outcomes with a random generator seeded from the run's seed. The same seed and the same moves MUST give the same game (ENV-002), on every platform.
What a player sees¶
- OSP-008 A player's observation MUST hold only what OpenSpiel gives that player:
viewis OpenSpiel's observation string for that player when the game provides one, and its information-state string otherwise. It MUST NOT include the full state string or another player's private information. The observation also holdsyou_are(the player number and agent ID),game(the game's name) andmoves_leftwhen the game has a maximum length. - OSP-009 Featured games MUST have written rules for agents, a readable observation with
named fields instead of (or as well as)
view, and a fitting grid view (VWR-012) where the game has a board. The featured games are:connect_four,kuhn_poker,leduc_poker,liars_dice,goofspiel,battleship,hanabiandmatrix_pd. - OSP-010 For other games,
describe()["rules"]MUST be built from OpenSpiel's game type: the game's long name, the number of players, whether moves are sequential or simultaneous, whether there is chance and hidden information, and that the legal moves are listed every turn. It MUST say that the game has no written rules in AgentPlay. - OSP-011 The legal moves MUST be OpenSpiel's action strings for that player
(
action_to_string), such asBet,x3or2-5. When two legal moves have the same string, both MUST be shown as<action id>: <string>. A move MUST be read with the same lenient reading as other worlds (SPEC-025 REL-006). - OSP-012 The world MUST declare a text view in
describe()(view: {type: "text", key: "view"}) when the observation has aviewstring, so the viewer and the human agent show it as preformatted text, not as JSON.
Results¶
- OSP-013 When the game ends,
outcome()MUST give each agent its OpenSpiel return as its score, and aswinnersthe agents with the highest return, or none when all returns are equal (a draw, or a cooperative game). Intermediate rewards MUST be passed on as steprewards. The outcome MAY reveal hidden information once the game is over, such as the cards dealt. - OSP-014
describe()MUST includename(openspiel/<game>, followed by the params the scenario sets in OpenSpiel's own notation, such asopenspiel/goofspiel(num_cards=6)),version(the AgentPlay adapter version and the OpenSpiel version),params(all of them, defaults included), andutility(zero_sum,constant_sum,general_sumoridentical). Reports MUST treat each game and set of params as its own world, so ratings never mixgoofspielwith 6 and with 13 cards. - OSP-015 A game with no limit of its own MUST still end at
limits.max_steps; worlds with a maximum length SHOULD say so in the rules.
Tools¶
- OSP-016
agentplaykit env listMUST listopenspielwhen the extra is installed, andagentplaykit env list openspielMUST list every game OpenSpiel offers, marking featured games and games AgentPlay cannot play (OSP-004). - OSP-017 The world MUST pass the world conformance kit (
agentplaykit test, SPEC-001) for every featured game, and for every other game OpenSpiel registers that AgentPlay can play, with random legal play from a few seeds. - OSP-018
examples/openspiel/MUST include at least: Kuhn poker between two models, and Liar's Dice for a person against a model (SPEC-027).
Docs¶
- OSP-019 A "Game library" guide MUST show how to install the extra, play a featured game, play any other game with params, and what a player sees; it MUST list the featured games with a line on what each one tests (bluffing, memory, cooperation, ...).
4. Acceptance criteria¶
| Requirement | Test ID | Notes |
|---|---|---|
| OSP-001..004 | OSP-001..OSP-004 |
shorthand name, missing extra (simulated import failure), unknown game with hint, bad params, refused game types; check without running |
| OSP-005..007 | OSP-005..OSP-007 |
agent order and count, sequential and simultaneous turns, the same seed gives the same deal |
| OSP-008..012 | OSP-008..OSP-012 |
a poker player never sees the other card; featured observations and rules; generated rules; duplicate action strings; text view |
| OSP-013..015 | OSP-013..OSP-015 |
returns as scores, winners and draws, identical utility, worlds kept apart by params |
| OSP-016..018 | OSP-016..OSP-018 |
env list, the conformance kit over every playable game, examples run |
| OSP-019 | OSP-019 |
the guide's sections |
Tests that need OpenSpiel MUST run in CI in a job with the extra installed; without it they are skipped, as the Hugging Face tests are.
5. Examples¶
agentplay: 1
name: kuhn-poker
seed: 1
world: {use: openspiel/kuhn_poker}
agents:
- {id: alice, use: ollama, config: {model: "qwen2.5:7b"}}
- {id: bob, use: scripted/random}
world: {use: openspiel, config: {game: goofspiel, params: {num_cards: 6}}}
liars_dice: you are bob (player 1).
your dice: 4
bids so far: alice 1-4 (one 4)
legal moves: 1-5 1-6 2-1 2-2 2-3 2-4 2-5 2-6 Liar
your move (bob): Liar
pip install "agentplaykit[openspiel]"
agentplaykit env list openspiel
agentplaykit play examples/openspiel/liars-dice.yaml --human bob
6. Open questions¶
- Opponents and analysis: OpenSpiel has MCTS bots and exact solvers (CFR for small poker
games). A
scripted/openspielopponent and an analyst (SPEC-022) for small games could come next, but both need the full game state, which agents never get; they would belong to the world, like the chess analyst. - PettingZoo: its classic games give observations as numeric arrays made for reinforcement learning, which a model cannot read. An adapter would need a text view for each game, so it is left out.
- Gymnasium environments are single-agent and mostly continuous control; not a fit yet.
7. Change log¶
- 2026-12-04: Initial draft.
- 2026-12-04: Accepted by the lead maintainer; the text view names its field with
key, as the grid view does. - 2026-12-04: OSP-014 puts the params a scenario sets in the world's name, found while implementing.
- 2026-12-04: Implemented in v0.17.0; every requirement has a test.
Changes to other specs on acceptance¶
- SPEC-006, REG-008: the built-in world
openspiel, andopenspiel/<game>names. - SPEC-012, VWR-012: a
textview, shown as preformatted text (OSP-012). - SPEC-027, HUM-006: the human agent prints a
textview as text. - SPEC-007:
env list openspiel(OSP-016). - SPEC-001: ENV-019 also allows a
textview.