See all glossary terms

Deterministic simulation

A deterministic simulation is a simulation that produces the same results every time it is run with the same initial conditions. In other words, if you run the simulation twice with the same inputs, you should get the same outputs.
In games, deterministic simulations are essential for online multiplayer, where there are slight delays in what each player sees because it takes time for the network to send inputs between players. The game simulation must be deterministic to ensure consistency when players receive inputs from other players.
Note that Godot, like most game engines, is not deterministic. Calculations with floating-point numbers, which are used for most things in a game engine under the hood, can produce slightly different results on different platforms or with different compiler settings. The differences can be tiny, but when your game uses physics, the tiniest differences can lead to major differences in the game state. Godot's physics engine extensively uses floating-point numbers, so it is unsuitable for deterministic simulation.
However, Godot provides tools to help you make your game simulation deterministic. You can use different physics engines as a plugin, like SG Physics 2D or Jolt Physics for 3D. Be sure to read their documentation to understand how they work and the limitations you face with deterministic simulation.
You also need to write a lot of your own code using fixed-point math to ensure that your game is deterministic. In Godot, you can use the Vector2i, Vector3i, and PackedInt64Array classes to always work with whole numbers, which are not subject to floating-point errors.