Skip to content

five-on-it / packages/ai/src

packages/ai/src ​

@foi/ai: the NPC brains. The server builds one AI world beside its simulation (createAi), spawns chasers into it with a behaviour profile (spawnChaser) and runs aiSystem every tick before the simulation steps; each NPC perceives (sight, hearing, being hit), decides (idle, alert, chase, search, return), plans on the navigation grid or the road graph within a budget, and writes an ordinary input, so the character and vehicle systems move it like a player. The police (policeSystem, run before aiSystem) turn the players' crimes into a Wanted level and the stars into police cars of chasers with the police profile. The ambient traffic (setTraffic) is drivers of the same kind on the lanes, obeying the traffic lights and giving way at the junctions; the crowd (setCrowd) keeps pedestrians with roles on the pavements around the players (both around the AI world's standIns while nobody is in the room: a room warming up before its first player). The sentries of stealth (spawnSentry) walk their rounds and watch: a cone and hearing, the alert phases (normal, suspicious, alert, search, caution), the security cameras feeding them, the bodies they find; the book of stealth keeps the room's alert and each player's counts. The role NPCs (spawnRole: drivers, targets, VIPs; racers are drivers on a race) and the schedules by the room clock that send NPCs about the city and home; the restricted zones (setRestrictedZones) that raise the alert or the Heat; the signals a mission switches (switchSignal). Isomorphic (no DOM, no Node) and deterministic.

References ​

AiBudget ​

Re-exports AiBudget


aiReadout ​

Re-exports aiReadout


AiStatic ​

Re-exports AiStatic


aiStaticOf ​

Re-exports aiStaticOf


AiStats ​

Re-exports AiStats


aiSystem ​

Re-exports aiSystem


AiWorld ​

Re-exports AiWorld


alertSentries ​

Re-exports alertSentries


Arrest ​

Re-exports Arrest


AWARENESS ​

Re-exports AWARENESS


BehaviourProfile ​

Re-exports BehaviourProfile


buildAiStatic ​

Re-exports buildAiStatic


calmSentries ​

Re-exports calmSentries


CAMERA ​

Re-exports CAMERA


CameraWatch ​

Re-exports CameraWatch


canSee ​

Re-exports canSee


catchUpSchedule ​

Re-exports catchUpSchedule


clampProfile ​

Re-exports clampProfile


CLASS_MIX ​

Re-exports CLASS_MIX


clearCrowd ​

Re-exports clearCrowd


clearNpcs ​

Re-exports clearNpcs


clearTraffic ​

Re-exports clearTraffic


commuteAt ​

Re-exports commuteAt


createAi ​

Re-exports createAi


CrimeKind ​

Re-exports CrimeKind


crimesOf ​

Re-exports crimesOf


CROWD ​

Re-exports CROWD


CROWD_HOURS ​

Re-exports CROWD_HOURS


crowdReadout ​

Re-exports crowdReadout


crowdShare ​

Re-exports crowdShare


crowdWanted ​

Re-exports crowdWanted


dogReadout ​

Re-exports dogReadout


entryAt ​

Re-exports entryAt


fleeRole ​

Re-exports fleeRole


hashAiState ​

Re-exports hashAiState


inFrame ​

Re-exports inFrame


isOfficer ​

Re-exports isOfficer


isProfileName ​

Re-exports isProfileName


listCrowd ​

Re-exports listCrowd


listCrowdDogs ​

Re-exports listCrowdDogs


listNpcs ​

Re-exports listNpcs


listSentries ​

Re-exports listSentries


listTraffic ​

Re-exports listTraffic


MAX_STARS ​

Re-exports MAX_STARS


NpcMode ​

Re-exports NpcMode


NpcPath ​

Re-exports NpcPath


NpcRoute ​

Re-exports NpcRoute


NpcState ​

Re-exports NpcState


phaseRank ​

Re-exports phaseRank


PHOTO ​

Re-exports PHOTO


POLICE ​

Re-exports POLICE


POLICE_RESPONSE ​

Re-exports POLICE_RESPONSE


policeProfile ​

Re-exports policeProfile


policeSystem ​

Re-exports policeSystem


PROFILE_NAMES ​

Re-exports PROFILE_NAMES


ProfileName ​

Re-exports ProfileName


PROFILES ​

Re-exports PROFILES


raceDistance ​

Re-exports raceDistance


RaceState ​

Re-exports RaceState


removeNpc ​

Re-exports removeNpc


resetPolice ​

Re-exports resetPolice


resetStealth ​

Re-exports resetStealth


RESTRICTED ​

Re-exports RESTRICTED


ROLE_MIX ​

Re-exports ROLE_MIX


RoleKind ​

Re-exports RoleKind


ROLES ​

Re-exports ROLES


rolesReadout ​

Re-exports rolesReadout


roleWeights ​

Re-exports roleWeights


roomAlert ​

Re-exports roomAlert


ROUTINE_MIX ​

Re-exports ROUTINE_MIX


ROUTINE_SHARE ​

Re-exports ROUTINE_SHARE


routineWeights ​

Re-exports routineWeights


RURAL_MIX ​

Re-exports RURAL_MIX


SCHEDULE ​

Re-exports SCHEDULE


ScheduleEntry ​

Re-exports ScheduleEntry


SENTRY ​

Re-exports SENTRY


setCrowd ​

Re-exports setCrowd


setPoliceSpawns ​

Re-exports setPoliceSpawns


setRestrictedZones ​

Re-exports setRestrictedZones


setTraffic ​

Re-exports setTraffic


setWantedStars ​

Re-exports setWantedStars


shopsOpen ​

Re-exports shopsOpen


signalOverrides ​

Re-exports signalOverrides


spawnChaser ​

Re-exports spawnChaser


spawnRole ​

Re-exports spawnRole


spawnSentry ​

Re-exports spawnSentry


spawnTrafficCar ​

Re-exports spawnTrafficCar


starsFor ​

Re-exports starsFor


startRace ​

Re-exports startRace


statsOf ​

Re-exports statsOf


STEALTH ​

Re-exports STEALTH


stealthReadout ​

Re-exports stealthReadout


stealthStats ​

Re-exports stealthStats


stealthView ​

Re-exports stealthView


switchSignal ​

Re-exports switchSignal


takeArrests ​

Re-exports takeArrests


TRAFFIC ​

Re-exports TRAFFIC


TrafficCar ​

Re-exports TrafficCar


trafficReadout ​

Re-exports trafficReadout


TrafficReadoutRow ​

Re-exports TrafficReadoutRow


TrafficWalker ​

Re-exports TrafficWalker


visibilityAt ​

Re-exports visibilityAt


WANTED ​

Re-exports WANTED


wantedView ​

Re-exports wantedView