‹ BackHN Continuity

Thread

Reversing Factorio's RNG

255 points · 48 comments · jheitmann

  1. PennRobotics · · focus · HN ↗
    Stardew Valley has two random number seeds. One is the normal character seed. The other, your multiplayer ID, can be determined by analyzing the save file.

    Except! On the Switch, you can't easily access the save file AND the random number generator is different than on PC. There is a seed cracker that looks at your traveling cart listing and calculates the character seed. Maybe because it's less important and harder to observe, I haven't found any tool to crack the other seed and don't have time to attempt writing it myself.

    By inspecting cracked geode contents, you should be able to isolate your multiplayer ID and then predict random events on Nintendo just as PC players have done for the last decade with access to the save file.

    The C# code for the game is online and the Switch RNG is known, so you never have to work in the dark. It's three steps: ensure your Switch RNG implementation works by testing against the normal seed, ensure your geode RNG implementation works by testing against the PC RNG, and then apply the Switch RNG to the geode function enough times that only one seed could create your observed sequence.

    -----

    Two semi-related open questions: Are you able to solve as quickly while starting at ANY geode as you'd be solving from the first geode? Does the RNG eventually repeat, so it actually doesn't matter what your multiplayer ID is as long as you observe a unique sequence, since there will only be one continuation of that sequence?

    1. bombcar · · focus · HN ↗
      My favorite is the Doom random number generator, which is just a list of “random” numbers that it cycles through and if you know how to use it, you can do things like concentrate BFG attacks.
      1. xoxxala · · focus · HN ↗
        EverQuest also used pre-generated numbers. The randomness was derived from the large number of players using the same list.
        1. thaumasiotes · · focus · HN ↗
          That sounds like a pretty strong source of true randomness, frankly.

          (It's then filtered through the list, so the list needs to have good pseudorandomness properties anyway, but still.)

          1. eru · · focus · HN ↗
            > (It's then filtered through the list, so the list needs to have good pseudorandomness properties anyway, but still.)

            Not sure? Suppose your list only had two number 0 and 1, and you build your random numbers one bit at a time.

            Or more realistically, you have 256 numbers on the list 0, 1, 2, ..., 255 in order. If the 'large numbers of players drawing from the same list' assumption holds, it doesn't matter much that the list is in order.

            What's just a bit weird is why anyone would want to turn an embarrassingly parallel problem into something with a sequential bottleneck?

            1. [deleted] · · focus · HN ↗

              [deleted]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.