Skip to content
ecorealPublic

About

⚔️ duel — a deterministic AI agent arena in your terminal. Any executable can fight. Every match is a replayable file.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

⚔ duel

A deterministic AI-agent arena in your terminal. Any executable can fight. Every match is a replayable file.

⚔ duel · seed 42 · turn 12/12 random WINS

greedy  KO                            ┃random
  \|/ *charged*                       ┃  \O/
   x_x                                ┃   |
  / \                                 ┃  / \
░░░░░░░░░░░░░░   0/100                ┃███████████░░░  80/100

T 9 greedy heals 8 · random strikes for 21
T10 greedy heals 13 · random heals 8
T11 greedy heals 10 · random unleashes HEAVY for 25
T12 greedy heals 9 · random unleashes HEAVY for 20

Yes — at seed 42, the random bot still beats greedy. Chaos remains a strategy.

🏆 Weekly standings (auto-updated Mondays)

2026-W43 — patient 1300.4 · greedy 1205.1 · greedy#2 1202.2

Full table: results/week.json · run your own bots against the same seeds: duel season <yourbot> builtin:greedy ... · join the ladder

60-second demo

git clone https://github.com/ecoreal/duel && cd duel
duel run bots/greedy.mjs builtin:random --seed 42   # npx duel-arena after publish
duel watch duel-42.json                            # spectate, frame by frame

The idea

You have agents. Other people have agents. Stop benchmarking them with vibes — make them fight in a game where luck is a seeded variable you control.

  • clash/2 (current) — both fighters get 100 HP and four moves: strike (10–16), heavy (18–26, 20% self-recoil), heal (8–14), charge (next attack ×1.5 — but you take ×1.25 damage while charging). Simultaneous turns, no first-player advantage, 40-turn limit. Balance tuned over 500-seed simulations (scripts/sim.mjs): no pure strategy exceeds ~72% against any other. clash/1 (v0.1.0 rules) replays still verify — a replay is forever.

  • rope/1 (game #2, --game rope/1) — tug of war on a 13-cell rope: haul, lunge, lean, rest; 15% slips, 10 stamina, knot to ±6 or the lean wins at turn 30. Tuned over a 1000-seed matrix (scripts/sim-rope.mjs) into a rock-paper-scissors cycle with a predator for every naive strategy — haul-only beats the rest-then-haul counter just 58%.

    Write a rope bot — stdin JSON has knot (shared: + is A's edge, × me.dir to make it yours), stamina, foeStamina; readable sample: bots/tugger.mjs.

    stdin  → {"game":"rope/1","turn":5,"knot":-1.5,"stamina":7,"foeStamina":4,"me":{"dir":-1}}
    stdout ← {"move":"lean"}
    duel eval bots/mine.mjs builtin:rope-greedy --game rope/1 --games 20   # honest numbers, sides swapped
    
  • An agent is any executable. It receives the match state as JSON on stdin and prints {"move":"strike"} on stdout. Four lines of bash can fight. So can an LLM. So can yourragiest regex.

  • Deterministic engine — splitmix32 PRNG, no Math.random in the engine. Same seed + same moves = byte-identical match. Argue about outcomes with receipts, not screenshots.

  • Matches are files. A replay is ~2 KB of JSON (seed + moves). Share it like a gist; anyone can re-simulate and spectate. duel verifies replays by re-simulating them.

  • ELO ladder — duel ladder a b c ... runs a double round-robin (sides swapped) and maintains ladder.json.

Why not just...?

alternative the problem
LLM leaderboards static benchmarks; can't watch, can't replay, can't add your agent
Elo bots on websites accounts, uptime, someone else's rules
writing your own harness a weekend of glue before the first fun match

Agent protocol (the whole thing)

stdin  → {"game":"clash/1","turn":3,"me":{"hp":72,"charged":true},"foe":{...},"rules":{...},"history":[...]}
stdout ← {"move":"strike"}        # 1.5s default; timeout = a jab (strike)

With --pickban, one extra exchange happens first — same pipe, different question:

stdin  → {"phase":"ban","game":"clash/2","moves":["strike","heavy","heal","charge"],"banned":[]}
stdout ← {"ban":"heavy"}          # a ban removes the move for BOTH fighters

Sample bots ship in bots/: random.sh (4 lines of bash), greedy.mjs (readable strategy), adapt.mjs (reads foe history, counters it), patient.mjs (beats adapt 72% — see #1 for the eval-driven story), counter.mjs (beats adapt 86%, greedy 86%, patient 60% — written to close issue #1), llm.mjs (any OpenAI-compatible endpoint, use --timeout 10000). Built-in sparring partners: builtin:random, builtin:greedy, builtin:rope-greedy — zero setup.

CLI

duel run <A> <B> [--seed N] [--best 3] [--timeout MS] [--json] [--pickban]
duel watch <replay.json>        # space pause · ←/→ step · +/- speed
duel stream <A> <B>             # live: watch the agents play, frame by frame
duel stream <replay.json>       # the same, for a finished match (--delay ms)
duel gif <replay.json>          # the whole match as an animated GIF (zero deps)
duel story <replay.json>        # full match narrative, paste-ready
duel adopt <gist-url|file>      # import + verify a replay; fight its ghost
duel frame <replay.json> [turn] # headless render (--plain) — CI & README-friendly
duel ladder <A> <B> [...]       # double round-robin → ELO table + ladder.json
duel bots                       # where the sample bots live

🎲 duel run --pickban — the draft

duel run bots/patient.mjs bots/greedy.mjs --seed 21 --pickban
🎲 draft: greedy bans strike · patient bans heal (greedy first)
⚔ patient vs greedy · seed 21 · 4 turns
   greedy wins — hp 0:29

Before the first punch, each side removes one move — and a ban applies to both fighters, so the draft is really a negotiation about what kind of game this will be. The seed decides who bans first, a best-of series alternates that advantage, and a replay records its bans ("bans": ["strike","heal"]), so a drafted match verifies exactly like any other — drop or edit the bans and the log no longer reproduces.

One rule keeps it a game: a draft may never remove the last attack. Ban both strike and heavy and every turn is two fighters healing at each other until the turn limit — the engine refuses that ban rather than hand you a stalemate. It works in run, eval, season, ladder and tournament.

🎬 duel stream — live, not a recording

duel watch is time travel. duel stream is the fight itself: both agents are asked for a move, and the arena frame is redrawn the instant both answers land.

duel stream bots/adapt.mjs builtin:greedy --delay 200
duel stream bots/adapt.mjs builtin:greedy --pickban   # draft first, then fight
duel stream duel-42.json --delay 400        # re-live a finished match, live

On a TTY it redraws in place (cursor hidden, restored on exit, even on ctrl-c). Piped anywhere — CI logs, a gist, a file — it degrades to one stable line per turn, --every N for an occasional full frame, so a streaming match is greppable and diffable:

T07 greedy heals 9 · berserker unleashes HEAVY 24 · hp 46:71
T08 greedy strikes 13 · berserker strikes 12 · hp 33:59

The replay is written when the match ends (--out, default duel-<seed>-live.json), so streaming produces exactly the same artefact as any other match — verifiable, adoptable, fightable as a ghost.

🎞 duel gif — the match as an animated GIF

duel gif duel-42.json                    # → duel-42.gif

Every turn is a frame of the arena, rendered by the same renderFrame() the TUI uses (so the GIF can never drift from what you saw), rasterized with a hand-drawn 5×7 bitmap font and encoded by a hand-written GIF89a/LZW encoder — no dependencies, no font files, no headless browser. The footer carries the seed, the format and, on the final frame, the winner. --frames samples long matches (keeping the opening bell and the finish), --delay is ms per frame (default 180), --cols/--rows set the character grid, --scale 2 doubles it for slides.

Frames after the first are transparent deltas (GIF disposal 1): the names, the health bars and the border never move, so they cost nothing after the opening frame — a 13-frame clash film goes from 37.0 KB to 19.8 KB with an identical composite. --no-diff gives you the naive full frames.

MVP scope (v0.1) — deliberately tiny

In: one game (clash/1), executable-agent protocol, deterministic engine + replay verify, spectator TUI, ELO ladder, three sample bots.

Out (on purpose): network play, matchmaking server, multiple games, tournament brackets, web UI. The engine interface (play(seed, movesA, movesB)) is deliberately game-agnostic — game #2 proves it.

Tech stack & why

choice reason
Node.js ≥ 18, ESM everyone has it; agents in any language via stdin/stdout
0 runtime dependencies git clone and play; nothing to audit
plain ANSI rendering works over SSH, in CI logs, in a README (see above)
node:test npm test, zero config

Roadmap

  • v0.2: submit/adopt ✅ shipped — duel adopt <gist>, then duel ladder ghost:adopted.json:0 builtin:greedy — fight the recording in your own ladder.
  • v0.3: game #2 ✅ shipped — rope/1, tug of war (--game rope/1): the engine interface really is game-agnostic. Best-of-N with pick/ban still open.
  • v0.4: duel stream ✅ shipped — live spectate while the agents play (TTY redraw, or one line per turn on a pipe), with the replay written at the end. duel gif turns any match into an animated GIF with a zero-dep GIF89a encoder (transparent delta frames: the static arena is paid for once).
  • pick/ban ✅ shipped — --pickban on run/eval/season/ladder/tournament: one ban per side, seed-decided order, bans stored in the replay, and an engine rule that refuses to draft away the last attack.
  • open: game #3 (the interface has now survived two very different games), and a duel draft <A> <B> command that shows the ban conversation on its own.

Contributing

Best PRs for v0.1: new bots (drop a file in bots/, any language) and new render themes. Especially welcome: a bot that reliably beats greedy#2.

MIT © 2026 duel contributors

About

⚔️ duel — a deterministic AI agent arena in your terminal. Any executable can fight. Every match is a replayable file.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages