factorio optimization thoughts - is it even deterministic?
Posted: Mon Aug 31, 2026 7:32 am
playing factorio and hearing how well it is allegedly optimized, had me wonder many times about whether one huge potential for optimization has been used or not, now hear me out, this might be a silly idea given that I am not a programmer.
my assumption is that every game has to be calculated, and since it is all calculated, there is only one outcome, and given no user input, the game should always arrive at the same outcome given its inputs, I call this deterministic calculation, it's what I generally synonymize with computing.
but designing space ships and watching frames drops from all the asteroids made me wonder about one thing: does the engine of factorio actually calculate space ships and asteroids, or only when I am looking? how could the game get away by not calculating space ships when not looking? well, when not looking, there is no user input, so no live input variables which make time sensitive calculations necessary. furthermore a spaceship, like any subfactory, is a set of given variables to the engine and thus the cpu it runs on, which means why not skip the whole calculation, and merely guess the outcome given the known input variables?
now what do I mean by guessing in comparison to actual computation? well you know a set of fixed variables, like how many asteroids will come per timeframe, how many rocket towers you have on your space ship, you merely calculate the probability of anything hitting your ship, and if you defenses are good, and the probability is 0, why calculate asteroids at all, especially if you also know how many grabbing arms you put on the space ship, so you can guess how many chunks it will collect on average etc etc.
I call this probabilistic computing.
so here we have two terms, one is deterministic computing, the other is probabilistic computing. I guess most games have to run actual computing (deterministic ones) especially fps shooters as live input is crucial, and the engine has to directly respond to live user input. it can never guess what you will do next, it will have to update the whole engine and all of its variables every tick.
but factorio? especially space ships? hell no they don't have to be calculated deterministically, right? I guess one could save 99% of cpu, if not 99.9% or even 99.99% given this approach. now the big question: does factorio already do this? does factorio already not process factories or space ships, when I am not looking or when I am not there with the engineer to potentially mess things up?
what about biters? the game knows how they work, how they attack, their properties etc etc. if the game knows all this, and I am not looking, maybe working on a base on fulgora, does the game actually calculate biter attacks which to me have no random outcomes anyways, but expectable ones, and if so, why calculate them in detail, why not calculate them probabilistically?
does the game engine really update everything on every surface every tick? or does factorio skip the calculating for things that do not need to be calculated, but can rather be (close to) accurately guessed given the non-changing nature of a set of already known variables, i.e. guessing based on already known probabilities?
is the factorio engine actually already guessing or not? if not, what a huge performance improvement it could gain from stopping to calculate things which can be approximated instead (with the same outcome of course, in the long run)
what do I mean by "with the same outcome in the long run"?
well does it really matter if you calculate every variable of a system (like a spaceship or a subfactory) every 60th of a second, and you end up with x amount of legendary plates, or you guess the same outcome instead? you will end up with the same outcome, except in one scenario the CPU knows cause it computed this outcome and tracked its progress for every tick in the game, and in the other scenario it just gives you the legendary plates cause it knows "I would have gotten 256 leg plates if I had done the work given the variables in front of me". how does it know? it looks at the variables, checks inputs and outputs, knows this setup will yield x amount of leg plates, and then just updates the user account with x amount of legendary plates instead of actually "producing" them in a factory, which takes way more cpu.
idk, am I tripping balls here, am I missing something basic in computing? are my questions silly or stupid? and if not, is factorio already doing exactly this, or something very similar?
it all boils down to
TLDR: does factorio's engine, as part of extensive optimizations, sometimes or most of the time skip calculating the whole multi-planet world, and go over to guessing outcomes/outputs, instead of actually calculating every tick of its production lines?
this question came up way too many times while playing factorio for me not to finally mention it on here.
what this means if I am on to something here: 99.9% performance improvements for megabases. if the game does not need to calculate bases anymore, cause it knows all the values beforehand, it can merely simulate it. the only surface it would actually need to calculate, would be the one you are currently on, and you could be sitting on an empty spaceship while doing everything in remote view, or doing nothing at all.
to me the idea is fascinating. belts would not have to be calculated anymore, neither inserters. you just check the probabilistic algo for how much stuff goes on this belt on average, how much will the miners produce on average, how much input diminishes on average cause an ore patch gets depleted, how fast does it get depleted on average, greate functions and variables about this autimatically, use them to approximate the outcome 99.99% accurately compared to the computed version of game reality.
I'd take 99.99% accuracy with this probabilistic method over 100% accuracy but with 99% worse processed performance any day. what about you? if your calculated game gives you 1000 plates for running your perfectly designed factory, but in my game, you only get 999plates, cause the guesstimation algo is not 100% accurate, but you can build your base 100x bigger, say 100 million spm megabase with 60 ups on average cpu easy.
what would you pick? I'd pick the 999 plates every day of the week.
do you need your game to actually be deterministic or probabilistic?
am I talking nonsense? looking forward for a good discussion. would also me nice if the game makers could chime in on this, or at least point to some FFF about this, it is has been addressed before. I a way I can't believe a heavily optimized game which mostly runs without immediate user input (every surface you are not watching or moving on) is actually updated every tick of a second, instead of summarized to a known set of non-changing variables, and this formula being updated until the user might change something about this forumla (i.e. live user input) at which point the guessing needs to stop and the calculating needs to kick in again.
is this switching even possible? if so, it would be so nice to know it is happening in the background. if not, we'll see 100m+ spm megabases if it gets implemented. basically you calculate what you see, and what you might change within about a second as a user, and all of the rest you estimate or guess, and the guessing will be good enough so nobody would notice.
my assumption is that every game has to be calculated, and since it is all calculated, there is only one outcome, and given no user input, the game should always arrive at the same outcome given its inputs, I call this deterministic calculation, it's what I generally synonymize with computing.
but designing space ships and watching frames drops from all the asteroids made me wonder about one thing: does the engine of factorio actually calculate space ships and asteroids, or only when I am looking? how could the game get away by not calculating space ships when not looking? well, when not looking, there is no user input, so no live input variables which make time sensitive calculations necessary. furthermore a spaceship, like any subfactory, is a set of given variables to the engine and thus the cpu it runs on, which means why not skip the whole calculation, and merely guess the outcome given the known input variables?
now what do I mean by guessing in comparison to actual computation? well you know a set of fixed variables, like how many asteroids will come per timeframe, how many rocket towers you have on your space ship, you merely calculate the probability of anything hitting your ship, and if you defenses are good, and the probability is 0, why calculate asteroids at all, especially if you also know how many grabbing arms you put on the space ship, so you can guess how many chunks it will collect on average etc etc.
I call this probabilistic computing.
so here we have two terms, one is deterministic computing, the other is probabilistic computing. I guess most games have to run actual computing (deterministic ones) especially fps shooters as live input is crucial, and the engine has to directly respond to live user input. it can never guess what you will do next, it will have to update the whole engine and all of its variables every tick.
but factorio? especially space ships? hell no they don't have to be calculated deterministically, right? I guess one could save 99% of cpu, if not 99.9% or even 99.99% given this approach. now the big question: does factorio already do this? does factorio already not process factories or space ships, when I am not looking or when I am not there with the engineer to potentially mess things up?
what about biters? the game knows how they work, how they attack, their properties etc etc. if the game knows all this, and I am not looking, maybe working on a base on fulgora, does the game actually calculate biter attacks which to me have no random outcomes anyways, but expectable ones, and if so, why calculate them in detail, why not calculate them probabilistically?
does the game engine really update everything on every surface every tick? or does factorio skip the calculating for things that do not need to be calculated, but can rather be (close to) accurately guessed given the non-changing nature of a set of already known variables, i.e. guessing based on already known probabilities?
is the factorio engine actually already guessing or not? if not, what a huge performance improvement it could gain from stopping to calculate things which can be approximated instead (with the same outcome of course, in the long run)
what do I mean by "with the same outcome in the long run"?
well does it really matter if you calculate every variable of a system (like a spaceship or a subfactory) every 60th of a second, and you end up with x amount of legendary plates, or you guess the same outcome instead? you will end up with the same outcome, except in one scenario the CPU knows cause it computed this outcome and tracked its progress for every tick in the game, and in the other scenario it just gives you the legendary plates cause it knows "I would have gotten 256 leg plates if I had done the work given the variables in front of me". how does it know? it looks at the variables, checks inputs and outputs, knows this setup will yield x amount of leg plates, and then just updates the user account with x amount of legendary plates instead of actually "producing" them in a factory, which takes way more cpu.
idk, am I tripping balls here, am I missing something basic in computing? are my questions silly or stupid? and if not, is factorio already doing exactly this, or something very similar?
it all boils down to
TLDR: does factorio's engine, as part of extensive optimizations, sometimes or most of the time skip calculating the whole multi-planet world, and go over to guessing outcomes/outputs, instead of actually calculating every tick of its production lines?
this question came up way too many times while playing factorio for me not to finally mention it on here.
what this means if I am on to something here: 99.9% performance improvements for megabases. if the game does not need to calculate bases anymore, cause it knows all the values beforehand, it can merely simulate it. the only surface it would actually need to calculate, would be the one you are currently on, and you could be sitting on an empty spaceship while doing everything in remote view, or doing nothing at all.
to me the idea is fascinating. belts would not have to be calculated anymore, neither inserters. you just check the probabilistic algo for how much stuff goes on this belt on average, how much will the miners produce on average, how much input diminishes on average cause an ore patch gets depleted, how fast does it get depleted on average, greate functions and variables about this autimatically, use them to approximate the outcome 99.99% accurately compared to the computed version of game reality.
I'd take 99.99% accuracy with this probabilistic method over 100% accuracy but with 99% worse processed performance any day. what about you? if your calculated game gives you 1000 plates for running your perfectly designed factory, but in my game, you only get 999plates, cause the guesstimation algo is not 100% accurate, but you can build your base 100x bigger, say 100 million spm megabase with 60 ups on average cpu easy.
what would you pick? I'd pick the 999 plates every day of the week.
do you need your game to actually be deterministic or probabilistic?
am I talking nonsense? looking forward for a good discussion. would also me nice if the game makers could chime in on this, or at least point to some FFF about this, it is has been addressed before. I a way I can't believe a heavily optimized game which mostly runs without immediate user input (every surface you are not watching or moving on) is actually updated every tick of a second, instead of summarized to a known set of non-changing variables, and this formula being updated until the user might change something about this forumla (i.e. live user input) at which point the guessing needs to stop and the calculating needs to kick in again.
is this switching even possible? if so, it would be so nice to know it is happening in the background. if not, we'll see 100m+ spm megabases if it gets implemented. basically you calculate what you see, and what you might change within about a second as a user, and all of the rest you estimate or guess, and the guessing will be good enough so nobody would notice.