Public: anyone can read this; the crew can change it.
forked from trevato/cs
bots should take cover when reloading. bots are still pretty dumb. they just… #360
Check · Review · Land · Live done — Landed and live in production.
Bots now reload behind cover. When a bot runs its magazine dry with an enemy in view, it runs to the nearest spot that enemy can't see and reloads there, instead of standing still and strafing for the 2–4 seconds it can't shoot. When the magazine is in, the trained policy takes over again. `bun run test` passes (typecheck plus 1416 tests).
shipped production is serving it deploy ae07c2d
Sign in to join this conversation.
new above
offline
Bots now reload behind cover. When a bot runs its magazine dry with an enemy in view, it runs to the nearest spot that enemy can't see and reloads there, instead of standing still and strafing for the 2–4 seconds it can't shoot. When the magazine is in, the trained policy takes over again.
bun run testpasses (typecheck plus 1416 tests).What changed
src/client/cover.ts:-
exposedchecks whether a threat's eye can see a standing body at its eye and at both shoulders. A wall or a smoke cloud blocks the view. -coverFromsearches the cells up to 4 out (512 units) around the bot, nearest first, for one that isn't exposed. It returns a path of at most 6 cells, or[]if the bot is already hidden, ornullif no cover is in reach.src/client/bots.ts:takeCoverruns inbotThinkbefore the fight while a reload is running. It picks the spot once per reload, then runs the bot there with its view on where the enemy was, and stands still on arrival. With no cover in reach, the policy keeps the fight as before.- Only bots on the trained policy do this. The scripted baseline in the training arena never does, so what the policy is measured against hasn't moved. - The policy's inputs, outputs and shipped weights are untouched.
Tests
src/client/cover.test.ts: open versus walled-off positions; the path length cap; a bot that is already hidden stays put; a full reload played out, after which the bot stands on the cover cell out of sight; the path is picked only once per reload and the policy takes over after; the scripted baseline never takes cover.Re-pinned digests Four seeded rounds in
src/client/replay.test.tschanged on purpose:ROUND,SMOKE_ROUND,SWITCH_ROUNDandOPEN_ROUND. All four match the old digests up to second 12 or 13, the first reload under fire, and differ from there. The comment aboveROUNDexplains why. The arena duel,TIGHT_ROUNDand the generated round ingenerate.test.tsstill match their old digests.Not done
Also:
src/range/boot.test.tsfailed once, in a test about drawing range plates that doesn't touch bots, and passed on the rerun.How to try it: start a round in the preview, empty a rifle's magazine on a bot in the open, and watch it duck behind the nearest wall or smoke before it shoots again. The README's "The bots" section describes the behaviour.
🤖 Generated with Claude Code
Closes #357