Great question! What you’re describing—world persistence and NPCs evolving over time across a large open world—is a complex challenge for game developers, especially given hardware and performance limitations. The key insight is that these systems are almost never fully simulated in real-time or fully loaded into memory at all times. Instead, game worlds use clever approximations, state-saving, and partial simulation techniques to balance immersion with performance.
Here’s a breakdown of how this typically works under the hood:
1. State Persistence Without Full Simulation
-
Saving the "Snapshot"
When the player leaves an area, the game records (saves) the important state of objects and NPCs there. For example:
- The flipped car’s position and orientation
- NPC’s health, hunger, inventory, current quest state, etc.
-
Unloading the Area
Once outside a certain range, the game “unloads” the area, freeing up memory and CPU time by no longer simulating or rendering those objects.
-
Reloading the Snapshot
If the player returns to that location, the game reloads the last saved state—so the car stays flipped, NPCs keep their last recorded stats.
This accounts for persistence in a “static sense” but does not explain how NPCs or world state progresses when you're not actively nearby.
2. Background or Time-Lapse Simulation
-
Simplified Time Progression
Many games perform a simplified simulation or time-lapse update to the world state when you return or enter a new area after a long absence. This might happen instantaneously during loading screens or background processes. For example:
- The NPC eats and reduces hunger according to how much in-game time has passed
- They travel from town A to town B based on planned schedules or probability distributions
- Their resources or injury state updates according to simplified rules
-
Limited Simulation Detail
This is much cheaper because the game:
- Doesn’t simulate every step or animation of movement or actions but jumps directly to the expected result (e.g., NPC moved 10 km east over 10 hours)
- Uses randomized or deterministic logic instead of full AI/pathfinding for every step
- Ignores interactions that aren’t relevant (e.g., NPCs don’t fight or interact unless player is nearby)
3. Zones and Instancing
- The world is partitioned into zones or cells. Only zones near the player are fully active/simulated/rendered. Other zones are either completely “frozen” or progress with the simplified logic mentioned above.
4. Event-Driven or Goal-Driven AI
- NPC behavior is often goal-driven or event-driven. For example, an NPC might have a “daily routine” or travel plan governed by:
- A schedule (e.g., goes to market at 9 AM, returns home at 5 PM)
- A decision tree or utility function that determines “where would I be now if the player is not around?”
When the player approaches, the NPC’s state is “fast-forwarded” to where it should be in time, consistent with the routine.
5. Record Keeping and Delta Compression
-
The game doesn’t record every property of every NPC every frame. Instead, it records changes to important variables at certain events or intervals ("deltas").
-
Persistent saves are often compressed and optimized to only include relevant details.
Summary Example
Imagine you flipped a car at 10 AM and walked away:
-
At 10:05 AM (game time), the game saves the car’s flipped position in the state file. The physics simulation for that car stops when you're out of range.
-
After 100 hours of in-game time, you return:
-
The world loads the saved flipped car data; since no simulation changes its position, it’s still flipped.
-
Nearby NPCs might have been updated by a quick time-lapse simulation:
- NPC1 traveled from town A to town B according to their scripted routine
- NPC2 got hungry and ate some food, updated stats accordingly.
Real-World Examples
-
Skyrim saves NPC states and uses an “event-based” system where NPCs have routines and get updated when the player is nearby.
-
Red Dead Redemption 2 uses complex world streaming and AI scheduling, along with time compression when you fast travel or exit and re-enter areas.
-
The Sims uses “background simulation” when the player isn’t controlling Sims, then loads full simulation when in their vicinity.
Summary
Persistent large worlds are managed with a hybrid of partial state saving, zone-based loading/unloading, and simplified background simulation (time-lapse updating), rather than fully simulating everything constantly.
If you want, I can also offer some example code/models of a simplified version of such a system or recommend some resources to dig into game architecture and simulation design.