Towards a newer, better space casino in 2.1
Posted: Wed Jul 08, 2026 3:42 am
I fired up ghidra and researched for random number manipulation possibilities again in 2.1, and found interesting changes. In short, the global quality / additional product RNG is now shared by much fewer, and much more predictable things. And with the addition of universal signals, TAS-style random number manipulation becomes tangible with in-game mechanics only.
The RNG algorithm is similar to 2.0 so I'm skipping it (check link at the end for code). For now it's enough to know it's possible to compute an arbitrary future value of the builtin RNG using an AND-XOR matrix multiplication, which is possible with in-game combinators. In 2.1, the global RNG is shared by:
- Quality rolls at the beginning of recipe-crafting (basically all thing-makers that are not miners), it seems always rolled, even for with crafts with +0% quality
- Additional production rolls at the end of recipe-crafting (e.g. recycling an iron gear will roll once to see whether you get an iron plate)
- Mining (likely one roll for big/quality miner resource consumption + one roll for quality). In 2.1, productivity mining seems batched so there is only one roll no matter how many ores are produced simultaneously
- Flickering of glows: confirmed for heating tower and nuclear plant, suspected for fusion plasma maker and accumulators
* Particle effects: confirmed for gun turret shooting, suspected for other turrets
* Unknown `randomPosition()` calls: suspected for Fulgora lightening or asteroid spawning. It no longer happens on every tick, became much more scarce.
* Didn't check in 2.1 yet: was used in computing heat transmission across heat pipes in 2.0
The '-' ones are somewhat controllable: you can "stop the world" during critical moments. Nuclear plant can be stopped by denying fuel and fusion plants can be denying coolant. Fulgora lightening can be "controlled" too by performing critical actions during Fulgora days. Asteroid spawning doesn't happen often for stationary platforms. Providing there is no shooting anywhere, we can get dozens of ticks where we *completely control* the quality RNG.
Now to utilize the control, we need to first leak the 88-bit RNG state. It's trivial to leak 1 bit by recycling an iron gear wheel and checking whether it produced an iron plate. The main obstacle is the opaque internal update order of Factorio, which isn't even visible to mods. However, while entities in a surface are updated in a dynamic and uncontrolled order, ordering *between* surfaces are likely deterministic (unconfirmed yet). So theoretically, if we launch 88 consecutive space platforms, then give them one recycler each and synchronize the recyclers, we can leak the complete RNG state in a single tick. The 2.1 universal signals allow us to transmit them to some Nauvis control center for RNG prediction.
With state leaked, it's possible to predict many future bits in parallel. If we aim for a 1/40 roll to directly make rare from common or recycle rare to legendary, we can predict 6 bits for 88 future rolls and get one with 89.2% chance. This prediction will be used to reprogram the 88 platforms: those getting bad rolls play with iron gear wheels, the few getting good rolls make / recycle big stuff like rocket silos, personal fusion reactors or capturing rockets. As long as only one thing goes through the first / last tick of crafting every platform, their ordering should remain predictable.
This design allows one to get legendary *anything* in a single upcycle, with fixed 25% yield. It can also enable in-space productivity loops like brick=>10 concrete=>10 bricks, or lossless promethium chunk upcycling, by manipulating recycler output as well. The catch is:
- Between the state-leak tick and the manipulation tick, i.e., during the matrix multiplication:
* You can't make or mine anything anywhere
* All reactors must be off, you can still get power from the non-glowing parts: heat exchangers, turbines, and likely fusion generators
* No shooting anywhere
* Could require Fulgora day
* We could have to bet on no asteroid spawning
- 66-88 iron gear wheels consumed as catalyst for each run (likely worse than normal recycling since you want to do them on known bad rolls)
- Need 88 platforms with strictly controlled launch order to reliably leak state
- The required combinator logic would be impractical to create by hand and some lua would be required to create the required blueprints
I haven't done the lua-ing yet. Just decided to share the preliminary results first.
For other people interested in reverse engineering: in 2.1.9, there is a dedicated function `rollQuality`, which takes a random number as input. You can set a break point at its start, then inspect the upper level of call stack and look for access to `DWORD PTR [reg+0x414]` to find out the quality RNG address (which is that `reg+0x414`). Then set a read/write breakpoint at it to see where it's used. It's best done in map editor where you can step single ticks.
Link to previous research in 2.0: viewtopic.php?p=653823#p653823
The RNG algorithm is similar to 2.0 so I'm skipping it (check link at the end for code). For now it's enough to know it's possible to compute an arbitrary future value of the builtin RNG using an AND-XOR matrix multiplication, which is possible with in-game combinators. In 2.1, the global RNG is shared by:
- Quality rolls at the beginning of recipe-crafting (basically all thing-makers that are not miners), it seems always rolled, even for with crafts with +0% quality
- Additional production rolls at the end of recipe-crafting (e.g. recycling an iron gear will roll once to see whether you get an iron plate)
- Mining (likely one roll for big/quality miner resource consumption + one roll for quality). In 2.1, productivity mining seems batched so there is only one roll no matter how many ores are produced simultaneously
- Flickering of glows: confirmed for heating tower and nuclear plant, suspected for fusion plasma maker and accumulators
* Particle effects: confirmed for gun turret shooting, suspected for other turrets
* Unknown `randomPosition()` calls: suspected for Fulgora lightening or asteroid spawning. It no longer happens on every tick, became much more scarce.
* Didn't check in 2.1 yet: was used in computing heat transmission across heat pipes in 2.0
The '-' ones are somewhat controllable: you can "stop the world" during critical moments. Nuclear plant can be stopped by denying fuel and fusion plants can be denying coolant. Fulgora lightening can be "controlled" too by performing critical actions during Fulgora days. Asteroid spawning doesn't happen often for stationary platforms. Providing there is no shooting anywhere, we can get dozens of ticks where we *completely control* the quality RNG.
Now to utilize the control, we need to first leak the 88-bit RNG state. It's trivial to leak 1 bit by recycling an iron gear wheel and checking whether it produced an iron plate. The main obstacle is the opaque internal update order of Factorio, which isn't even visible to mods. However, while entities in a surface are updated in a dynamic and uncontrolled order, ordering *between* surfaces are likely deterministic (unconfirmed yet). So theoretically, if we launch 88 consecutive space platforms, then give them one recycler each and synchronize the recyclers, we can leak the complete RNG state in a single tick. The 2.1 universal signals allow us to transmit them to some Nauvis control center for RNG prediction.
With state leaked, it's possible to predict many future bits in parallel. If we aim for a 1/40 roll to directly make rare from common or recycle rare to legendary, we can predict 6 bits for 88 future rolls and get one with 89.2% chance. This prediction will be used to reprogram the 88 platforms: those getting bad rolls play with iron gear wheels, the few getting good rolls make / recycle big stuff like rocket silos, personal fusion reactors or capturing rockets. As long as only one thing goes through the first / last tick of crafting every platform, their ordering should remain predictable.
This design allows one to get legendary *anything* in a single upcycle, with fixed 25% yield. It can also enable in-space productivity loops like brick=>10 concrete=>10 bricks, or lossless promethium chunk upcycling, by manipulating recycler output as well. The catch is:
- Between the state-leak tick and the manipulation tick, i.e., during the matrix multiplication:
* You can't make or mine anything anywhere
* All reactors must be off, you can still get power from the non-glowing parts: heat exchangers, turbines, and likely fusion generators
* No shooting anywhere
* Could require Fulgora day
* We could have to bet on no asteroid spawning
- 66-88 iron gear wheels consumed as catalyst for each run (likely worse than normal recycling since you want to do them on known bad rolls)
- Need 88 platforms with strictly controlled launch order to reliably leak state
- The required combinator logic would be impractical to create by hand and some lua would be required to create the required blueprints
I haven't done the lua-ing yet. Just decided to share the preliminary results first.
For other people interested in reverse engineering: in 2.1.9, there is a dedicated function `rollQuality`, which takes a random number as input. You can set a break point at its start, then inspect the upper level of call stack and look for access to `DWORD PTR [reg+0x414]` to find out the quality RNG address (which is that `reg+0x414`). Then set a read/write breakpoint at it to see where it's used. It's best done in map editor where you can step single ticks.
Link to previous research in 2.0: viewtopic.php?p=653823#p653823