Skip to content

SPEC-029: Worlds without code

  • Status: Implemented
  • Milestone: v0.18 "Worlds without code"
  • Owners: lead maintainer

1. Purpose

Today a new world is a Python class. The helpers (SPEC-017) and agentplaykit new world (SPEC-018) make that short, but it is still code, and most people who want to test agents on their own situation are not game programmers: a researcher with a question set, a teacher with a classroom game, a product team with a negotiation they care about.

This spec lets anyone write a world in one YAML file, with no code, for the three shapes most custom worlds take: - a game of choices and payoffs: every player picks a move, a table says what each gets (the Prisoner's Dilemma, a public-goods game, a pricing duel), once or over many rounds; - a quiz: questions with answers, from the file itself or a CSV, JSON or JSONL file, scored automatically (a custom benchmark in minutes); - a conversation: players with roles and private briefs talk in turns, then optionally make a final choice scored by a table, or are judged (negotiations, interviews, persuasion).

A world file is an ordinary world to everything else: it is checked like a scenario, passes the conformance kit, can be played by a person (SPEC-027), and works in experiments, tournaments, benchmarks, reports and the viewer.

2. Terms

  • World file: a YAML file that starts with agentplay_world: 1.
  • Kind: the shape of the world: matrix, quiz or conversation.
  • Player: a seat in the world; a scenario lists one agent per player, with the same IDs.

Keywords MUST, SHOULD and MAY follow RFC 2119.

3. Requirements

The file

  • NCW-001 A world file MUST be YAML with agentplay_world: 1, name, kind, rules (the text agents get) and players (a list of IDs, or for a quiz a number of players), plus the fields of its kind. It MAY set version (default "1"), description and chat (default true; false turns off messages between players).
  • NCW-002 A scenario MUST be able to use a world file as world: {use: path/to/file.yaml}, relative to the scenario, and through agentplaykit.yaml names (REG-010). config in the scenario MAY override any top-level field of the world file except agentplay_world and kind, so one file serves many settings (config: {rounds: 10}).
  • NCW-003 Loading a world file MUST NOT run code: it is read with a safe YAML loader, has no expressions or templates that execute, and may read only data files (NCW-008) in its own folder or below. The files are read when the scenario loads, never while the world plays (ENV-018).
  • NCW-004 agentplaykit check MUST validate a world file, alone or through a scenario that uses it, and report every problem with the file and the field path (prisoners.yaml:payoffs.C/D), with a "did you mean" hint for misspelled fields, kinds and moves. The format MUST be published as a JSON Schema in specs/schemas/, so editors can complete and check it.
  • NCW-005 run_start MUST record the world's name, version and kind, and the SHA-256 of the world file and of each data file it read, so a result can be traced to the exact files. Reports MUST group runs by name and version (as for any world).

A game of choices and payoffs (kind: matrix)

  • NCW-006 A matrix world MUST have moves (a list shared by all players, or a map from player to its list) and payoffs: a map from a joint move, written as the players' moves in player order joined by / (cooperate/defect), to each player's payoff (a list in player order, or a map by player). Every joint move MUST have a payoff; check MUST list the missing ones. It MAY set rounds (default 1) and show_history (default true).
  • NCW-007 Players MUST choose at the same time each round (ENV-006), without seeing the others' choice for that round. Each player sees the rules, the round, its own total and, with show_history, every past round's moves and payoffs. The score is the total payoff; the winners are the players with the highest total, or none when all are equal.

A quiz (kind: quiz)

  • NCW-008 A quiz world MUST have questions, given in the file or as questions_file (a .yaml, .json, .jsonl or .csv file). Each question has question and answer, and MAY have choices (then the legal moves are the choices), accept (more accepted answers), type (text, the default, or number with tolerance) and points (default 1).
  • NCW-009 A text answer MUST be matched after normalising case, surrounding spaces and final punctuation; a number answer MUST be matched within tolerance (default 0). The quiz MAY set ask (how many questions to ask, sampled with the run's seed; default all) and shuffle (default true, by the seed). With feedback: true a player sees whether each past answer was right; by default it does not.
  • NCW-010 Every player MUST answer every question, at the same time, without seeing the others' answers. The score is the points for right answers; the outcome MUST also give each player's correct count and the list of questions it got wrong, so a report can show accuracy.

A conversation (kind: conversation)

  • NCW-011 A conversation world MUST have roles: a map from player to public (what every player is told about it, optional) and brief (what only that player is told). Players take turns in the order of players, each sending one message per turn, for turns rounds (a number, default 4). A message is free text up to max_chars (default 600), handled as TextMoves handles it (WLD-003).
  • NCW-012 A player MUST see the rules, its own brief, every role's public text, the conversation so far and how many turns are left, and MUST NOT see another player's brief.
  • NCW-013 A conversation MAY end with final: after the last turn, each player makes one choice at the same time, scored with moves and payoffs exactly as a matrix world (NCW-006), and that decides the outcome (cheap talk, then action: did they keep their word?). Without final, the world MUST declare decided_by: "judge" (ENV-020), so a judge evaluator (SPEC-010) scores the conversation, and the run's outcome has no winners.

Making and testing one

  • NCW-014 agentplaykit new world NAME --kind matrix|quiz|conversation MUST write a commented world file of that kind and a scenario that plays it with scripted agents and no key; check, play and test MUST pass on them as written (SCF-004).
  • NCW-015 agentplaykit test my-world.yaml MUST run the world conformance kit (SPEC-001) on a world file, as it does on a .py world.
  • NCW-016 Agents MUST get the world's rules and their observation as for any world. A person MUST be able to play every kind (SPEC-027): moves are listed for matrix worlds, quizzes with choices and final choices, and typed for text answers and messages.
  • NCW-017 The viewer MUST show each kind readably without new code in the world file: a matrix round's moves and payoffs, a quiz question with each player's answer marked right or wrong, and a conversation's messages in the chat panel.

Examples and docs

  • NCW-018 examples/no-code/ MUST include: the Prisoner's Dilemma over 10 rounds, a quiz of at least 20 questions from a CSV file, and a negotiation conversation with private briefs and a final choice; each MUST run with scripted agents and no key (scripted/lines types the answers and messages).
  • NCW-019 A "Worlds without code" guide MUST show each kind from an empty file to a run, list every field with its default, explain what each player sees, and say when to move on to a Python world (SPEC-017).

4. Acceptance criteria

Requirement Test ID Notes
NCW-001..005 NCW-001..NCW-005 minimal files of each kind; config overrides; no code runs (a file with a !!python tag is refused); data files outside the folder refused; every problem reported with its field path and hints; schema validates the examples; hashes in run_start
NCW-006..007 NCW-006, NCW-007 missing joint moves listed; simultaneous rounds; history on and off; totals and winners
NCW-008..010 NCW-008..NCW-010 each data file format; text, number and choice answers; sampling and shuffling by seed; feedback; accuracy in the outcome
NCW-011..013 NCW-011..NCW-013 briefs hidden from the other players; turns and length; final choices scored by the table; judge-decided without final
NCW-014..017 NCW-014..NCW-017 new world --kind starters pass check, play and test; the conformance kit on each kind; a person plays each kind; the viewer shows each kind
NCW-018..019 NCW-018, NCW-019 the examples run; the guide's sections

5. Examples

# prisoners.yaml
agentplay_world: 1
name: prisoners-dilemma
kind: matrix
rules: >
  You and another player each choose to cooperate or defect, at the same time, for 10 rounds.
  Your score is your total payoff.
players: [a, b]
moves: [cooperate, defect]
payoffs:
  cooperate/cooperate: [3, 3]
  cooperate/defect: [0, 5]
  defect/cooperate: [5, 0]
  defect/defect: [1, 1]
rounds: 10
# capitals.yaml
agentplay_world: 1
name: capitals
kind: quiz
rules: Answer with the capital city only.
players: 2
questions_file: capitals.csv     # columns: question, answer, accept
ask: 20
# job-offer.yaml
agentplay_world: 1
name: job-offer
kind: conversation
rules: A recruiter and a candidate talk about a job offer, then each decides.
players: [recruiter, candidate]
roles:
  recruiter:
    public: You hire for a startup.
    brief: Your budget is up to 95k. You would love to hire this candidate.
  candidate:
    public: You are a senior engineer.
    brief: You have another offer at 90k. You would take this job at 92k or more.
turns: 3
final:
  moves: [agree, walk away]
  payoffs:
    agree/agree: [1, 1]
    agree/walk away: [0, 0]
    walk away/agree: [0, 0]
    walk away/walk away: [0, 0]
# scenario.yaml
agentplay: 1
name: dilemma
seed: 1
world: {use: prisoners.yaml, config: {rounds: 5}}
agents:
  - {id: a, use: ollama, config: {model: "qwen2.5:7b"}}
  - {id: b, use: scripted/random}
agentplaykit new world pricing --kind matrix
agentplaykit check pricing/pricing.yaml
agentplaykit test pricing/pricing.yaml
agentplaykit play pricing/scenario.yaml --human a

6. Open questions

  • Formulas: payoffs that depend on numbers (a public-goods game with any contribution, an auction) need arithmetic. A small, safe expression language could come later; for now, list the moves you need, or write a Python world.
  • More kinds: board games on a grid, and story worlds with states and transitions, are common requests. They need more design than a table; Python worlds cover them today.
  • Structured deals in conversations: a final choice covers agree or walk away; agreeing on numbers (a salary) would need offers with fields, as in the negotiation example.

7. Change log

  • 2026-12-04: Initial draft.
  • 2026-12-04: Accepted by the lead maintainer.
  • 2026-12-04: NCW-018 names scripted/lines, a scripted agent that types text moves (ADP-004).
  • 2026-12-04: Implemented in v0.18.0; every requirement has a test.

Changes to other specs on acceptance

  • SPEC-005: world.use may name a world file (NCW-002).
  • SPEC-006, REG-010/011: world files as local names and file references.
  • SPEC-007, CLI-009: agentplaykit test takes a world file (NCW-015).
  • SPEC-018, SCF-001: new world --kind (NCW-014).
  • SPEC-009, ADP-004: scripted/lines, for text moves without a key (NCW-018).
  • SPEC-003: run_start.world gains kind and file hashes for world files (NCW-005).