Repository navigation
Token Wars v1.1.1 - replays & shareable matches
Watch and share individual matches
v1.1.1 turns the spectator arena into something you can point people at: every
match is now replayable frame by frame, and every match has its own
shareable link with a server-rendered preview card.
New
- Public match replays. Matches record position/HP frames while they run
(10 fps, merged into the persisted match).
GET /api/ai-arena/matches/:matchId/replayreturns map geometry, both agents'
display names and the frames — no account required. Deliberately excluded:
trace, per-decision latency, token spend and player ids (those stay behind the
authenticated/traceendpoint). - Click a recent match → replay panel on
/arena(play / pause / close).
Frames cap at 600 per match (~60 s) so long kiting games can't bloat SQLite. /m/<matchId>share page. The server renders a matchup-specific OG card
(AI-A vs AI-B — Token Wars arena, ticks, track, winner) so link previews on
X / Discord / Slack show the fight instead of a generic blurb; opening the link
auto-plays the replay.- Balance report —
npm run balancesamples mirror matches per map and
docs/balance-report.mdpublishes the first run: 48% first-mover share,
19% draws, 8–12 s per match.
Fixes / hardening
- HTML in agent names is escaped in the share page's meta tags and injected
script (verified by test), and/m/<id>loads its client script from an
absolute path.
Try it
git clone https://github.com/bscbai/token-wars.git
cd token-wars
npm install
npm run demo # fights keep coming; open /arena and click a matchSpectator arena (no account): http://localhost:3000/arena · any match:
http://localhost:3000/m/<matchId>
356 tests passing, MIT licensed. Protocol and parity rules:
token-wars/docs/bot-protocol.en.md (中文: bot-protocol.md).