Public: anyone can read this; the crew can change it.

forked from trevato/cs

study typesafe.ai and integrate it into the bots for individual planning and… #235

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

The bots had A* for the objective and a trained policy for the fight, and nothing between them: every bot flipped its own coin for a site, so five attackers arrived at two sites in ones and twos. `src/plan/plan.ts` is that missing layer — a round plan is a site, a shape (`stack`, `split` or `fake`), a tempo and a save per side, and `assign` cuts it into one job per bot: which site it walks to, ent…

shipped production is serving it deploy ae07c2d

opened this

The bots had A* for the objective and a trained policy for the fight, and nothing between them: every bot flipped its own coin for a site, so five attackers arrived at two sites in ones and twos. src/plan/plan.ts is that missing layer — a round plan is a site, a shape (stack, split or fake), a tempo and a save per side, and assign cuts it into one job per bot: which site it walks to, entry or support or lurk or anchor, the beat it waits before moving off, how far off the site it stands, and whether it buys at all. The fight, the policy and the weights are untouched.

Where the plan comes from is one environment variable. With no TYPESAFE_API_KEY — which is what this preview is — the page plans every round itself with localPlan, sends nothing anywhere, and the bots are still a team. With a key, the page posts the round's situation (map, round, score, money per side, and nothing about the player) to POST /api/plan, and src/plan/typesafe.ts puts it to TypeSafe AI as typed questions: a choice between the two sites, a four-step rubric for the tempo, a noul for the save. Every answer is validated field by field back into a plan, or dropped whole for the local one; a timeout, a 500, junk on the wire and a caller over its limit all end in a plan rather than an error.

Worth looking at: the round's call now appears on the HUD at the start of every round ("T: split B, fast"), so play a match in the preview and watch the attackers arrive together instead of in dribs. The plan hangs on the world rather than in a module — a plan is one match's, and a module-level one leaked into the arena and moved the pinned replay digests, which is how that got caught. @typesafe-ai/sdk is this repository's first runtime dependency, justified in the header of src/plan/typesafe.ts: it is the vendor's own MIT client with no dependencies of its own, it carries the retry/timeout/error taxonomy a call into a round needs, and it takes its fetch as an option, so all eight planner tests run against a stub and never the network.

What I chose not to do: the terminal has no plan surface — a round's plan is browser state for a match in progress and the tty shows the leaderboard, so there was nothing honest to print there; the app's log line says whether planning is live. I also did not touch the trainer or the arena: bots nobody planned for behave exactly as before, down to the coin flip, which is what keeps the RL guard and the replay digests where they were. bun test is 1,057 passing, and the committed bundle is rebuilt (app 92,978 raw / 36,716 gzipped, still under its 98,000 / 39,000 ceiling; the planner itself ships in no bundle).

🤖 Generated with Claude Code

Closes #228

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs