Post subject: Re: How to determine the formula for a random number generator?
ALAKTORN
He/Him
Former player
Joined: 10/19/2009
Posts: 2527
Location: Italy
Warp wrote:
Out of curiosity, do you have any examples of actual games and the LCG values they use, that you have found this way (or in general)?
Tenchu: (x * 1103515245 + 12345) % 2^32 AWDS: (x+1)(4x+1) % 2^30 wait this is different. What I actually meant to say before was that cheating the RNG to 0 and advancing it 1 step allows you to figure out the formula if you’re good at maths or whatever. That’s how we found Tenchu and AWDS both.
Active player (477)
Joined: 2/1/2014
Posts: 928
I would watch the hell out of any and all videos of people who go through the process of finding RNG in different games using dissemble or other methods(with explanations). I watched a lot of sockfolder's testing on twitch which was super interesting but I havent seen anyone trying to find RNG on stream before.
Post subject: Re: How to determine the formula for a random number generator?
Masterjun
He/Him
Site Developer, Skilled player (1988)
Joined: 10/12/2010
Posts: 1185
Location: Germany
Warp wrote:
Out of curiosity, do you have any examples of actual games and the LCG values they use, that you have found this way (or in general)?
Paper Mario TTYD (GCN): RNG(x+1) = (( 1103515245 * RNG(x) ) + 12345) % 4294967296 Pokemon Black 2 (NDS): RNG(x+1) = (( 6726279311198226789 * RNG(x) ) + 2531011) % 18446744073709551616
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Post subject: Re: How to determine the formula for a random number generator?
Banned User
Joined: 3/10/2004
Posts: 7698
Location: Finland
Masterjun wrote:
Pokemon Black 2 (NDS): RNG(x+1) = (( 6726279311198226789 * RNG(x) ) + 2531011) % 18446744073709551616
It uses a 64-bit RNG? Well, I suppose they wanted a maximum amount of possible variation in a Pokemon game... (Although using a LCG for randomness has a pitfall that too many programmers fall into, simply because they don't know about it. The most common way of getting a random number out of a LCG which range is smaller than the seed size is to take the value modulo the desired range. This, however, is a bad idea because the lower bits of a LCG repeat much more often than the whole period of the LCG. If you want to take advantage of the full period of the LCG, you need to take the highest bits. Or, better yet, use a higher-quality RNG that has no such problem.)
Post subject: Re: How to determine the formula for a random number generator?
Masterjun
He/Him
Site Developer, Skilled player (1988)
Joined: 10/12/2010
Posts: 1185
Location: Germany
Warp wrote:
It uses a 64-bit RNG? Well, I suppose they wanted a maximum amount of possible variation in a Pokemon game...
Indeed, they even calculate the starting seed of the RNG using the input & clock among other things. (RNG manipulation is cool in that game)
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Post subject: Re: How to determine the formula for a random number generator?
Emulator Coder
Joined: 3/9/2004
Posts: 4588
Location: In his lab studying psychology to find new ways to torture TASers and forumers
ALAKTORN wrote:
Tenchu: (x * 1103515245 + 12345) % 2^32
Masterjun wrote:
RNG(x+1) = (( 1103515245 * RNG(x) ) + 12345) % 4294967296
I just wanted to point at that this set of constants appears near the top of the list of common parameters in the Wikipedia article I linked to in the first page. Those looking to hack RNGs should really collect all the constants there, as it's quite likely your game uses one of them.
Warning: Opinions expressed by Nach or others in this post do not necessarily reflect the views, opinions, or position of Nach himself on the matter(s) being discussed therein.