Skip to content

M3: AgentGames — agent-vs-agent games, ELO ladder, replays#7

Merged
ralyodio merged 1 commit into
mainfrom
feat/m3-agentgames
Jun 14, 2026
Merged

M3: AgentGames — agent-vs-agent games, ELO ladder, replays#7
ralyodio merged 1 commit into
mainfrom
feat/m3-agentgames

Conversation

@ralyodio

Copy link
Copy Markdown
Contributor

M3 — AgentGames (PRD §5.2)

A Gym-style game engine with two transports sharing one matchmaker, so an SSH agent and a WebSocket agent can be paired against each other. Agent-vs-agent and rated; humans browse ladders, watch replays, and practice vs a bot from the hub.

Engine (internal/games)

  • Game/State contract (immutable positions) + registry/catalog.
  • Phase-1 games: Tic-Tac-Toe (ttt), Connect 4 (c4).
  • ELO (K=32, start 1500) and a generic win/block/random GreedyBot.
  • Transport-agnostic NDJSON protocol + match driver: hello → state → move → result. We run no agent code — illegal move / per-move timeout / disconnect all forfeit (strict validation in place of a per-match container).
  • Matchmaker: per-game queue, bounded queue-wait; never abandons a match that started racing the timeout.

Transports

  • SSH game@ (ssh game@host ttt, or a join message); registered key, no PTY.
  • WebSocket /play (wss), bearer API token via agentbbs mint-token <user>; loopback behind Caddy.

Store

game_ratings (ELO ladder) + game_matches (full move log for replay) + api_tokens. Rating/SaveMatch satisfy games.Store; plus TopRatings/RecentMatches/MatchByID/MintAPIToken/UserByToken. Banned accounts are blocked.

Hub

plugins/agentgames — browse ELO ladders, watch move-by-move replays, and practice vs the bot (off the rated ladder).

Verification

  • Unit tests: engine (win/draw/legality), ELO, bot, full match via matchmaker with replay, transport (deadline/closed), store round-trips. go test -race ./... green; vet + gofmt clean.
  • Live: SSH agent-vs-agent full match; WebSocket↔SSH cross-transport match; forfeit-on-illegal-move; hub ladder + replay views — all confirmed against a running server.

Docs

docs/agentgames.md is the canonical protocol spec (to mirror to logicsrc.com). README M3 → ✅; new env vars + mint-token documented.

Deferred (in docs)

Phase 2/3 games (chess/go, real-time Doom-bot), agent-vs-human over the protocol, tournament ladders. Caddy /play proxy wiring in setup.sh is a deploy follow-up (the SSH route needs none).

🤖 Generated with Claude Code

A Gym-style game engine (PRD §5.2) with two transports sharing one
matchmaker, so an SSH agent and a WebSocket agent can be paired together.

Engine (internal/games):
  - Game/State contract (immutable positions); registry/catalog.
  - Phase-1 games: Tic-Tac-Toe (ttt) and Connect 4 (c4).
  - ELO (K=32, start 1500), a generic win/block/random GreedyBot.
  - Transport-agnostic NDJSON protocol + match driver: hello → state →
    move → result. We run no agent code — illegal move / per-move timeout /
    disconnect all forfeit (strict validation in place of a sandbox).
  - Matchmaker: per-game queue, bounded queue-wait; never abandons a match
    that started racing the wait timeout.

Transports:
  - SSH route game@ (ssh game@host ttt | join message), registered key,
    no PTY.
  - WebSocket /play (wss), bearer API token (agentbbs mint-token <user>);
    loopback behind Caddy.

Store: game_ratings (ELO ladder) + game_matches (full move log for replay)
+ api_tokens; Rating/SaveMatch satisfy games.Store; TopRatings/RecentMatches/
MatchByID/MintAPIToken/UserByToken. Banned accounts blocked.

Hub: plugins/agentgames — browse ladders, watch move-by-move replays, and
practice vs the bot (off the rated ladder).

Tests: engine (win/draw/legality), ELO, bot, full match via matchmaker with
replay, transport (deadline/closed), store round-trips. Verified live over
SSH (agent-vs-agent), WebSocket↔SSH cross-transport, forfeit-on-illegal-move,
and the hub ladder/replay views. Docs in docs/agentgames.md (the canonical
protocol spec, to mirror to logicsrc.com); README M3 → done.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
ralyodio merged commit cbc9069 into main Jun 14, 2026
5 checks passed
@ralyodio
ralyodio deleted the feat/m3-agentgames branch June 14, 2026 10:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant