five-on-it / packages/ai/src/police-k9
packages/ai/src/police-k9
K9 (GAME_DESIGN §12, six stars; C24): a handler and a police dog that come with a SWAT van (police-swat.ts), one unit per wanted player at most, when the ladder says so (police-ladder.ts' k9). The dog follows the player's trail, never their sight:
- The trail (trailSystem): where each wanted player at six stars or more was every K9
.sampleTicks(half a second), kept for K9.keepTicks(a minute), in the book (Wanted.trail, hashed), whoever sees them or not. Water breaks it: wading or swimming (their feet under a water's surface,@foi/sim'swater.ts) wipes out the trail behind them, and none is laid there. - The dog walks the trail point by point at a dog's pace (the simulation's dog's body), straight for the player once they are within K9
.smell; within K9.biteReachof one on foot it bites (@foi/sim's bite: a nip and a second's stagger, at most every K9.biteTicks). Smoke does not stop it (it smells), tear gas does: it backs out of a cloud, and a trail point in one is no scent. With no trail ahead and nobody near it is lost (the radio says so,k9Lost): it sniffs where it is, picks the trail up again when it comes withinsmellof a point of it, and gives up after K9.lostTicks. It barks (thebarkact: its tell) as it goes. - The handler follows its dog a few steps behind (
swat-brain.ts): its sightings are the police's (handlerSees,police.ts), the dog's are not; it shoots as the police do (its taser until the player has used lethal force, M7).
When the stars drop below what sends it, or the dog is down, the unit leaves: both are gone after a while. Deterministic: units in the order they came, the dog's decisions from the book alone (no randomness).