Page 1 of 1
deterministic lockstep
Posted: Sun Mar 30, 2025 3:46 pm
by TheKillerChicken
I do not know if this is the right location, but I am curious why Factorio uses a deterministic lockstep setup. Was there not any other alternative, or is it due to how the engine handles everything?
Re: deterministic lockstep
Posted: Sun Mar 30, 2025 3:48 pm
by boskid
Because amount of state changes each tick is so large that multiplayer would not be feasible otherwise.
Re: deterministic lockstep
Posted: Sun Mar 30, 2025 3:52 pm
by TheKillerChicken
I see, now that makes sense. Thank you for this info.
Re: deterministic lockstep
Posted: Sun Mar 30, 2025 9:14 pm
by TheKillerChicken
Sorry, another question, is there a reason why the server/client must have the exact same data and CRCs?
Re: deterministic lockstep
Posted: Sun Mar 30, 2025 9:19 pm
by Loewchen
TheKillerChicken wrote: Sun Mar 30, 2025 9:14 pm
is there a reason why the server/client must have the exact same data and CRCs?
Otherwise you would not play the same game.
Re: deterministic lockstep
Posted: Sun Mar 30, 2025 9:32 pm
by MEOWMI
TheKillerChicken wrote: Sun Mar 30, 2025 9:14 pm
Sorry, another question, is there a reason why the server/client must have the exact same data and CRCs?
Once you have deterministic lockstep, the entire game can be simulated perfectly, without errors, and any remaining errors are due to existing errors in data or data corruption, and any one error will eventually cascade into completely different game states (read up on the butterfly effect if you're still unsure). Usually caused either by faulty starting data, faulty hardware, or by problems in data transmission during multiplayer. Any of them would be comparatively rare cases, but either way, at that point in program development, it's easily worthwhile to add checks to ensure that the data is and remains the same, considering that after that, you have nearly perfect multiplayer that just works.
Lockstep basically requires complete data integrity, so you implement checks for it if you are designing a game with lockstep in mind.
Re: deterministic lockstep
Posted: Mon Mar 31, 2025 3:17 am
by TheKillerChicken
MEOWMI wrote: Sun Mar 30, 2025 9:32 pm
TheKillerChicken wrote: Sun Mar 30, 2025 9:14 pm
Sorry, another question, is there a reason why the server/client must have the exact same data and CRCs?
Once you have deterministic lockstep, the entire game can be simulated perfectly, without errors, and any remaining errors are due to existing errors in data or data corruption, and any one error will eventually cascade into completely different game states (read up on the butterfly effect if you're still unsure). Usually caused either by faulty starting data, faulty hardware, or by problems in data transmission during multiplayer. Any of them would be comparatively rare cases, but either way, at that point in program development, it's easily worthwhile to add checks to ensure that the data is and remains the same, considering that after that, you have nearly perfect multiplayer that just works.
Lockstep basically requires complete data integrity, so you implement checks for it if you are designing a game with lockstep in mind.
Interesting. I did not know that. That solves that mystery for me.