Runtime
Architectural Blueprint for Offscreen Simulation and Deterministic Movement of Persistent NPCs
Report summary
The integration of persistent, linguistically capable Non-Player Characters into a multiplayer escape room environment represents a complex convergence of deterministic spatial simulation and stochastic cognitive generation. The fundamental architectural challenge lies in respecting the rigid owners
Key topics
- Runtime
- AI
- Privacy
- Physics
- Strategy
- Audit
- Architecture
- Governance
Research provenance
For citation, use the report title and canonical URL. Archival presence does not establish authorship or promote report statements into portfolio evidence.
This page renders the archived Markdown as safe, formatted HTML. It is background research and does not become a portfolio claim without evidence review.
Full report
On this page
Executive Recommendation and Architectural Philosophy
The integration of persistent, linguistically capable Non-Player Characters into a multiplayer escape room environment represents a complex convergence of deterministic spatial simulation and stochastic cognitive generation. The fundamental architectural challenge lies in respecting the rigid ownership boundaries established by the system design: the physical game space, puzzle states, room occupancy, and legal routing are the absolute domain of the primary game server, while cognitive identity, naming, and memory retrieval belong to external microservices. Based on these infrastructural constraints, the system must adopt a rigid "Simulation Level of Detail" paradigm coupled with a Model-View-Controller routing architecture. The primary recommendation is to deploy a deterministic-first, model-assisted framework. Under this paradigm, agents operate on a deterministic Finite State Machine blended with hierarchical Behavior Trees to govern their spatial movement and routine actions. Generative model calls to external cognitive APIs are strictly reserved for observed social interaction and high-level intention setting. To optimize computational load and eliminate unnecessary application programming interface expenditures, when a physical room registers zero human participants, the entities within that spatial volume must instantly drop to a dormant, offscreen mathematical simulation layer. In this layer, rendering, collision physics, and cognitive API calls are entirely suspended, and movement is calculated utilizing temporal displacement mathematics along pre-calculated navigation graphs. Furthermore, the integrity of the puzzle environment demands a policy of zero-authorization for independent puzzle resolution. Permitting an external behavioral model to alter authoritative puzzle states risks breaking human progression, bypassing authored locks, and corrupting the state machine managed by the authoritative server. Model-proposed intentions must always submit to the game’s physical routing engine; if an external model generates an intention to traverse through a locked door, the game engine must reject the request unconditionally, forcing the deterministic fallback behavior to execute. This ensures complete physical compliance, eliminates offscreen surprises, minimizes remote processing costs, and maintains the strict obfuscation of the entity's controller type, preserving the illusion that any participant could be either human or artificial.
The Separation of Ownership and Controller Routing
The operational stability of this architecture relies on a strict demarcation of ownership across the three primary domains. The primary game server retains exclusive authority over player accounts, anonymous sessions, gameplay states, room occupancy, legal movement, doors, locks, puzzles, and the lifecycle of each active game. External services are treated as untrusted clients requesting read access to the environment or proposing actions that must be strictly validated. The entity memories are the exclusive domain of an external memory endpoint system. The game server does not own the identities; it merely hosts their physical manifestations for the duration of the active game. When a game concludes, the physical avatars are destroyed, but the external memory service retains the approved social and general interactions. Similarly, the canonical identity nomenclature—specifically the exact first, middle, and last names—is strictly supplied by a dedicated external artificial intelligence naming service. To satisfy the requirement that participant records never disclose or confirm whether a participant is human-controlled or generated, the architecture must utilize a polymorphic controller routing design. Both human client inputs and artificial intelligence outputs must be piped into the exact same command queue on the server, formatted as identical, protocol-agnostic events. By routing all commands through a unified controller interface, the system ensures that downstream logic, audit logs, and client-side rendering engines possess no awareness of the command's origin. Behavioral inference by players may remain uncertain, but the underlying system architecture guarantees that the controller type is never explicitly serialized, broadcasted, or exposed through asymmetric logging structures.
Compact Entity Location and Activation State Machine
The behavioral lifecycle of a non-player entity is governed by a hierarchical state machine that distinctly separates authoritative physical location from visible activation and conversational availability. The system operates under a strict constraint: a maximum persistent roster of ten non-player identities per active game, with no more than six active entities permitted in a single room simultaneously. This physical capacity limit necessitates a state machine capable of aggressive resource culling, load balancing, and spatial distribution. The Finite State Machine is structured across four primary macroscopic states. These states dictate the simulation fidelity of the entity at any given server tick, balancing computational overhead against the necessary illusion of continuous existence.
| State Identifier | Human Presence Requirement | Physics and Collision | Conversational Availability | Movement Mechanism | Generative API Calls |
|---|---|---|---|---|---|
| ACTIVE\_ENGAGED | Greater than zero | Enabled | Active (Listening and Typing) | NavMesh Agent / Local Steering | Permitted (Triggered by text) |
| ACTIVE\_BACKGROUND | Greater than zero | Enabled | Standby | NavMesh Agent / Behavior Tree | Restricted to intention setting |
| TRANSIT\_OFFSCREEN | Exactly zero | Disabled | Unavailable | Graph-based Mathematical Simulation | Strictly Prohibited |
| DORMANT\_OFFSCREEN | Exactly zero | Disabled | Unavailable | Stationary (Suspended) | Strictly Prohibited |
State Transitions and Environmental Triggers
The transitions between these states are governed entirely by environmental sensors managed by the primary game server, specifically tied to room occupancy and direct player interaction. The transition from a dormant offscreen state to an active background state is triggered the moment a human participant crosses a portal or door threshold into a room containing a dormant entity. The primary server intercepts the room occupancy change, instantly localizing the entity to its last recorded authoritative coordinate. The physical capsule is instantiated, collision bounds are enabled, and the state machine initializes a localized wander or idle animation loop. Because the entity's state survived the period of human absence, its continuity is preserved perfectly upon the player's arrival. When a human participant explicitly addresses the entity, either by utilizing their exact full name or by generating proximity-based text events, the entity transitions into the active engaged state. The entity halts its ambient patrol path and orients toward the human. The controller routes the typed text to the external cognitive model to generate a response. This engaged state is maintained until a conversational timeout occurs, or until the entity's internal utility score dictates that fulfilling a previously scheduled destination supersedes the current social interaction. Upon either condition, the entity reverts to the active background state. The transition to the offscreen transit state is triggered precisely when the final human leaves a room. The primary server executes an immediate culling operation, destroying the physical meshes and colliders of all entities within that room to reclaim processing resources. If an entity possessed an active pathing request at the moment of culling, that request is seamlessly translated into a target node on the global navigation graph, initiating the mathematical simulation phase.
The Mathematics of Offscreen Continuity
When an entity enters the offscreen transit state, it utilizes a decoupled artificial life simulation approach to traverse the game world. Rather than running heavy pathfinding computations every frame, the engine calculates the total distance to the target node along the shortest valid path on the global navigation graph. This calculation utilizes Dijkstra's algorithm or an A\* search heuristic. The server calculates the estimated arrival time utilizing the fundamental kinematic equation: [Figure omitted from source export] Where [Figure omitted from source export] represents the total distance of the approved route, and [Figure omitted from source export] represents the entity's defined base walking speed. The server places the entity into a lightweight priority queue. When the global server time surpasses the calculated arrival time, the entity's authoritative location is instantly updated to the destination room, and it transitions into the dormant offscreen state. If a human enters the destination room or the transit corridor while the entity is in mid-transit, the server interpolates the entity's current position along the path based on the elapsed time percentage, instantly instantiating their physical avatar mid-stride to preserve the illusion of continuous travel.
Movement Admission Rules and Numerical Timing Defaults
To ensure that non-player entities respect the exact same legal world rules as human players, all movement intentions—whether generated by deterministic schedules or by external generative models—must pass through an admission gateway. This gateway acts as a strict validator, ensuring that no entity can bypass authored physical constraints.
The Validation Gateway Process
The validation process begins when the entity's state machine generates an intention to move to a specific destination. The server queries the global navigation graph to establish a theoretical route. The pathfinder then evaluates the edges between the navigational nodes. If an edge represents a mechanical or puzzle-locked door, the system queries the authoritative state of that object. If the door is locked, and the entity lacks the specific permission tag to bypass it, the algorithmic weight of that edge is set to infinity, rendering the path impassable. If the path is successfully validated, the intention is approved. The entity begins traversing the local navigation mesh if they are currently onscreen, or begins the time-step calculation if they are operating in the offscreen layer. Conversely, if the admission gateway returns a failure code indicating an unreachable path, the entity's behavior tree intercepts this event. The tree must then trigger a deterministic fallback node, such as loitering near the impassable barrier, selecting a secondary utility target within the current room, or returning to their point of origin.
Capacity Enforcement and Room Limits
The physical policy mandates a maximum of six active non-player entities per room. This rule requires strict algorithmic enforcement at the gateway level. Before any path is validated, the gateway checks the current and projected occupancy of the destination room. If the room already contains six entities, any external entity attempting to route into that room is temporarily held in a neighboring node's dormant state. This queuing mechanism prevents overcrowding and ensures that the physical rendering budget and social dynamics of the space remain balanced. Human attendance is not capped by this policy, meaning players can flood a room, but the system will actively prevent artificial entities from exacerbating the congestion.
Numerical Timing Limits
To prevent the authoritative server from becoming computationally bound by continuous path recalculations or micro-movements, strict numerical timing limits are enforced across all entity layers.
| Parameter | Defined Limit | Architectural Rationale |
|---|---|---|
| Offscreen Tick Rate | 0.1 Hz (Once every 10 seconds) | Eliminates per-frame processing for entities in empty rooms, freeing CPU cycles for physics validation in populated areas. |
| Onscreen Path Recalculation | Maximum 1 per 1.5 seconds per entity | Prevents thrashing if the physical environment changes rapidly or if human players block narrow corridors. |
| Pathfinding Exponential Backoff | 5s, then 10s, 20s, up to 60s max | Prevents the system from continuously attempting to route through newly locked doors, forcing the entity to abandon impossible paths. |
| Conversational Cooldown | 15 seconds post-interaction | Ensures the entity lingers naturally after a chat, preventing abrupt, robotic departures immediately after sending a text. |
Routing and Transition Case Studies
The following scenarios illustrate how the hybrid architecture handles various topological conditions, social interactions, and physical constraints while strictly adhering to the division of ownership between the game engine and the cognitive programming.
Scenario A: The Deterministic Normal Route
An entity is currently located in the central foyer alongside two human participants. The deterministic schedule within the entity's behavior tree dictates that at a specific virtual time, the entity should relocate to the adjacent conservatory. The behavior tree evaluates the chronological condition and generates an intention to move to the center of the conservatory. The admission gateway intercepts this intention and checks the global navigation graph. The doors connecting the foyer to the conservatory are verified as open, and the path is deemed valid. The entity transitions into the active background state, and the local navigation mesh agent is assigned the path coordinates. The entity physically walks across the room, utilizing reciprocal velocity obstacles and local steering behaviors to dynamically avoid the human players standing in its way. Upon reaching the conservatory, the behavior tree switches to an idle patrol sequence. Throughout this entire sequence, zero generative model calls were executed, ensuring cost-free, flawless physical compliance.
Scenario B: The Model-Proposed Locked Route
An entity is engaged in a text-based conversation with a human in a hallway. The human participant types a request, asking the entity to check if the vault door at the end of the corridor is open. This text is routed through the controller to the external cognitive model. The model generates a conversational response indicating compliance and outputs a structured tool-call requesting navigation to the vault. The admission gateway receives this programmatic intention and attempts to calculate the path. However, the gateway identifies that the vault door is currently locked by an unsolved puzzle. The entity does not possess the requisite state completion variables to open it. Consequently, the pathfinder returns an unreachable failure code to the entity's state machine. Because the intention was directly prompted by a user interaction, the behavior tree catches the failure and triggers a secondary, context-aware generative text request. The entity outputs a response indicating that the door appears to be locked and they cannot gain entry. The entity remains in the hallway, completely preserving the integrity of the puzzle environment while providing a highly believable narrative justification for their physical limitation.
Scenario C: The Culling of a No-Human Room
A large library room contains four non-player entities and one human player. The human player exits the room and closes the door. The primary server's occupancy sensor immediately registers that the human count has dropped to zero. An interrupt signal is instantly dispatched to the four entities within the library. The entities immediately halt their local navigation agents. Their physical avatars, skeletal meshes, and animations are immediately culled from the rendering pipeline and the physics engine. They transition into the dormant offscreen state. Two of the entities had active movement intentions to cross the library to examine a bookshelf. These local physical intentions are converted into virtual mathematics. The system calculates that crossing the room takes approximately twelve seconds. It schedules an asynchronous event twelve seconds in the future to update their authoritative spatial coordinates to the other side of the room. For the entire duration the library remains empty of humans, no pathfinding, collision detection, or generative model calls are executed for these four entities, dropping their computational footprint to near zero.
Scenario D: Front Desk Invitation and Naming Integration
A human player arrives at the designated front desk area of the game space and interacts with the interface, requesting to visit a specific entity. The player types the exact full name of the requested character. The primary server intercepts this request and queries the external naming service provided by the artificial intelligence partner. The naming service verifies the canonical first, middle, and last name against the persistent roster of ten active identities for that specific game instance. Upon positive verification, the server generates a high-priority, deterministic routing override. The requested entity, regardless of whether it is currently idling in a populated room or operating in the dormant offscreen layer, has its current behavior tree suspended. The admission gateway plots an immediate, legal path from the entity's current authoritative location to the front desk. If the entity is offscreen, it travels via mathematical simulation until it breaches the threshold of the front desk room, at which point it physically manifests and walks to the counter to greet the requesting player. This mechanic seamlessly integrates the external identity service with the authoritative physical routing engine.
Text Interaction, Messaging Bus, and Controller Obfuscation
The social interface of the environment relies exclusively on typed in-game text, demanding a messaging architecture that supports natural communication without revealing the underlying nature of the participants. Human-to-human voice features remain strictly opt-in and are explicitly isolated from the entity processing pipeline; player audio is never sent to a transcription service, ensuring total compliance with privacy and simulation constraints. When any participant—human or artificial—submits a text message, it is published to a unified room-based message bus. Public room text remains visible to everyone present in the exact same chronological order. The initial release does not utilize spatial distance to hide or reorder text, ensuring that the conversational timeline is universally consistent for all occupants. To facilitate natural targeting in crowded rooms, the system allows for direct addressees to receive visual emphasis on their clients. When an entity intends to speak directly to a player, the output payload includes a target identifier. The rendering client of the targeted player applies typographical emphasis to the message, while all other players see the message normally in the public stream. Crucially, the server processes incoming text payloads through identical pipelines. Whether a string of text originates from a human keyboard or an external language model API, it enters the command queue wrapped in the exact same polymorphic event structure. This ensures that no metadata, packet timing irregularities, or structural telltales can be intercepted by client software to deduce the controller type.
Puzzle Resolution Authority and Environmental Permissions
Addressing the specific inquiry regarding whether non-player entities should ever solve puzzles independently, the architectural recommendation is an absolute prohibition. Entities must operate with zero authorization to alter puzzle states, consume critical inventory objects, or bypass logic gates. The fundamental design of an escape room relies on human agency to progress the state machine. If an artificial entity were permitted to solve a puzzle, it would require write-access permissions to the authoritative game state. This introduces catastrophic risks to the gameplay loop. An entity operating offscreen could theoretically solve a sequential puzzle, unlocking doors and triggering environmental changes while the human players are entirely unaware, resulting in deep player frustration and a disjointed narrative experience. Furthermore, granting entities puzzle-solving capabilities requires the generative model to perfectly comprehend the spatial and logical constraints of complex, bespoke environmental puzzles—a task current language models cannot perform reliably without extensive, computationally expensive spatial context injection. By restricting entities to read-only permissions regarding puzzle states, the architecture guarantees that human players remain the sole drivers of progression. Entities may observe the state of a puzzle and offer pre-approved, contextually relevant commentary generated from their memory, but they remain strictly incapable of altering the mathematical state of the lock.
Ten Believability and Gameplay Failure Modes with Mitigations
Integrating artificial behaviors into rigid spatial environments traditionally yields severe edge cases. The following ten failure modes have been anticipated, alongside architectural mitigations designed to maintain the illusion of life and the integrity of the game space.
| Failure Mode | Description of the Risk | Architectural Mitigation Strategy |
|---|---|---|
| 1\. Teleportation | Entities moving offscreen transition between rooms instantly, arriving faster than humanly possible. | Offscreen movement relies on strict mathematical enforcement of velocity. Entities cannot arrive at a destination node until the precise temporal duration of the walk has elapsed. |
| 2\. Omniscience | An entity infers the location of a human or puzzle state on the other side of the map. | Context injection is strictly localized. The cognitive API only receives data from the entity's immediate room occupancy array and personal event history. |
| 3\. Crowd Oscillation | Multiple entities attempting to navigate a narrow door result in jittering and perpetual path recalculation. | Implementation of Reciprocal Velocity Obstacles for dynamic avoidance, paired with a strict queuing system at choke points. |
| 4\. Swarm Behavior | All ten entities decide to follow a single human player, violating room limits and crowding the player. | Implementation of a Utility Decay function regarding social interest, hard-capped by the strict six-entity admission limit per room. |
| 5\. Object Consumption | An entity picks up a critical puzzle item and wanders offscreen, soft-locking the game. | Strict item taxonomy. Entities are physically prohibited from interacting with or altering the inventory state of items tagged as critical puzzle components. |
| 6\. Corridor Deadlocks | Two entities walking in opposite directions meet in a narrow hallway and freeze permanently. | Yielding hierarchies based on hidden integer IDs. The entity with the lower ID reverses to a pre-authored passing node to yield the right of way. |
| 7\. Offscreen Surprises | An offscreen entity triggers a trap or alters the environment while humans are elsewhere. | Offscreen entities are completely stripped of environmental write-permissions, limited exclusively to updating their own spatial coordinates. |
| 8\. Asymmetric Logging | Audit logs or network traffic definitively prove which characters are human and which are artificial. | Implementation of obfuscated controller routing. All entities generate identical spatial and interaction packets, stripping all boolean flags regarding controller origin. |
| 9\. Locked-Door Looping | An entity repeatedly tries to path through a locked door, failing and retrying in an endless, robotic loop. | Application of Exponential Backoff. Failed paths blacklist the destination for escalating time periods, forcing the entity to select alternative behavior. |
| 10\. Flash Mobs | Deterministic schedules cause all entities to change their behavior on the exact same server tick. | Schedule fuzzing. Deterministic triggers are offset by randomized float delays, ensuring organic, staggered transitions across the population. |
Multi-Tenant Memory Isolation and Continuity
Because multiple participants may interact with the exact same non-player identity concurrently across different active games and at different times, the storage and retrieval of memory introduces severe risks of cross-contamination. Game-specific clues must never leak across instances, yet the entity must maintain a cohesive personality and approved social memories across encounters. This necessitates a strict multi-tenant data isolation architecture managed in tandem with the external memory endpoint service. Memory is fundamentally bifurcated into two distinct vectors: global persona memory and session-scoped game memory. Global persona memory contains static truths regarding the entity's background, preferences, and approved social traits. Session-scoped memory contains the dynamic interactions, observed puzzle states, and specific human relationships forged entirely within the bounds of a single active game instance. When the authoritative server initiates a request to the external cognitive model, it injects a cryptographic Session ID. The external memory database must utilize Row-Level Security policies tied explicitly to this Session ID. When the model queries the vector database for relevant context to formulate a reply, the database restricts the return payload to global traits and the specific rows matching the active game's Session ID. This guarantees that an entity in one game instance cannot recall or leak that a player in an entirely separate instance successfully deduced the combination to the vault. When no human is present in a room and the entity enters dormancy, the session-scoped memory is preserved perfectly. Rather than destroying and recreating the entity, the primary server simply halts the active processing, while the memory endpoint retains the conversational graph, ready to seamlessly resume when a human re-enters the space.
Phased Deployment: Cost-Free MVP to Model-Assisted Enhancements
To minimize initial development risk, establish a stable baseline, and control generative API expenditures, the system architecture should be deployed across two distinct phases: a deterministic Minimum Viable Product, followed by a model-assisted enhancement layer.
Phase 1: The Deterministic Minimum Viable Product
The initial release relies entirely on classical game artificial intelligence techniques, ensuring zero API costs for movement and spatial behavior. Each of the ten entities is assigned a predefined chronological routine governed by a rigid behavior tree. When an entity reaches its scheduled destination, it utilizes a random-waypoint selection system to move naturally between authored points of interest within that room. During this phase, the external cognitive models are invoked strictly when a human player types a direct message to the entity. If not explicitly addressed, the entity operates entirely on computationally inexpensive, localized logic. This approach guarantees systemic stability, ensures no unpredictable offscreen surprises, and scales efficiently to thousands of concurrent game instances with negligible central processor overhead.
Phase 2: Model-Assisted Enhancements
Once the deterministic baseline proves stable, the cognitive models can be granted limited read-access to the environment to propose high-level intentions. Instead of a rigid chronological schedule, the model is periodically prompted with the entity's recent memory and the current state of populated rooms. The model returns a structured JSON payload proposing an intention and a target room. The deterministic routing gateway receives this intention. If the target room is accessible and under the physical capacity limit, the gateway approves the route. If the room is locked or over capacity, the deterministic router overrides the model, forcing the entity into an idle state and silently dropping the generative request. To maintain cost control, model-assisted intentions are strictly limited to entities that are currently in an active state within a populated room; offscreen entities remain governed purely by their deterministic schedules until a human player interrupts them.
Required Audit Events and Controller Obfuscation
The project mandate dictates that participant records must never disclose or confirm the controller type of any entity. Traditional architectures log artificial actions differently than human actions, creating a critical vulnerability if audit logs are ever exposed, parsed, or utilized for behavioral inference. To mitigate this, the logging infrastructure must carefully obscure the origin of commands through a unified schema. The system adopts a Chain of Responsibility design pattern to process all spatial and interaction events. When a movement occurs, it is logged with a universal Entity ID, completely devoid of distinguishing boolean flags.
Obfuscated Audit Event Schema
| Log Field | Description | Architectural Function |
|---|---|---|
| timestamp | ISO-8601 formatted time | Establishes chronological order of events across the game instance. |
| event\_id | Unique cryptographic hash | Prevents log collision and allows for precise auditing of specific actions. |
| entity\_id | Universal opaque identifier | Strips all human/AI distinction. Maps only to a generic actor in the database. |
| action\_type | Categorical classification | Identifies the nature of the action (e.g., SPATIAL\_TRANSLATION, TEXT\_SUBMISSION). |
| parameters | JSON blob of action details | Contains origin nodes, destination nodes, or the raw string of submitted text. |
| authorization | Gateway validation stamp | Confirms the action passed the primary server's legal routing checks. |
If a human player queries the system—such as asking the front desk where a specific entity went—the system requires a mechanism to look up that entity's location without confirming their artificial nature. The query service performs a database lookup on the specific entity\_id and retrieves the last known destination node from the audit log. The system then outputs standard text indicating the last known trajectory. Because humans and artificial entities generate the exact same spatial translation events in the logs, the explanation mechanism functions identically regardless of whether the queried entity is a generative model executing a path or a human player walking away from the keyboard. This ensures total systemic compliance with the obfuscation mandate while preserving a highly immersive, responsive, and legally sound physical simulation.