> ## Content Index
> Fetch the complete content index at: https://simstructures.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Prison Architect Under the Hood: Needs-Based AI, Regime Scheduling & Grid Pathfinding
- URL: https://simstructures.com/prison-architect-under-the-hood/
- Published: 2026-09-01T15:29:34.000Z
- Updated: 2026-09-01T15:36:25.000Z
- Description: How Prison Architect runs a whole prison on Introversion's custom C++/OpenGL engine: needs-based utility AI gated by the daily Regime, an object-component world, staggered utility/need ticks, and room-partitioned grid A*.
- Author: ENGN GAME STUDIO LLC
- Tags: Prison Architect, Articles

### Engine & Tech Stack

- **Engine / language:** a custom in-house engine written in **C++** by Introversion Software, drawing 2D sprites through **OpenGL** — no third-party game engine.
- **Map representation:** a fixed **2D tile grid**; every cell carries terrain plus wall/floor material, an object reference, and parallel utility layers (electricity, water pipes).
- **Content & modding:** heavily data-driven — objects, materials, rooms and grants are declared in plain-text `.txt` config files, with **Lua** scripts loaded at startup for custom mod logic.

### Core AI & Decision Making

- **Architecture:** prisoner behavior is a [**needs-based utility model**](https://en.wikipedia.org/wiki/Utility%5Fsystem?ref=simstructures.com). Each prisoner tracks a vector of needs — sleep, food, hygiene, bladder, recreation, family, safety, comfort, freedom — that decay over time and bias which action looks most valuable.
- **Dispatch:** the current need set is filtered through the active **Regime**, the hour-by-hour schedule of Sleep / Eat / Work / Yard / Lockup blocks; the highest-pressure *legal* action for the current block wins. Staff and workmen instead pull from a shared **job queue** (construction, hauling, cleaning, guarding), each claiming the nearest available task.

### State Management & Data Architecture

- **Model:** object-oriented **entity + component** style rather than strict ECS. The world is a tree of managers (map, objects, utilities, deployment, intelligence/reports) owning collections of entities; each entity — prisoner, guard, door, object — holds its own state and component data.
- **Updates:** systems advance their own entities each step and communicate through **events/reports** (incidents, needs alerts, contraband) that surface on the deployment and intelligence screens.

### Tick Scheduling & Performance Tricks

- **Staggered work:** cheap logic (movement, immediate needs) runs often, while expensive simulations — utility propagation (power/water), temperature, need decay, reports — update on **slower macro passes** rather than every visual frame.
- **Why it scales:** batching per-tile propagation and spreading entity AI across ticks keeps hundreds of prisoners and thousands of utility tiles from all updating in one frame; the game-speed control multiplies steps per frame, not the interval.

### Pathfinding & Spatial Systems

- **Algorithm:** grid **A\*** over the tile map — a long-standing hotspot Introversion repeatedly optimized with path caching and threaded path requests.
- **Spatial partitioning:** the map is carved into **rooms/sectors** bounded by walls and doors, giving fast reachability and "nearest room of type" lookups and pruning A\* to relevant areas. The cost matrix weights walls, doors (including staff-only access) and floor material.