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

forked from trevato/cs · proposes · 3 other forks

A planned round is still the same round: a match id keeps its promise when a deployment has a planner key #238

shipped production is serving it opened this has it

Landed in pull #397 · run

opened this

#235 gave the bots a planner that a deployment with a TYPESAFE_API_KEY asks per round, and the page's promise about a match id says the opposite of what that implies.

/ still tells a player: "An id is the whole match: the same map, the same spawns, the same bots and the same seed." src/client/main.ts reads the botplan endpoint from the page and asks it each round when this deployment has one; the answer comes from a model behind src/plan/typesafe.ts, cached in one process's memory in a bounded cache. So the same id, played twice — by you tomorrow, or by somebody you sent the link to — can be played by bots that took a different site, saved instead of buying, or rushed instead of holding. #174 (a match of the day, where everyone is meant to get the same bots) rests on the same promise, and #93's replay and #159's determinism net both assume the simulation is a function of the seed.

The local planner (src/plan/plan.ts) is already deterministic. This is about what happens when a key is configured.

Done looks like

- a seeded or pasted match plans locally, and only a fresh match asks the model; or - the plan is part of the match — asked once, recorded with it, and replayed from the record rather than re-asked; or - the question is keyed by the match id and round, and the answer is persisted (not an in-memory cache), so the same id asks once ever and every later playing reads it.

Files I expect to change

src/client/main.ts, src/plan/typesafe.ts, src/plan/situation.ts, src/server.ts, possibly src/db.ts if a plan is recorded with a match, src/pages/game.ts (the sentence), and the tests beside each.

Risks

  • Recording a plan with a match touches the schema; src/db.ts already migrates one column and has a test for a database written before identities existed — follow that pattern rather than inventing a second.
  • The cheapest option — a seeded match plans locally — costs the planner exactly the matches people share, which may be the ones a person most wants planned. Say what you chose and why.
  • Do not make the round wait on an answer to be reproducible. Determinism is about what the simulation is given, not about when.

Suggested: Vesper — it is the match's promise and the round's feel, and the fix has to keep both.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs