r/factorio • logic noodles • Sep 12 '26 • Galaxy Brain 1 Bravo 14 Mindblown 2 Heartwarming 1

Design / Blueprint Tired of gambling for quality? Try math instead!

Do YOU have a gambling problem? Does your quality roller seem to never give you that bump in quality that you so rightfully deserve? Well worry no more, with just a bit of math you too can guarantee** legendaries in no time. Just follow this simple build and you too may soon be clad in full legendary gear.

** mostly guarantee

In all seriousness though: Hi everyone, today's the day I finally showcase a project I've worked on, on and off, for almost three years by now. As you can see in the video above, I built a machine which allows me to ingest common quality items into a craft and instantly upgrade to legendary outputs.

How?

As you may know, in games there is the concept of RNGs (or random number generators) underpinning randomly occurring events. But what if I told you that these random numbers... are not actually random (shocker for a deterministic game I know)!

Instead they are generated by a fixed algorithm that produces a sequence which merely seems random. If you start from the same initial state, then you will observe the exact same sequence!

What this means is, that once we figure out the position that the game's RNG currently is at within this sequence, we may as well start performing the same computations that the game will do for future random numbers, but get there before the game does. This allows us to "look ahead" in the sequence and predict future """random""" outcomes, even before they occur.

What's even more interesting is that this computation is actually quite cheap, which allows one to reimplement it entirely within combinators!

This led me to build this machine, which can (1) sample and deduce from the observations the game's current RNG state, (2) predict many future outputs of calls to the random generator, (3) automatically skip towards lucrative outcomes and (4) craft the desired item at the right time, to hit the rare instances where an item immediately upgrades from common to legendary quality.

And the most amazing part is that this is actually sort-of feasible in game! As in it does work, but only in a semi-controlled environment. Factorio shares the same random generator with a bunch of other parts of the game, which may desync our current guess of the game state, which if not handled leads us back to basically blindly guessing.For example, Fulgora lightning strike positioning is determined by the same generator used for crafting result creation and quality rolls.

Lastly, as I already said, this project has been going on since about 3 years (right around when quality was first announced in FFF#375). In the mean time, others have independently shared their findings: kovaxis in the factorio forums and d4s_over_dt4 in the official discord, but as far as I know this fully autonomous machine is (still) the first of its kind.

There is sadly one major drawback. Since I waited so long to release this the devs have made strides on the 2.1. update. Within it, the way the RNG is called also got a rework, which broke some of the assumptions I made while designing this contraption (mainly about how many calls a single craft makes) breaking it in 2.1, so it is currently limited only to 2.0.

I figure some of you might enjoy a deeper dive, for which you can have a look at my full write up (which was part of the reason I didn't show this off for so long):

https://gegell.github.io/posts/factorio-rng/

It contains all the juicy technical details of basically every minute part of the machine, covering the underlying mathematics (with interactive visualizations!), in game setup, containing a world download, blueprint string and the code used for generating parts of the machine and a deeper discussion into why it may break down.

5.0k Upvotes

300 comments sorted by

82

u/Lachtheblock Sep 12 '26 edited Sep 12 '26

This is very cool. I have never thought about RNG manip in game, but makes sense.

I assume (in 2.0 atleast) that a lot of things would be driven by the same RNG? Asteroids? Biter expansion? Of course it also means you can only be crafting a single quality component at a time too?

Is biter behavior also controlled in this way?

I could see this legimately being useful in some sort of biters off sushi challenge run.

Absolutely will be checking out your deep dive.

79

u/Gegellibu logic noodles Sep 12 '26

biters are from what I can tell driven by a separate RNG instance (there are 6 different global RNGs in 2.0 with a 7th being added in 2.1). Item creation shares the same RNG across all crafting machines, so thats why a strict grasp is necessary on that one (esp. the other locations where its used) if one wants to actually use this in a true save game.

And yes, since I flip between skipping ahead and crafting, it can only ever do a single quality component at a time, though as visible in the video, there is not a large interval necessary when skipping ahead, leading to actually somewhat decent throughput.

118

u/BoskiDialer Developer Sep 12 '26

2.0 has 5 random generators, the sixth one is called "unsafe" because it is not part of game state which means it is only used for visual things. Since it is not part of game state, by definition it cannot influence anything in game state. New random generator in 2.1 is "fish" random generator since fishes generate quite a lot of random numbers to decide if they should rotate left or right. Also in 2.1 the lightning generator for fulgora got its own random generator. Having those random generators separated is primarily to help reduce desyncs spreading over entire game state (if one entity did different amount of rng calls, all subsequent entities will also get different result causing desyncs to be useless). I cannot confirm or deny that having use cases like this was a secondary reason for the changes.

74

u/Gegellibu logic noodles Sep 12 '26

You cannot imagine my dread when I first opened the save in the 2.1 update, saw it broken and took a look at the random generators memory. While I came to terms that 2.1 may require fish genocide to make it "feasible" again, I was so delighted to see the introduction of the fish generator. Y'all unknowingly sent me on a roller-coaster of emotions with the initial couple of updates :')

Also the 2.1 lightning getting its own generator is veeeery interesting (as in 2.0 only the mesh generation had its own).

25

u/oobanooba- The Factory Must Groove Sep 12 '26 • Bravo

Fish rng is fascinating and beautiful.

I bid the fish good fortune.

→ More replies (4)

14

u/Lachtheblock Sep 12 '26

Does the RNG get rolled across all assemblers? Or just the ones with Quality modules?

28

u/Gegellibu logic noodles Sep 12 '26

In 2.0 it was only across all the assemblers which require some sort of random output (quality, or non integer item stacks). In 2.1 each completed craft calls the RNG twice regardless of whether the RNG gets used or not, as they implemented some sort of roll sharing.

→ More replies (1)

7

u/ImSolidGold Sep 12 '26

This Post made it to Reddits hot page and Im proud and happy for you!

1

u/AramisUkr Sep 12 '26

Does this RNG rely on in-game tick system or on the items, produced? Because, if it's the former, it means we'll get strictly limited number of legendary items per time amount, no matter how many assemblers we use.

5

u/Gegellibu logic noodles Sep 12 '26

The RNG gets advanced whenever a random number is required (e.g. a crafting result with non-integer item counts, quality level, ...) so it is not directly linked to the ticks, but somehow it still is, as we need to consume the "bad" calls (which requires time) before we can consume the one "good" call. Scaling this up might be feasible with more subtick mechanics (i.e. always schedule the bad calls into the skippers with good calls consumed by crafters interleaved) but that sounds like an even bigger explosion in complexity. So even with your stated latter scenario we can't simply increase the number of assemblers (as they all share the same RNG).

→ More replies (1)
→ More replies (1)

9

u/Keleyr Sep 12 '26

Oh, no. Imagine how insane the tas speedrun for the space age would be. Ah, you need upgraded components for the spacecraft? Lets just throw in a single t1 quality module and craft everything once. As long as it is crafted at the correct time.

→ More replies (3)

16

u/Courmisch Sep 12 '26

If we have Quality without Space Age, and no other quality module anywhere, are there still perturbations from other RNG consumers?

39

u/Gegellibu logic noodles Sep 12 '26

Yes. Since the RNG that is used for quality is the generalRandomGenerator this also gets used in several other locations. For instance, whenever a recipe has non whole item counts in the output (e.g. uranium processing or recycling) this is also invoked. Likewise, the placement of spidertron legs, dust particles spawning when the player walks over dusty ground, or fire for instance also all use the same generator for variation.

While this may sound quite bad, I believe if one takes this machine into account from the get go, then it should be feasible to use (e.g. one could disable all RNG consumers with a logistics group or similar).

4

u/Ironic_Toblerone Sep 12 '26

How difficult would it be to adapt it so that it will produce anything at or above above a given quality? Also what machines and things would need to be disabled for this to work?

8

u/Gegellibu logic noodles Sep 12 '26

It is actually already configurable for this, though as one needs to do the entire back and forth cycle anyways (which takes a bulk of the time) you might as well just upgrade fully. In 2.0 it would suffice to simply shut of all other machines which require the random generator (e.g. non integer stack sizes or other quality rollers) being careful not to trigger the other possible source see section 6.0 of the post.

→ More replies (1)

10

u/QuizardNr7 Sep 12 '26

"I got this idea from my real work as high frequency trader" - OP, allegedly

15

u/Gegellibu logic noodles Sep 12 '26

It was infact u/earthcomputer (and co.) who posted their mess detector (RNG cracking in minecraft) in the same time frame as the first post on quality (FFF#375) was released which actually made me consider this project. In addition to that, after digging around the code a bit, I realized that this sort of RNG was something I (at the time) just learned about in the same semester.

This was certainly all necessary parts just perfectly falling into place :)

→ More replies (1)

5

u/Ozryela Sep 12 '26 edited Sep 12 '26

I understand the idea behind this, but I don't understand how you can reliably isolate a single random event. Surely there's lots of random events constantly going on in the background. You already mentioned Fulgora lightning, but there's also asteroids, biters, even fish. Oh uranium processing too. I'm sure there's others I'm not even thinking about right now.

So I guessing this only works if it's day on Fulgora (or you don't have the planet yet), if you have no spaceships and if you have eliminated all biters and fish on Nauvis? That's some rather harsh pre-conditions.

edit It's also rather interesting that this only works because the Factorio devs decided to use a custom RNG algorithm (taus88) with a state of only 96 bits. The game is written in C++, which by default uses Mersenne Twister for random number generation. Mersenne Twister has a state of 19968 bits, so you'd need a lot of combinators to keep track of its state compared to the one that is actually used in the game.

I wonder why they chose a different algorithm. Speed, presumably. But that is strange because you'd think the game doesn't use enough random numbers to justify that.

6

u/Gegellibu logic noodles Sep 12 '26

Factorio actually has multiple different RNGs it uses for different aspects of the game. While item creation infact does make use of the generalRandomGenerator (and like the name states, its shared across multiple different aspects) the ones which require many calls are actually split out from it. Asteroids for example have their own, so do biters (and in 2.1 so do fish, though for some reason they were not a problem in 2.0, probably outside the simulation distance).

But yes, other production lines like uranium processing or fulgora scrap recycling (and during 2.0 lightning strikes) are factors which need to be considered and consequently disabled while this is running.

2

u/Ozryela Sep 12 '26

Ah, yeah, if biters and asteroids have their own seed that helps a lot. As was wondering if you had to scrap all your spaceships before using this. That doesn't make it impossible, but highly impractical.

And yeah, you're right, fish don't move outside a certain distance. I actually knew that, but didn't think of it while writing my comment. So you'd have to do this away from water, or at least remove the fish in the closest chunks. That's doable.

Thanks for the explanation.

So what breaks in 2.1 then? If they just added a separate generator for fish that should only make your life easier. I guess they moved more stuff around?

It would be fairly easy for the devs to make this RNG prediction impossible (on a practical level) by using an RNG algorithm with a larger state. Which brings me back to wondering why they don't use the C++ built-in algorithm to begin with.

4

u/Gegellibu logic noodles Sep 12 '26

In 2.1 there were several reworks to the RNG wrote about it under section 6.1 but the tl;dr is:

Crafts now compute a single roll which can be reused by different parts in the item creation which violates my assumptions on which offsets get sampled when sampling while also removing the capability of using scrap to skip ahead quickly as it will likewise now just call the RNG twice.

Additionally since updates are still coming in which touch those code paths, I did not feel it was stable enough yet to update, seeing as it might just break with the next update again.

4

u/tru_mu_ choo choo Sep 12 '26

Do the types and qualities of the modules affect the calculations? Could you have this work with just one q1 quality 1 module in the legendary assembler? And do the modules of the other assemblers affect the quality of the legendary one too?

10

u/Gegellibu logic noodles Sep 12 '26

The only difference the quality module makes is the threshold used when deciding the first upgrade step. Theres a calculator for that in my post under section 5.4 of my blog.

4

u/ObsessiveOwl Sep 12 '26

Short answer: No.

The large part of this contraption are a sample pool, by reading the result of the samples it guess the seed number of the RNG. From that seed number the legendary area calculate when is the right time to start crafting to guarantee a legendary outcome.

The modules of the other assemblers doesn't affect the end result but will need different equations to work, the seed stay the same.

The modules on the Legendary assembler will give proportional results in different config. A 5% quality assembler will output half as much as a 10% one and the calculation will need a little tweak.

Assuming infinite resources, this machine will not increase your legendary production. Compare to normal up-cycling functionally this thing will void everything that isn't legendary.

Edit: I haven't read the in-depth write up so I could be wrong on this. Need confirmation from OP.

4

u/Dtitan Sep 12 '26

My friend … I read the write up … holy smokes that’s nuts.

How long did implementing this take?

9

u/Gegellibu logic noodles Sep 12 '26

Over all I estimate that I easily spent 250+ hours on this project (including the writeup, me snooping around in the disassembly, ...). If I look at the game time, the current save file sits at 130h while the first one (which by now sadly is lost to time) was likely around 50h already as well.

The first implementation I already had down like 2 years ago, with further feature creep (faster state readout, full automatic cycling) getting implemented over the last 2 years. It was very much a on and off process, where I occasionally burnt out on this, which is why it dragged itself out so long (but in the end I'm glad I finally got to the full auto cycling).

3

u/Dtitan Sep 12 '26

Man that’s dedication. Are you a dev on any mods? That kind of obsession needs channeling.

4

u/Gegellibu logic noodles Sep 12 '26

No not really, I made a single QoL change back in the days (fire not leaving any burnt trees).

But if its creating mods vs something like this I really need the topic at hand to tickle my brain in a very specific way for me to hyperfocus on which so far very little topics have done as much as this project.

I wish I could be this dedicated to everything I do lmao.

→ More replies (1)

1.7k

u/MightyBigMinus Sep 12 '26

new intended way dropped

786

u/The_Sovien_Rug-37 Sep 12 '26

why doesn't the engineer just always craft things in legendary quality. is he stupid?

112

u/gerx03 Sep 12 '26

1x normal quality1 module is more than enough if you don't have a skill issue therefore you only ever craft legendary

33

u/CherryTorn-ado Sep 12 '26

maybe we need a Legendary Engineer 💀

(Time to dive at that Recycler with Legendary Quality Modules)

35

u/Llyrithra Sep 12 '26

Unfortunately, you got a bad roll. 1 uncommon fingernail and 3 normal teeth. The rest of the engineer was consumed in the process.

→ More replies (3)
→ More replies (1)

4

u/KeithFromCanadaOlson Sep 13 '26

Not stupid, no. He is an engineer, not a materials scientist, and has to figure out how to make everything from scratch, so he won't get it perfect straight out of the gate. (Also, the whole 'Quality' system is backwards. Basic items are the 'it actually works!' level of figuring out how to make stuff. It is only when you get to 'rare' that it approaches average quality, and 'Legendary' is what we would call 'Grade A' quality.)

→ More replies (1)
→ More replies (2)

1.4k

u/Korporal_kagger Sep 12 '26

Any sufficiently evolved factory is indistinguishable from magic

159

u/ZootedMelon Sep 12 '26

tried mainbus mega factory for the first time, got a spaghetti mega factory that even i didnt know how it worked, remove the wrong piece and it never works again.

56

u/Panzerv2003 Sep 12 '26

Sounds like writing code

20

u/metaquine Sep 13 '26

This guy codes

→ More replies (1)

17

u/Bearstew Sep 13 '26

Factorio engineer checking horoscopes before crafting iron gesrs

→ More replies (1)

826

u/Cephell Sep 12 '26

Space casinos died for this

136

u/dasi128 Sep 12 '26

ban that, Wube

362

u/zuilli Sep 12 '26

Next patch: "changed RNG to become true random using 7 different seed sources including the radioactive decay of a sample of U-235 we have in our office."

298

u/Super_Pie_Man Sep 12 '26

Factorio is now an always-online game after Wube purchased a warehouse full of lava lamps.

13

u/fezzam Sep 13 '26

Given enough time every comment I want to make gets made… sigh

→ More replies (1)

94

u/pmormr Sep 12 '26

Fun fact, what you're talking about is already built into your CPU. The newer Intel chips use thermal noise instead of radiation as one of the physically random entropy sources from a quick reading, but it's mathematically just as good (horray quantum mechanics).

You just wouldn't ever use this for a video game, because you know... why bother making sure that legendary rolls are cryptographically secure? lol.

50

u/Xadnem Sep 12 '26

why bother making sure that legendary rolls are cryptographically secure? lol.

Because we can!

→ More replies (9)
→ More replies (4)

13

u/Aveduil Sep 12 '26

Wube will have lava lamp wall and to get quality you need internet connection

→ More replies (4)

5

u/HeKis4 LTN enjoyer Sep 12 '26

... I'm guessing they could by using two RNGs with different states, one for quality only and one for the rest. But I wouldn't even patch this, this is "fun black magic" tier.

→ More replies (1)

16

u/LauraD2423 Sep 12 '26

No, this actually died with 2.1 too.

9

u/Then_Entertainment97 Sep 12 '26

Space casinos died for with this

6

u/Demiu Sep 12 '26

Wym casino is back, now with card counting

2

u/Lardbucket_ Sep 12 '26 edited Sep 12 '26

Is there a plan to update it once 2.1 becomes stable with the RNG changes you mentioned in the blog?

Had stumbled upon the forum thread you mentioned and had been tinkering a month or two ago doing the maths myself with recycling of gears but could never get it to work so gave up, happy to hear it sounds like the RNG calculations have changed and not just me being an idiot

4

u/Gegellibu logic noodles Sep 12 '26

Maybe when 2.1 becomes stable, I'll have to see, currently I'm somewhat burnt out on the project and have a lot less free time. I was considering to release this only once I did an updated version, but that would have probably delayed this getting published even longer :)

→ More replies (1)

2

u/MaleficentCow8513 Sep 12 '26

You can also replicate the sequence if you know the seed. Is there no way to access the seed from game files?

4

u/Gegellibu logic noodles Sep 12 '26

The issue with that is that even if you know the same start seed, it is incredibly difficult to know how many times the rng was called until the current point in time. This is something we need to know, as being of by just 1 in this sequence, the entire breaking ceases to work. So having the static initial seed would not help a lot. But yes the generators obviously also get saved to disk, but in some binary format. At that point however you might as well inspect the games runtime memory and look at the state directly though (this is what I actually did while debugging this :) ).

→ More replies (1)

2

u/Rsccman Sep 12 '26

Blueprint please?

2

u/Gegellibu logic noodles Sep 12 '26

Linked to in the post under section 6. which also goes into the limitations of this method, which is important to read lest you might wonder why it does not necessarily work.

2

u/TonicAndDjinn Sep 13 '26

Have you thought about using random input on selector combinators? I think you could read the seed much more quickly with one selector combinator shuffling two input signals once per tick; likewise you could advance the PRNG quickly by having blocks of selector coordinators on power networks controlled by switches which get selectively turned on for one tick.

2

u/Gegellibu logic noodles Sep 13 '26

yes I did think about this as the very first thing once they were announced. However the only time those query the generalRandomGenerator is when they get placed. This is due to them having their own internal RNG state, which only gets initialized from the general RNG -- afterwards they will diverge.

The initial seeding is what d4s_over_dt4 used when they built their state read out combinator network. Issue with that is that it requires player interaction to resample the RNG.

3

u/TonicAndDjinn Sep 13 '26

Ah, gotcha. I guess if I'd read as far as the section on different seeds in your write-up I would have noticed that.

248

u/Agador777 Sep 12 '26

Wow! This is some woodoo magic shit here! Outstanding!

80

u/Overwatcher_Leo Sep 12 '26 • Bravo

Rng manipulation? In my casino game?

75

u/Stunning_Box8782 Sep 12 '26

This is like looking at a single particle and determining the state of the entire universe

19

u/RyanSpunk Sep 12 '26

Have you seen Devs?

3

u/Stunning_Box8782 Sep 14 '26

No never heard of that

→ More replies (2)

5

u/MadyCastigan Sep 12 '26

According to modern theoretical physics, it is actually always theoretically possible to figure out all past states of a system given the information in a current state. Actually doing that on the other hand...

5

u/man-of-pipis Sep 13 '26

Getting arrested because a stray atom of carbon dioxide in Kenya was the result of me killing someone in London 3 years prior

→ More replies (2)

276

u/Correctsmorons69 Sep 12 '26

Creepy-pasta version: it works in real life too.

118

u/DaPlipsta Sep 12 '26

Quantum state prediction engine

30

u/Last8Exile Sep 12 '26

Finally achieving FTL communicatuion?

24

u/danielv123 2485344 repair packs in storage Sep 12 '26

Sadly this method of FTL communication only works for producing legendary iron gears.

→ More replies (11)

23

u/Narrrz Sep 12 '26

"the devs updated the RNG code in the newest version. Fortunately my algorithm already anticipated and accounted for this change so it was merely a matter of waiting for reality to catch up to my simulation..."

→ More replies (1)

4

u/FrozenHaystack Sep 12 '26

Wasn't that the plot of an Doctor Who episode? People all saying the same random numbers.

→ More replies (6)

139

u/foxgirlmoon Sep 12 '26

Pure insanity.

41

u/zerossoul Sep 12 '26

Virtual insanity.

24

u/towerfella Sep 12 '26

Factorio Tuesday.

8

u/dearvalentina Fungusmaxxing Sep 12 '26

That dude hasn't gotten the belt immunity slippers yet it seems

→ More replies (2)

59

u/deco1000 Sep 12 '26

This is absolutely incredible, I have absolutely no idea how you could reverse-engineer the random number generator for the game and implement this kind of thing, but it feels amazing that it is actually possible to do. Kudos to you! This game and this community are amazing

112

u/Greningas Sep 12 '26

What in Laplace's demon is this.

91

u/what_the_fuck_clown ÐŌ ʼnºŤ ĿĖŢ ŦĤĖ ĘŸĚŜ ØF £ŲŁĜºЯÄ ŦŒ ŞŢÅŖĖ ŀʼnŤŎ ŶŒÙŔ ŠºÛĽ Sep 12 '26

your insanity inspires and madness brings hope.

26

u/clif08 Sep 12 '26

One of the craziest things I've ever seen on this sub.

21

u/LeifDTO You haven't automated math yet? Sep 12 '26

Only 5 combinators? How did y- HOLY MOTHER OF GOD

18

u/Runelt99 Sep 12 '26

Bro hacked bitcoin mining

16

u/Funintuitive Sep 12 '26

That's pretty cool. Congrats on the achievement.

15

u/mist_kaefer Sep 12 '26

That zoom out was legendary

13

u/Aggressive_South_991 Sep 12 '26

i just use spaghetti and figure it out as i go... and then theres people that do this.

Factorio is probably the game with the biggest (gigantic) gap between casuals and actual good players. holy shit.

13

u/DiabolicallyOrange Sep 12 '26

What. The. Fuck.

12

u/Grismor2 Sep 12 '26

"He who meddles with the threads of fate should prepare himself for the wrath of Atropos."

—Me

22

u/MakingAngels Sep 12 '26

The absolute mad lads (and ladies) of this community never stop amazing me. This game is bonkers with its ability to enable such creativity.

→ More replies (1)

10

u/tiogshi very picky Sep 12 '26

Guaranteed results every time; all you gotta do is consult Maxwell's Demon.

9

u/Old_Ad9574 Sep 13 '26

Bro is predicting the future with math, and I'm here, struggling to set up a timer

2

u/weeknie Sep 12 '26

Amazing work. One question though: in this post and in your write up, you seem to make the connection that the RNG is implemented as pseudo RNG to ensure the game remains deterministic. It is something that is important for Factorio, since it allows all clients in multi-player to make the exact same calculations even if "randomness" is required to be involved.

However, afaik there is no true way to do randomness in a computer, barring specialized hardware maybe. The way randomness is implemented is just the way "randomness" works in computers. The determinism, given enough knowledge, is a side effect, not the main purpose.

5

u/Gegellibu logic noodles Sep 12 '26

Yeah that specialized hardware was what I was getting at. You can for instance measure magnetic noise, or detect radiation decay, which are sometimes used for seeding the random generators. I just wanted to really drive the point home, that basically almost all RNGs in computers rely on PRNGs producing deterministic sequences, as some people might not be aware of this fact.

→ More replies (1)
→ More replies (5)

5

u/Technical-Ad9571 Express engineer Sep 12 '26

This is just SOO cool!

I knew something like this was possible, but goddamn this is just PEAK

I kinda got the process until you got to Galois Field, which make me short circuit. I did get the programming part tho. Great blog post!

5

u/Simic13 Sep 12 '26

Wow, this is the level of diving into the game...

You should not be allowed to visit casino ...

4

u/SevereBruhMoments Disco Lab! Sep 12 '26

Very interesting

4

u/Helpmefromthememes Sep 12 '26

Someone call Michael Hendricks, his Kwality setup might benefit from an upgrade !

4

u/Raynsen Sep 12 '26

Bro, when was the last time you saw sunlight?

4

u/Brewer_Lex Sep 12 '26

I read your blog post about it and it was an impressive academic write up if I’ve ever seen one. Your process and problem solving was beautiful.

4

u/lysianth Sep 12 '26

holy shit,

have you considered cyber security?

This is way more impressive than the comments are giving you credit for.

1

u/dmigowski Sep 12 '26

Does this work if you have two of them?

3

u/Gegellibu logic noodles Sep 12 '26

Nope. There is a single random generator which gets called whenever anything requires randomness. So in-fact 2 of them would get in each others way instead. However, this is not to say that there is no room for improvement in this design, as the delay between rolling and crafting could probably be reduced a bit further.

→ More replies (3)

1

u/mglachrome Sep 12 '26

wait, you can color concrete?

3

u/Gegellibu logic noodles Sep 12 '26

They are available tiles in the editor (I think due to one of the PvP modes). So no, sadly not without "cheating" or mods.

1

u/sypwn Sep 12 '26

And here I thought I was so clever to use automated recipe cycling to sink excess liquids on Aquilo. This is a level of game mechanics abuse so far above that I can't even. Bravo.

Quick question because I can only skim the blog post right now: for the process of determining the current state (using the 44x recyclers) and feeding that seed into the predictor, is it fully automated as well? Or does it require the player to do some frame-by-frame inputs to set things up at first?

2

u/Gegellibu logic noodles Sep 12 '26

It is fully automated, even the detection when the prediction diverges & auto resetting when it does. The only thing I did in the video was toggle the constant combinator below the display panel saying "Disabled" to turn it on. You can do that with a keybind (F1 for me) thats why no gui opened.

1

u/Winter_Ad6784 Sep 12 '26

does this work with other upcyclers running? can you run multiple of these at once?

1

u/Gegellibu logic noodles Sep 12 '26

nope only a single one of these can run at once, as the quality rolling shares one global RNG and multiple would get in the way of one another. Likewise other sources of random calls also will hinder this machine. This includes any recipe with non integer results (e.g. recycling or uranium processing) getting crafted or dust particles spawning when walking over dry flooring.

1

u/VoidRaizer Sep 13 '26

Fascinating. I also couldn't help but notice it looks like your blog is exactly what I was just looking into setting up for my wife - I'm guessing you used Obsidian + github pages to host your site? Probably Vercel too? Any advice you can offer regarding this for someone just starting to look into it?

2

u/Gegellibu logic noodles Sep 13 '26

Yeah that approach sounds about right (though I didn't use vercel, just gh-pages).

For me, as I was interested in having more control (like the interactive widgets) and wanting to tinker with my own site I actually custom built myself a solution based on svelte and mdsvex (the text is mostly written in markdown, with some references to the interactive components in between). It of course came with additional engineering costs to setup, but thats also part of why I chose this route myself.

To host I generate static sites using the svelte adapter-static mode which builds fixed html pages. For the scaffold I just followed a tutorial, adapted it for my needs and looked in to the previously mentioned svelte docs on the static adapter on how to publish on gh-pages.

But tbh, it depends on the amount of control you need over the site. Something like the default jekyll might be completely sufficient.

My best advice: go look at some blog sources (there are many on gh) and see how they handle their stuff, often the different frameworks / SSGs also have some sort of list showcasing pages built with the corresponding framework -- have a look at those for inspiration!

3

u/and0p Sep 12 '26

Insanely cool.

3

u/MelangeBot Sep 12 '26

That write up is amazing, had to give up half way cause I am just not mathemamically inclined enought but regardless it was super intressting. I still don't get how you can use ingame combinators to figure out where in the sequence the RNG is. But that's because I gave up on reading it. I might return when I feel smarter.

3

u/prash3r Speghetti Sep 12 '26

This is unironically the quantum physics research of the factorio universe.

Analyzing and then predicting and steering the probabilities of underlIng randomness events. Man I hope this never works in our universe.

3

u/RockRancher24 Sep 12 '26

We fucking bending reality and mocking the Gods out here

3

u/Dummy1707 Sep 12 '26

This goes in my hall of fame of Factorio players who inspire-but-frighten me.
Between the guy who recoded the game but with multithreading for his Py save, and the train-based signal-less megabase.

3

u/xTMagTx Sep 13 '26

If this were Vegas they'd put you a list.

3

u/Yggdrazzil Sep 13 '26

There is sadly one major drawback. Since I waited so long to release this the devs have made strides on the 2.1. update. Within it, the way the RNG is called also got a rework, which broke some of the assumptions I made while designing this contraption (mainly about how many calls a single craft makes) breaking it in 2.1, so it is currently limited only to 2.0.

That was heartbreaking to read.

I tried reading your documentation on Github but quickly realised my understanding of math was insufficient. I really liked the formatting of the blog though. The parts that I did understand were pleasant to read.

3

u/maceo107 Sep 14 '26

I can't stop thinking about this since I read it.

2

u/ArtieTheFashionDemon Sep 12 '26

Mr. Jackpots! Mr Jackpots!

2

u/Terrorscream Sep 12 '26

Exploiting the RNG seed is brilliant

2

u/DaMonkfish < a purple penis Sep 12 '26

The RNG knows where it is at all time because it knows where it isn't.

2

u/BibianaAudris Sep 12 '26

Nice work! I've been interested in this project too but never managed your dedication. Your designs are so much more clever than what I have thought of.

My thought on the output side: for a "practical" run in a real save, my conclusions were that the most "valuable" target is manipulating the recycling productivity (and maybe quality) to 100% for recycle-into-self things, like science bottles and planet-specific raw materials. It can utilize 1/4 or 1/16 RNG calls so:

  • Only a tiny amount of material will be consumed for skipping.
  • The crafting stage can become profitable within a few seconds
  • One can more easily afford to continuously re-leak the state and stop the whole world during each RNG manipulation window

2

u/ex0planetary Sep 12 '26

I'd dare say Wube should separate the RNG and make this an intended mechanic because it feels very much in the spirit of Factorio lmao

2

u/eisenefaust Sep 12 '26

Cool! Another independently derived version of this I saw back in May: https://www.youtube.com/watch?v=ZXwIYKzrkd8

2

u/AlbeniChocolate Sep 12 '26

only in 2.0 bummmmmmer i was getting excited. amazing concept though awesome work man

2

u/sharktail_tanker Sep 12 '26

Please man keep working on it, this is the only way I'd ever turn quality on in my games

2

u/sobrique Sep 12 '26

This is also a beautiful example of why good quality random is so important to encryption and security.

A password with a "time" seed and a 30 day expiry is a lot easier to "figure out" than "true random" might suggest.

I really love what you have done. I think you might be slightly mad, but it's genuinely delightful as an example of why "good" random is needed for security applications (like encryption)

2

u/leglesslegolegolas Sep 12 '26

This reminds me of the Infinite Improbability Drive from Hitchhiker's Guide to the Galaxy...

2

u/VeniABE Sep 13 '26

This cannot ever have enough upvotes.

2

u/QThellimist Sep 13 '26

One of the best posts in the whole subreddit 👏

2

u/tevelee Sep 13 '26

Well, it’s already broken by factorio 2.1

2

u/Fit_Giraffe_748 Sep 13 '26

haha yeah i totally understand this and am not confused at all

2

u/_Sanchous Sep 13 '26

Math players are goated👍

2

u/lukeybue Sep 13 '26

I feel, this post qualifies to be officially be marked "black magic". The last one on this forum was https://www.reddit.com/r/factorio/comments/6hi0ac/black_magic_2_belt_full_throughput_splitter_sorter/, which is comparable in witchcraft and sorcery.

2

u/Due-Chance-8540 Sep 14 '26

I fucking knew someone will figure out and reverse engineer the prng. congrats.

2

u/Litoprobka Sep 24 '26

RNGesus ex machina

2

u/Alpha1Actual Sep 12 '26

I’ll be honest, I only superficially understand what you’ve done but amazing work! This is the kind of thing I love the Factorio community for

2

u/alive1 Sep 13 '26

This right here is the pure, distilled, genius mastermind core of what makes this game so freaking amazing. You have tapped into something otherworldly. Divine. Absolute game mastery. Bravo.

1

u/oobanooba- The Factory Must Groove Sep 12 '26

That’s pretty clever, thanks op

1

u/Aesthetically Rushing all 3 planets simultaneously next playthrough Sep 12 '26

Legend.

1

u/Drfoxthefurry Sep 12 '26

trading randomness with speed sounds like a good trade off

1

u/miketastic_art Sep 12 '26

there's like, too many numbers.

1

u/2DHypercube Constructor of worlds Sep 12 '26

This is amazing and hilarious!

1

u/sobrique Sep 12 '26

This is terrifying dark magic and I love it.

1

u/unhott Sep 12 '26

amazing

1

u/cybertruckboat Sep 12 '26

Unbelievable!! 😍

1

u/constant-runtime Sep 12 '26

this is absolutely amazing! I would love a 10-minute long video explaining how RNG manipulation in factorio please.

1

u/solonit WE BRAKE FOR NOBODY Sep 12 '26

If this was Hollywood, OP would be immediately recruited as The Hacker Man in either a top-secret black book mission by gov; or a heist. Probably both.

Wait that's just Ocean 13

1

u/jbroombroom Sep 12 '26

This is insane.

1

u/MartinMystikJonas Sep 12 '26

This is the coolest, most insane and truly admirable piece of engineering I ever saw.

1

u/RyanSpunk Sep 12 '26

Peak Factorio

1

u/Evening_Archer_2202 Sep 12 '26

Congratulations!!!!

1

u/MrFizzyBubbs Sep 12 '26

This is sick

1

u/geneticfreak6 Sep 12 '26

Doesn't seem like it's within the spirit of the game. Obviously there's no such thing as random in this universe but it seems to me that it seems to be good enough

1

u/VeryGoldGolden Sep 12 '26

Soon people will defend their PhD thesis on Factorio.

1

u/IncredibleReferencer Sep 12 '26

As someone who absolutely hates the quality mod (don't come at me I'm glad ya'll like it its just not for me), this is so interesting I'm going to try it out.

1

u/Jester185 Sep 12 '26

They use the dark magic, we have a witch!

1

u/MattieShoes Sep 12 '26

Man, I love the factorio community :-D This is... legendary. heh.

1

u/bugprof2020 Sep 12 '26

Guass's dream of a world modeled by statistics has become a nightmare.

1

u/lordwafflesbane Sep 12 '26

mom come pick me up I'm scared they're doing black magic.

1

u/A_man_from_america Sep 12 '26

LETS GO GAMBLING!

1

u/pertur4bo Sep 12 '26

This is incredible.

1

u/jmpaul320 Sep 12 '26

This guy literally found a way to see the future

1

u/Alian713 Sep 12 '26

Reversing and forcing pRNG state to force quality outcomes... absolute genius XD

And the funny thing is, due to the ridiculous number of times the rng might be rolled in the game, they can't simply use a cryptographically secure pRNG or that kills perf. How would you even attempt to patch this as a dev 😂

→ More replies (3)

1

u/Specialist_Ice_1838 Sep 12 '26

Where Is the fun?

1

u/Inner-Ad-9478 Sep 12 '26

Still sane, engineer?

1

u/Then_Entertainment97 Sep 12 '26

We walk amongst oracles.

1

u/Panzerv2003 Sep 12 '26

Out with space casinos in with... whatever the fuck is this monstrosity. Great job engineer!

1

u/Head-Objective-7480 Sep 12 '26

Its glorious. I also play 2.0 so its perfect for me lmao, I have thought about upgrading to 2.1 for the logic and stuff, but i also dont want anything to bug my save of like 150 hours lol

1

u/Shiranui987 Sep 12 '26

Man this is amazing! I have to give my salute and congratulations to your work and research, but also to the devs, Its incredible that they could achieve such a turing perfect machine that we could analyze it and use it from within it lol

1

u/timonix Sep 12 '26

Oh.. ok... oh.... This is cursed

1

u/jsrobson10 Sep 12 '26

gambler: "trust me, i have a system"

1

u/maceo107 Sep 12 '26

WOW! Hope you can get it updated for the latest version.

1

u/StickyDeltaStrike Sep 12 '26

Mind blown … amazing

1

u/eric23456 Sep 12 '26

Awesome. If the devs want to fix it, they need to do a crypto-rng. Probably the fastest option would be to do a stream cipher using aes and generate a true-random seed for each game. People could reverse-engineer it by extracting it from the save game file, but pulling it in-game would be impossible.

1

u/ffsollie Sep 12 '26

We should name this around this posters name,
Maybe gegells giggle

1

u/Lovestick Sep 12 '26

This game keeps calling.

1

u/3davideo Doesn't use Flame Turrets Sep 13 '26

Neat, but even though I've never actually gotten around to quality during any of my playthroughs, I know the practical solution to quality isn't gambling, but quantity. If you need a d6 to roll a 1, you just need to roll lots and lots of d6s instead of worrying too much about individual rolls.

1

u/infam0usx Sep 13 '26

Oh god, doing stuff like that just using game mechanics is pure madness. Well done and mad respect!

1

u/Exciting-Carpet3873 Sep 13 '26

I refuse this amazing contraption and choose to remain stoopid. Thank you, but no thank you, SIR! If that is even your name!

1

u/Numerous_Schedule896 Sep 13 '26

Isn't this the same operating principle for rng they used to catch dream cheating rods in minecraft

1

u/paphnutius Sep 13 '26

"We'd like to invite you to play any other game in the casino, but your quality crafting days are over here."

1

u/lunat1cakos Sep 13 '26

i felt pain .

1

u/Rakomi Sep 13 '26

This is very impressive!!! I was worried you broke the system and that we'd now see this blueprint spammed in every competitive game...

1

u/Choice-Comment-1864 Sep 13 '26

Friends, is it possible to use a transport drone to deliver coal to chests or to a specific building? Thanks for the help.

1

u/authilmorros Sep 13 '26

I remember in minecraft the people from scicraft doing something similar, manipulating random events to allign mob spawns to a specific position

1

u/OtlichnikTop-Off Sep 13 '26

oh yea RNG manipulation my favorite

1

u/sabrewolfACS Sep 13 '26

fastinating!

could this be parallelised? meaning : at the same tick feed 100 different fabrications? and would it be easy to allow higher frequency with two step quality jumps (e.g. A) smelters/miners for rare iron and assemblers for rare wires. then B) assembler for highest circuits?

1

u/FoxStarSnake Sep 14 '26

ITS WIZARD TIME MOTHER FUCKER

1

u/Thankedsphere Sep 15 '26

mario maker 2 levels of technology

1

u/Maistho Sep 16 '26

This is really cool!

I saw another example of reverse engineering the RNG in a video game a few years ago, where speedrunners made a tool to solve a terrible minigame in windwaker

https://www.youtube.com/watch?v=1hs451PfFzQ

https://github.com/petersn/web-sploosh-kaboom

1

u/choicetomake Sep 16 '26

Factorio card counting.

1

u/Crystalcompany Sep 16 '26

Let's go gambling