SPEC-024: Chess world¶
- Status: Implemented
- Milestone: v0.13 "Chess"
- Owners: lead maintainer
1. Purpose¶
Chess is the best-known test of planning and strategy, and the first game people ask to see
AI models play. AgentPlay should ship it as a built-in world, as it ships tic-tac-toe and
rock-paper-scissors. Then any two agents can play with world: {use: chess}, talk while they
play, be watched move by move in the viewer, and be compared in reports and benchmark suites.
No extra package is needed.
2. Terms¶
Keywords MUST, SHOULD and MAY follow RFC 2119.
- SAN: standard algebraic notation, as printed in chess books: e4, Nf3, exd5, O-O,
e8=Q, Qxf7#.
- UCI: a move as its from and to squares, with a promotion letter: e2e4, e7e8q.
- Perft: the number of move sequences of a given depth from a position; the standard check
that a move generator is correct.
3. Requirements¶
The world¶
- CHS-001 The framework MUST ship a built-in world
chessthat plays the full rules of chess: castling, en passant, promotion, check, checkmate, stalemate, threefold repetition, the fifty-move rule and insufficient material. It MUST need no package beyond AgentPlay's own dependencies (see ADR-0013). - CHS-002 The rules engine MUST produce the published perft counts for the standard test positions: the starting position to depth 3 (8,902) and "Kiwipete" to depth 2 (2,039), plus positions that test en passant, castling through check and promotion.
- CHS-003 The world MUST take these config fields, all optional:
| Field | Default | Meaning |
|---|---|---|
players |
[white, black] |
the two agent ids, white first |
max_moves |
60 | moves per side before the game stops |
at_limit |
draw |
a stopped game is a draw, or goes to whoever has more material |
fen |
the start | a starting position in FEN |
talk |
false | ask each player to send its opponent one short message every move |
An invalid fen or at_limit MUST be reported as a config error that names the field.
Moves¶
- CHS-004 The legal actions MUST be the legal moves in SAN. A move MUST also be accepted in
UCI and with common variations: any letter case for UCI,
0-0forO-O, a missing or extra+,#or=(e8Q), and a dash or space in UCI (e2-e4). The step'sinfo.normalisedMUST say what was sent and how it was read (WLD-004). - CHS-005 A rejected move MUST be answered with what was wrong and the legal moves, for
example
"Ke2" is not a legal move; legal moves: "Nc3", "Na3", ..., so the agent can try again (RUN-008).
What each player sees¶
- CHS-006 The observation MUST include:
- the player's colour and its opponent's id;
- the board as text rows with coordinates (letters, which models read well), and as 64 squares with chess symbols (♔ white, ♚ black) for the viewer;
- the position in FEN;
- whose turn it is and whether the player is in check;
- the last moves in SAN;
- the player's legal moves when it is its turn;
- the material each side has;
- the moves the player has left.
With talk: true it MUST also include a note that names the opponent's exact id as the
recipient, so models address messages to an agent that exists.
- CHS-007 describe() MUST include a view hint for an 8 by 8 grid (ENV-019), so the replay
and live pages draw the board.
The end of a game¶
- CHS-008 A game MUST end at checkmate (the player who gave mate wins), stalemate,
threefold repetition, the fifty-move rule or insufficient material (draws), or at
max_moves, asat_limitsays. The outcome MUST score a win 1, a draw 0.5 for each player and a loss 0, and MUST name the ending in plain words, such as"checkmate: qwen wins"or"the same position three times: a draw".
Examples and docs¶
- CHS-009 The framework MUST ship an example scenario in which two models play chess and
talk, with comments on the settings that help small models (
json_mode,format_hints,limits.max_illegal). The docs MUST describe the world, its config, the move formats and the endings.
4. Acceptance criteria¶
| Requirement | Test ID | Notes |
|---|---|---|
| CHS-001..002 | CHS-001, CHS-002 |
every rule in a set position; perft counts; no import of other packages |
| CHS-003 | CHS-003 |
each field; bad fen and at_limit |
| CHS-004..005 | CHS-004, CHS-005 |
SAN, UCI and variations; normalised info; the rejection text |
| CHS-006..007 | CHS-006, CHS-007 |
observation fields; talk names the opponent's id; view hint |
| CHS-008 | CHS-008 |
each ending; scores; ending text |
| CHS-009 | CHS-009 |
the example passes agentplaykit check; the docs page exists |
The world also runs the SPEC-001 conformance tests (ENV-001 to ENV-018), as every built-in world does.
5. Examples¶
agentplay: 1
name: chess
world: {use: chess, config: {players: [qwen, llama], max_moves: 60, talk: true}}
agents:
- {id: qwen, use: ollama, config: {model: "qwen2.5:3b", json_mode: true}, wrap: [format_hints]}
- {id: llama, use: ollama, config: {model: "llama3.2:3b", json_mode: true}, wrap: [format_hints]}
limits: {max_steps: 200, max_illegal: 5}
What qwen sees on its first move (shortened):
{"you_play": "white (capital letters)", "opponent": "llama", "your_turn": true,
"board": ["8 r n b q k b n r", "7 p p p p p p p p", "...", " a b c d e f g h"],
"legal_moves": ["Nc3", "Na3", "Nh3", "Nf3", "a3", "...", "h4"], "last_moves": [],
"material": {"you": 39, "opponent": 39}, "your_moves_left": 60}
6. Open questions¶
- A scripted chess opponent stronger than
scripted/random, for benchmark suites. - Time controls, as a number of seconds per player.
7. Change log¶
- 2026-12-02: Initial draft.
- 2026-12-02: Accepted by the lead maintainer, who asked for chess as a built-in world.
- 2026-12-03:
describe()gainsanalysisfor the chess analyst (SPEC-022 STR-013 to STR-015). - 2026-12-03: Implemented in v0.13.0; every requirement has a test.
Changes to other specs on acceptance¶
- SPEC-006, REG-008: the built-in worlds include
chess. - ADR-0013 on writing the rules engine in AgentPlay instead of depending on python-chess, whose GPL-3.0 licence would apply to everyone who installs agentplaykit.