Skip to content

Instantly share code, notes, and snippets.

View Uriopass's full-sized avatar

Pâris DOUADY Uriopass

View GitHub Profile
@felko
felko / adt.py
Last active April 1, 2020 18:26
#!/usr/bin/env python3.7
# coding: utf-8
import types
import functools
import abc
import typing
from contextlib import contextmanager
from collections import OrderedDict

Deterministic save load in Factorio

One of the key parts of the save/load process in Factorio is that it must be deterministic. This means that for a given save file (when no external factors change) saving, exiting, and loading the save shouldn't change any observable behavior.

There are a few reasons and benefits for this strict requirement:

  • Without it: You couldn't join a running multiplayer game (and by proxy save, exit, and resume one)
  • Without it: the replay system wouldn't work if you ever saved, exited, and resumed playing.
  • With it: we can easily test that saving and loading produces no observable change letting us know we implemented save/load correctly.
  • With it: you won't see things change randomly as a result of "reloading" like you do in so many other games.