‹ BackHN Continuity

Thread

Reversing Factorio's RNG

255 points · 48 comments · jheitmann

  1. strstr · · focus · HN ↗
    I did an easier version of this in my college intro class. There was a class competition that involved rock paper scissors as a subcomponent, and ties were broken with randomness. You could rig Java’s prng so you would win all ties.

    The prng was seeded with usec time at first call. I called the rng a bunch of times to harvest entropy, and scanned the plausible usec times to find the seed. Then I primed the prng so I would win ties.

    Frankly, I assume I implemented this wrong, but the theory was there lol.

    1. rogueaine · · focus · HN ↗
      That’s not at all what the article proposed. The author constructed and transpose to the linear shift register coefficients and built a circuit network based on this to predict the next state (in the sandbox) and direct recipes.
      1. strstr · · focus · HN ↗
        From the article:

        > Sampling the current RNG through observations,

        > Computing the current internal RNG state,

        > Predicting the future internal states,

        > Calculating corresponding quality levels for each future call, and finally

        > Making use of the predicted levels with some adapters.

        The entropy->seeds (internal RNG state) step took more math of course. Frankly, I wouldn’t be surprised if they could have extracted the seeds without the math with a bit of RE and memory inspection.

        The version I did wasn’t predicting quality of course, it was predicting tie breakers

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.