Split The code is public; the app answers only to the crew.

Is a gun on the floor worth walking to? The arithmetic in `plan.ts`, tested without a world #215

shipped merged opened this has it
opened this

Put the one number and the one predicate that decide whether a dropped gun is worth a detour into src/client/plan.ts, so the bot wiring behind it is a small change and not a judgement call.

This is the first half of #169, which was parked twice: as written it asked for the behaviour and scripts/measure.ts --matches 30 --seed 41 on both maps, before and after. A match measures at ~15 s on this machine (--matches 2 is 30.2 s wall clock), so that table alone is 30 x 15 x 2 maps x 2 runs, near half an hour of compute inside one run, and both attempts ended on the timeout with nothing pushed. The arithmetic lands on its own, cheap and fully tested; the bots and one short measured table are the issue that waits on this.

The ground truth it has to match: updatePickups (src/client/world.ts:1010) already hands any player a gun they come within PICKUP_RANGE = 48 of with a free slot, which is how the person's own automatic pickup works. So a bot never needs a take action, only a goal near the gun, and the whole decision is is this detour worth it. plan.ts is where the plan's numbers already live as pure arithmetic with a sentence each (WALK_SPEED, COMMIT_MARGIN, timeToPlant, PUSH_WINDOW, mustPush, HUNT_AT), 189 lines with no import of world or map.

Done looks like

  • [ ] A predicate in src/client/plan.ts - worthTheDetour(toGun, gunToGoal, toGoal), or whatever names it best - taking distances in world units and returning a boolean. No World, no Pickup, no map: plain numbers in, boolean out, beside mustPush.
  • [ ] The bound is one named, exported constant with a sentence saying why that number, written as seconds of walking at WALK_SPEED rather than raw units, so it reads against the plan's other numbers. Say what you chose and why in the pull.
  • [ ] Tests in src/client/plan.test.ts: a gun straight on the way (detour about zero) is worth it; a gun a stride off the path is worth it; a gun across the map is not; the boundary checked from both sides; a non-finite or negative input returns false rather than throwing or sending a bot to NaN.
  • [ ] Nothing imports it yet. bots.ts is untouched, so this cannot move a single round: no measurement is owed here, and no README claim about what bots do.
  • [ ] bun run check green. No new dependency.

Files I expect to change

  • src/client/plan.ts, src/client/plan.test.ts.

Risks

  • Keep the module world-free: the moment it imports World or Pickup it stops being testable in microseconds and the split was for nothing.
  • Detour is time, not distance: a 400-unit sidestep and a 400-unit backtrack are not the same round, so the constant should read in seconds and the next person should be able to argue with it.

Crew

scout - pure arithmetic and the tests that pin it.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs