Skip to main content

Demo

Multi-agent chess

Imagine a game of chess where each piece moves itself. 2 teams of 16 players.

Take an ordinary game and remove the players. Each of the 32 pieces is its own agent, with its own name and its own signing key. It sees the board and can send a move for itself. Nothing stops a knight from moving on its own.

Watch them play over chat

Start with the simplest way to coordinate. Each team has a chat channel. Agents talk about the plan there, and each piece sends its own move. The referee plays the first move it receives from the piece that makes it.

Both teams over chat. No contract, no shared rules.

White · chat0 off-plan sent · 0 played

No messages yet.

White to move. Press ▶ or step through.

an off-plan move was played a move or rule was refused, or rules changed

Black · chat0 off-plan sent · 0 played

No messages yet.

Both teams drift. Whenever an off-plan move arrives first, it is the move that's played. Talking more doesn't change that: the referee takes the first move from the right piece, not the move the team agreed on.

White writes rules down

Now White adds a shared RULES.md. After an off-plan move is played, White's agents hold a retro and one of them writes a rule. An agent about to go off plan reads the file and follows a rule that covers it half the time. Nothing checks the file. Black still only chats.

White keeps a RULES.md that its agents write and are asked to follow. Black only chats.

White · chat0 off-plan sent · 0 played

No messages yet.

White to move. Press ▶ or step through.

an off-plan move was played a move or rule was refused, or rules changed

Black · chat0 off-plan sent · 0 played

No messages yet.

White: RULES.md against plain chat · 16 games each

With RULES.md, the share of White's off-plan moves that reached the board fell from 81% to 41%.

Plain chatRULES.md
Off-plan moves White's agents sent, per 10 White moveswithin noise1.71.5–1.91.71.5–2.0
Share of them RULES.md held back—47%38%–54%
Share of them that reached the board81%76%–86%41%34%–49%
Centipawns White lost to them, per gamewithin noise16581289–19891074732–1392
White score (win 1, draw ½)within noise0.560.34–0.780.660.44–0.88
Black, which only chats: share of its off-plan moves that reached the boardwithin noise79%74%–84%76%71%–79%

Small numbers are 95% intervals from resampling games. "Within noise" means the two intervals overlap: sixteen games can't tell that difference apart. The last row is the other side, which plays plain chat in both: it should not move.

A written rule helps exactly as often as an agent decides to follow it.

Two teams, two answers

White keeps its chat. The referee plays the first White move that arrives from the piece that makes it. In some experiments White also keeps a shared RULES.md that its agents write and are asked to follow. Nothing checks it.

Black coordinates through a Modality contract instead. Every move is a commit. The piece that moves proposes it by signing, and every agent that agrees co-signs. An agent that goes off plan signs its own move, alone. The referee plays the first Black commit the contract accepts and reads nothing else. The contract has three rules:

contract/rules.txt
owns_moves: always([+modifies(/moves/$k.text) -signed_by(/team/pieces/$k.id)] false)
team_moves: always([-threshold("4", /team/pieces)] false)
roster_locked: always([+modifies(/team)] false)

In owns_moves, $k stands for every agent: a commit that writes a piece's move must be signed by that piece. So on Black a piece can only formally propose its own movement. Every commit needs signatures from four of the sixteen Black agents, and nobody can change who the sixteen are. The contract doesn't know what a good move is, or even what chess is. It counts who agreed.

One turn, two ways · move 9 for Black, game 1 below

Two moves are sent

Ng3+knight_g8 proposes the team's plan · 15 of 16 agents sign
Bxh4bishop_f8 proposes a capture of its own: greed · signs alone · arrives first

Over chat

The referee plays the first move that arrives.

Bxh4 played. The plan never lands.

Through the contract

Each move is a commit. The contract counts signatures.

Bxh41 signature, 4 neededrefused
Ng3+15 signatures, 4 neededaccepted
missing +threshold(4, /team/pieces) (authorized signatures 1/4 required from 16 accepted members under /team/pieces
Black: a Modality contract against plain chat · 16 games each

With the contract, the share of Black's off-plan moves that reached the board fell from 79% to 0%.

Plain chatModality contract
Off-plan moves Black's agents sent, per 10 Black moveswithin noise1.81.6–2.12.31.9–2.7
Share of them that reached the board79%74%–84%0%0%–0%
Centipawns Black lost to them, per game17921531–206000–0
Centipawns given up replanning around a refused piece, per gamewithin noise—890–240
Black score (win 1, draw ½)0.440.22–0.660.910.81–1.00
White, which only chats: share of its off-plan moves that reached the boardwithin noise81%76%–86%76%68%–83%

Small numbers are 95% intervals from resampling games. "Within noise" means the two intervals overlap: sixteen games can't tell that difference apart. The last row is the other side, which plays plain chat in both: it should not move. Under the contract, an agent whose move was refused is asked again and may stray again, so more off-plan moves are sent. None of them is played.

Watch a game

Every Black move here is a real commit that modal checked. Step through a game, or jump from incident to incident.

Chat against the preset contract. Three White moves no one planned reach the board. None of Black's do.

an off-plan move was played a move or rule was refused, or rules changed

Loading game…

Written rules work as far as agents obey them

Give White a shared RULES.md and its agents write good rules, nearly all of them "send only the agreed move". Then it comes down to whether they follow them.

Off-plan moves that reached the board, per game · 16 games each, fault rate 0.1
Chat6.4
Chat + RULES.md, followed half the time4.0
Chat + RULES.md, always followed1.1
Modality contract0.0

A RULES.md that every agent always obeys does about what the contract does: Black's score fell to 0.58, close to the 0.44 it scores with no faults at all. The contract does not need anyone to obey it.

An empty contract belongs to whoever writes the first rule

Let Black start with an empty contract and write its own rules after things go wrong. From ply 10, a rogue agent on each side tries to take over. Black's rogue posts one rule: every commit must carry its signature. Rules only accumulate, and none comes off. So the race is decided by who writes first.

Rule first · 5 of 16 games

  1. ply 2knight_g8 plays Nh6 off plan. With no rules, one signature is enough.
  2. ply 2Retro: the team commits a rule that a move needs 12 of 16 signatures.
  3. ply 10The rogue pawn_e7 posts its takeover rule. Refused: it has one signature, not twelve.
  4. endBlack wins on material.

Rogue first · 11 of 16 games

  1. ply 1–9Black plays its plan every move. Nothing prompts a retro, so no rule is written.
  2. ply 10The rogue bishop_f8 posts its takeover rule. The contract is empty, so it is accepted.
  3. ply 10The team's next move lacks the rogue's signature. Refused, three times.
  4. endBlack forfeits.

Against the preset contract, the same rogue was refused in all 16 games, and Black scored 0.94. A contract that starts with its rules has no race to lose.

Left alone, agents write the same kind of rule

When Black's agents wrote their own contract, every rule the team got accepted required a number of the sixteen signatures: in 16 games against plain chat, 13 rules at twelve and 3 at nine. Each team wrote its rule in plain language, and modal contract ai suggest-rule turned it into a formula. In 14 of the 16 games the rule went in at the team's first retro. Once a rule was in, no off-plan Black move reached the board.

Ratings

Each experiment is a match between White's way of coordinating and Black's. Fit them all at once and each way gets an Elo rating, with a term for White moving first. A 200-point gap means the stronger team scores about 0.76 against the weaker.

Elo by way of coordinating · plain chat fixed at 1500 · 95% intervals
Self-ruled Modality contract1835
Chat + RULES.md1607
Plain chat1500

From 64 games with the default faults: each of the three plays the other two, and plain chat also plays itself. RULES.md is followed half the time, as everywhere on this page. The self-ruled contract writes a rule before the first move and more after incidents. The other experiments, including the preset contract, are in the table below. White's first-move edge came out at 17 points (-121 to 160). Intervals come from refitting on games resampled within each experiment.

All experiments

ExperimentWhiteBlackGamesBlack scoreOff-plan played, WhiteOff-plan played, Black
Both sides over chatchatchat160.448.89.3
White keeps a RULES.md, Black only chatschat + RULES.mdchat160.344.68.6
Control: no faultschatpreset contract160.440.00.0
Baselinechatpreset contract160.916.40.0
White keeps a RULES.mdchat + RULES.mdpreset contract160.754.00.0
RULES.md, always obeyedchat + RULES.mdfollowed 100%preset contract320.581.10.0
RULES.md always obeyed, Black only chatschat + RULES.mdfollowed 100%chat160.131.37.0
RULES.md, obeyed 95%chat + RULES.mdfollowed 95%preset contract160.501.40.0
RULES.md obeyed 95%, Black only chatschat + RULES.mdfollowed 95%chat160.191.87.7
Black writes its own ruleschatself-ruled contract160.886.11.1
Black writes its own rules from the startchatself-ruled, from the start160.916.40.0
RULES.md against rules from the startchat + RULES.mdself-ruled, from the start160.754.00.0
Both sides write ruleschat + RULES.mdself-ruled contract160.594.51.0
Rogue vs. preset contractchatpreset contract160.947.80.0
Rogue, both sides write ruleschat + RULES.mdself-ruled contract160.314.21.5
Pawn personalitieschatpreset contract160.885.10.0
Pawn personalities, both write ruleschat + RULES.mdself-ruled contract160.635.31.1

Black score counts a win as 1 and a draw as ½. Off-plan moves are per game. In every game, the contract's own log agrees with the moves the referee played.

What this does not show

  • The chess is simulated: a shallow engine every agent shares, and fixed rates of panic, greed and amnesia. Only the rules are written by a language model.
  • How often an agent follows RULES.md is a setting, not a measurement. The experiments try one half and always.
  • Sixteen games per experiment separate large effects, not close ones.
  • Four agents that go off plan together can get their move past a four-signature contract.
  • In the rogue games, White also keeps a RULES.md, so the two rogue experiments differ on both sides, not only Black's.

Run it

cd examples/multi-agent-chess
pip install -r requirements.txt
python3 multi_agent_chess.py play --seed 7 # one narrated game, with a replay page
python3 multi_agent_chess.py experiments --games 16 --jobs 8 --cache results/llm-cache

results/llm-cache holds every language-model answer these games used, so a rerun plays the same games without asking a model.