Hacker News
Reversing Factorio's RNG
PennRobotics
|next
[-]
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?
bombcar
|root
|parent
[-]
nomel
|root
|parent
|next
[-]
PennRobotics
|root
|parent
|next
|previous
[-]
the closely related not-at-all-random fizzlefade from Wolfenstein: https://fabiensanglard.net/fizzlefade/
torvin92
|next
|previous
[-]
Aardwolf
|next
|previous
[-]
That's an RNG from 1996. It seems neither recent C++ standards, nor boost, know anything about the modern PRNGs that are much faster yet better at passing test suites
EDIT: Ok the above quote was from 2014, and boost seems to know some now! https://www.boost.org/doc/libs/latest/doc/html/boost_random/...
cmovq
|next
|previous
[-]
typedef xor_combine_engine<
xor_combine_engine<
linear_feedback_shift_engine<uint32_t, 32, 31, 13, 12>, 0,
linear_feedback_shift_engine<uint32_t, 32, 29, 2, 4>, 0>, 0,
linear_feedback_shift_engine<uint32_t, 32, 28, 3, 17>, 0> taus88;
chaz6
|next
|previous
[-]
https://devblogs.microsoft.com/cppblog/bringing-correctly-ro...
It mentions how they had to use a custom math library to differences in results on different platforms causing multiplayer sync issues.
harlan_pdx
|next
|previous
[-]
pema99
|next
|previous
[-]
jvanderbot
|root
|parent
[-]
TL;DR: Wired up an in-game predictor of RNG output and used it to only craft legendary items when RNG would line up to roll legendary.
From base to legendary at a suprisingly high rate. Look very closely at the video at the top of the post - what I was seeing didn't sink in until I had finished the article. Amazing.
hbroom
|next
|previous
[-]
strstr
|next
|previous
[-]
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.
3eb7988a1663
|root
|parent
|next
[-]
e28eta
|root
|parent
[-]
google surfaces a couple of HN posts, but the source (cigital.com) seems to be a dead domain at this point:
https://news.ycombinator.com/item?id=288138
https://news.ycombinator.com/item?id=9914607
It's a bad shuffle implementation + using time of day as seed (reducing search space). Using the player's 2 cards and the 3 flop cards, it finds the RNG seed in real time, and then future hands (on the same server) are solved in "under one second!"
rogueaine
|root
|parent
|previous
[-]
strstr
|root
|parent
[-]
> 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