The Simulation Engine

The "Tick" Cycle

The heart of SynCity is the Game Loop, often referred to as the "Tick." Unlike standard web apps that wait for user input, the simulation updates itself continuously.

The Loop Logic:

  1. Delta Time Calculation: The engine calculates the time difference between the current frame and the last frame.

  2. Update Phase: The system iterates through every active entity (Agents, Buildings).

    • Agents update their position and needs.

    • Buildings consume resources and produce goods.

    • Economy updates tax collections (if a day has passed).

  3. Render Phase: The visual representation is drawn based on the new data.

Time Management

The simulation time is decoupled from real time.

  • 1 Tick: Represents the smallest unit of logic update (e.g., 100ms).

  • Day/Night Cycle: A configurable number of ticks constitutes a "Game Day."

Time Acceleration

Players can control the speed of the simulation (1x, 2x, 5x).

  • Implementation: We apply a multiplier to the Delta Time variable passed into the update functions.

  • Performance Note: At high speeds (e.g., 10x), the visual interpolation of agent movement is disabled to save CPU resources, focusing purely on the mathematical calculation of the economy and simulation.

Last updated