• Snag some vintage SPL team logo merch over at our Teespring store before January 12th!

RNG Manipulation in Pokemon Showdown

From a youtube comment by Myren Eario,


I happen to play a generation where games are quite long, and paralysis is very common. I checked through the replays of a random recent sample - 43 games of RBY OU in Week 1 of the recent RBYPL.
If I'm understanding correctly, one game (here) definitely reached a state where full RNG prediction was possible, with 52 FPs in 178 turns, without either player even trying - I wonder if Tarvold armed with full RNG prediction tools could have broken the game to steal a win here?
Four more games got over the 20 FP mark and relatively close to the 32 FPs mark - (this) had 28, (this) had 26, (these two) had 22. The game with 28 FPs also had two crits and a freeze by Turn 5, so I am quite comfortable saying a 'complete' RNG prediction tool would be able to break games relatively frequently in this tier, without needing to gimp yourself with Metronomes at all.

Damage rolls are also much easier to use for information, since you can pretty safely assume everything is max EVs/DVs, so I think damage rolls from enemy attacks are reliable sources of info to track the seed as well (and I think they give more info than in modern gens since there's >16 damage rolls in RBY, as opposed to every subsequent generation).
GSC might also be extremely easy to determine through received damage rolls for the same reason, but I'm not super clear on just how much info one roll gives

I think unless the cartridge RNG for RBY is so busted that this somehow doesn't apply, this might just completely break our meta. Haha, lmao


@ Myren it would be interesting, as a further proof of concept, if you could demonstrate the potential of these other seed detection methods on the replays provided. it's one thing forcing it with Metronome, it's another thing giving a demonstration based on actual tournament games that this tool can already break games. it would be big
I've just done some tests, and reversing the RNG from 32 full paras takes too long with the current algorithms.
I ran it for over an hour and then stopped it because it didn't finish.

Reversing the RNG from 15 events with 5% chance (like critical hits) works and takes only a few seconds of computation.
Reversing the RNG from 20 events with 10% chance takes half a minute on my laptop.
Reversing the RNG from 32 events with 25% chance (like full para) takes over an hour, so it seems to be infeasible unless we find a better algorithm.

Paralysis information seems to only be useful when it is combined with more interesting information.
Reversing the RNG from 10 crits and 10 full paras is doable and only takes 2 minutes on my laptop.

In the keepingiticy vs tarvold game we get the 10th crit at turn 161.
So at this point it would be possible to reverse the RNG with current algorithms in 2 minutes of computation time,
using only crit and para information.
But using only para information doesn't work, not because there are multiple possible RNG seeds compatible with the para, but because actually calculating the RNG seed is too difficult.
 
I've just done some tests, and reversing the RNG from 32 full paras takes too long with the current algorithms.
I ran it for over an hour and then stopped it because it didn't finish.

Reversing the RNG from 15 events with 5% chance (like critical hits) works and takes only a few seconds of computation.
Reversing the RNG from 20 events with 10% chance takes half a minute on my laptop.
Reversing the RNG from 32 events with 25% chance (like full para) takes over an hour, so it seems to be infeasible unless we find a better algorithm.

Paralysis information seems to only be useful when it is combined with more interesting information.
Reversing the RNG from 10 crits and 10 full paras is doable and only takes 2 minutes on my laptop.

In the keepingiticy vs tarvold game we get the 10th crit at turn 161.
So at this point it would be possible to reverse the RNG with current algorithms in 2 minutes of computation time,
using only crit and para information.
But using only para information doesn't work, not because there are multiple possible RNG seeds compatible with the para, but because actually calculating the RNG seed is too difficult.
Ok very interesting. Did you factor in RBY critrate being different (dependant on base speed, higher than 1/16 for a vast majority of pokemon)? Does it matter? I'm guessing it would make the critrate data a bit less reliable based on what you're saying.

I feel that if you squeeze all the information possible, between crits, FPs, misses, damage rolls, and the general length of RBY (and GSC) games, there's probably a world where you can put something together consistently. But it will take a lot of work to get a tool that can do all that.

Damage rolls alone might be really good though, RBY/GSC damage calculation formula has 39 rolls so it feels like most attacks will give you a lot of info
 
Last edited:
Yo Myren Eario, not sure if they work the same way, but could you hypothetically reverse engineer a seed from damage rolls? And (if you know) about how many turns would that take? That seems like a far more consistent/fast way to find a seed each game

edit: just saw amaranth’s post above, if this was already covered somewhere mb
 
Ok very interesting. Did you factor in RBY critrate being different (dependant on base speed, higher than 1/16 for a vast majority of pokemon)? Does it matter? I'm guessing it would make the critrate data a bit less reliable based on what you're saying.

I feel that if you squeeze all the information possible, between crits, FPs, misses, damage rolls, and the general length of RBY (and GSC) games, there's probably a world where you can put something together consistently. But it will take a lot of work to get a tool that can do all that.

Damage rolls alone might be really good though, RBY/GSC damage calculation formula has 39 rolls so it feels like most attacks will give you a lot of info
"Did you factor in RBY critrate being different (dependant on base speed, higher than 1/16 for a vast majority of pokemon)? "

I didn't know about that at all. Right now I just treated crits as a 1 in 20 event.
 
Yo Myren Eario, not sure if they work the same way, but could you hypothetically reverse engineer a seed from damage rolls? And (if you know) about how many turns would that take? That seems like a far more consistent/fast way to find a seed each game

edit: just saw amaranth’s post above, if this was already covered somewhere mb
Getting RNG information from damage rolls is something I have to look into. It could be very promising. I just don't know how well it works right now.
You usually don't know your opponents EVs, so you can't always tell what damage rolls you get. To figure out what damage rolls you get you could either use moves with recoil damage, or you could first user moves without damage rolls like Night Shade or Super Fang to figure out your opponents EVs and then figure out your damage rolls against enemies with known EVs.

Edit: Anyway, in Gen1 there seems to always be a damage roll number between 217 and 255. If you can figure out that damage roll number exactly for 12-13 attacks, that is enough to reverse the RNG. I will now look into whether this number can actually be figured out.
 
Last edited:
Getting RNG information from damage rolls is something I have to look into. It could be very promising. I just don't know how well it works right now.
You usually don't know your opponents EVs, so you can't always tell what damage rolls you get. To figure out what damage rolls you get you could either use moves with recoil damage, or you could first user moves without damage rolls like Night Shade or Super Fang to figure out your opponents EVs and then figure out your damage rolls against enemies with known EVs.

Edit: Anyway, in Gen1 there seems to always be a damage roll number between 217 and 255. If you can figure out that damage roll number exactly for 12-13 attacks, that is enough to reverse the RNG. I will now look into whether this number can actually be figured out.
The point is that in Gen1/2 have different mechanics: everyone just maxes out all EVs+DVs, and there are no Natures, so the damage rolls should be very reliable in these generations. They seem like a nightmare in Gen3+
 
The point is that in Gen1/2 have different mechanics: everyone just maxes out all EVs+DVs, and there are no Natures, so the damage rolls should be very reliable in these generations. They seem like a nightmare in Gen3+
In Gen2, the method of lowering DVs for Hidden Power is widely used. Also, the use of items like Charcoal Moltres and Magnet Zapdos is at least commonly known.
Even if it takes these into consideration, predictability is still high, but if there is a problem even just branching to around 4-8 cases, these things can become a problem for attempting to search the seed.
 
Last edited:
I think damage rolls could be extremely promising to determine the seed in randbats, where all of the sets are essentially public information so the rolls should be calculable. It definitely will take some additional math and calc-ing to determine what the actual roll was though.
 
From a youtube comment by Myren Eario,


I happen to play a generation where games are quite long, and paralysis is very common. I checked through the replays of a random recent sample - 43 games of RBY OU in Week 1 of the recent RBYPL.
If I'm understanding correctly, one game (here) definitely reached a state where full RNG prediction was possible, with 52 FPs in 178 turns, without either player even trying - I wonder if Tarvold armed with full RNG prediction tools could have broken the game to steal a win here?
Four more games got over the 20 FP mark and relatively close to the 32 FPs mark - (this) had 28, (this) had 26, (these two) had 22. The game with 28 FPs also had two crits and a freeze by Turn 5, so I am quite comfortable saying a 'complete' RNG prediction tool would be able to break games relatively frequently in this tier, without needing to gimp yourself with Metronomes at all.

Damage rolls are also much easier to use for information, since you can pretty safely assume everything is max EVs/DVs, so I think damage rolls from enemy attacks are reliable sources of info to track the seed as well (and I think they give more info than in modern gens since there's >16 damage rolls in RBY, as opposed to every subsequent generation).
GSC might also be extremely easy to determine through received damage rolls for the same reason, but I'm not super clear on just how much info one roll gives

I think unless the cartridge RNG for RBY is so busted that this somehow doesn't apply, this might just completely break our meta. Haha, lmao


@ Myren it would be interesting, as a further proof of concept, if you could demonstrate the potential of these other seed detection methods on the replays provided. it's one thing forcing it with Metronome, it's another thing giving a demonstration based on actual tournament games that this tool can already break games. it would be big
Finally, Persistent Positive RNG
 
If anyone was actually wondering, I posted my initial thoughts on how this would affect the Metronome Battle meta over in the Metronome Battle thread last night after personally trying it, because I didn't really grasp what the posts concerning the format here were exactly about, except for this guy who sums up the vision of high level Metronome play quite nicely.

this is already happening in the brain, albeit imperfectly. after thousands of hours of play, one can recognise or decipher seeds subconsciously as a "gut feeling". i'm curious to hear from more experienced players on this.

Overall it does let you press a given button (tera/Z-move/mega) with perfect knowledge in theory, but I feel it's still pretty impractical to get an advantage from in practice, mostly because of the strict setup requirements with speed ties being extremely common to bring through 2 of the same mon or Imposter Blissey, which currently messes up predictions (and even if speed tie calls are figured out, an opponent could run 2 of the same mon without the same speed and you wouldn't know for sure if it was a speed tie). There is also counterplay in potential additional random calls from unknown abilities like Poison Point or items like King's Rock, as mentioned in the end of the recent video, and the whole tradeoff of needing to wait ~2 turns to determine information instead of pressing tera early for value.
 
I'm not a maintainer, but for my own interest, I looked at the Pokemon Showdown code until I got tired of it.
Among them, I found two things that I think I should share, so I share them randomly.

1. Regarding the reproducibility of the RNG algorithm in Pokemon Showdown
RNG is producted by pokemon-showdown/sim
/prng.ts, and there was a comment stating that it was reproducing cartridge's RNG production algorithm.
1735521505298.png


If this comment is true and similar RNG manipulation is possible in cartridge's games, then I think there will be a growing opinion that this is an issue which should be accepted as progress of the metagame, rather than an issue which Pokemon Showdown should take measures against it.

However, at this point, I recognize that this may be false, at least for Gen1-4.

This source code assumes 64bit, but Gen1-2 uses 16bit algorithm (Pokemon RNG FFD3) and does not fall under this.
Also, for Gen3-4, the algorithm was commented out in this source code.
1735522377290.png


However, even in Gen1-4, if the RNG algorithm can be reproduced on the Type Script source code, I think there can be an argument that the same algorithm as cartridge should be impremented instead of taking measures against RNG manipulation.

To be honest with my personal opinion, having been in touch with competitive play in Gen 2 for over 20 years, it is mentaly very difficult for me to accept RNG manipulation as a progress of the metagame. But if it's possible in the real cartridge, I think I have to open to it.

2. A concern for team regeneration in random battles if RNG algorithm is changed
I found a statement in the Pokemon Showdown's github issues which states that RNG seeds are given for team regeneration in random battles.
Simulator RNG Seed produces inconsistent teams #10162

If the algorithm is changed to take measures against RNG manipulation, there is concern about the impact on this.
(However, looking at this issue, it seems that there have been cases in the past where teams from past replays could not be reproduced, so it may not be an issue to be too concerned about)
 
Last edited:
The Linear Congruential Generator used in PS is the same (with the same constants (a=0x5D588B656C078965, c=0x0000000000269EC3) and everything) as used in gens 5 and 6 on cartridge. Later gens are harder-to-impossible to crack like this on cartridge, but PS never changed because it didn't need to. Now it needs to.

2. A concern for team regeneration in random battles if RNG algorithm is changed
I found a statement in the Pokemon Showdown's github issues which states that RNG seeds are given for team regeneration in random battles.
Simulator RNG Seed produces inconsistent teams #10162

If the algorithm is changed to take measures against RNG manipulation, there is concern about the impact on this.
(However, looking at this issue, it seems that there have been cases in the past where teams from past replays could not be reproduced, so it may not be an issue to be too concerned about)
Any PRNG still requires a seed, and from that seed the team generation can still be reproduced, so this wouldn't impact that. Because the team generation algorithm changes all the time it "breaks" for old replays in the sense that using the seed on a newer PS version will not yield the same result, but a replay contains the version as well so you can still use that PS version to reproduce everything, which is sufficient for debugging and stuff.
 
From what I can see for GSC, if someone were to make one of these based off damage rolls the you would be able to get the rng seed within 15-18 instances of you taking damage (depending on what is attacking and being hit). This is assuming that I understood it correctly, i.e. the set of seeds is continuously filtered down with each new piece of information until one initial seed remains.

This is a huge advantage given to anyone using this tool in gen2 and likely gen1 as well, which becomes usable in the early-mid game - which would change the way the tier is played completely (e.g. curse lax can stay in on machamp risk free or knowing what talks will be called). I don't think this advantage is acceptable for a few reasons: 1) its an offsite tool so will hurt new/not in the know players 2) its a big divergence from what it aims to simulate (i.e. link cable/in person play), as its never acceptable to show up with a pc to try and get the rng seed (like showing up with a card counting device) 3) it makes the game much more boring/less fun - it will reduce the ability to play back into a game if I can see when a crit is called/a roll will go my way.

It should be really be made obsolete like Vertigo said as its a matter of time before someone makes one of these that is usable on a normal game, and they may not want to share it.
tbf damage calculators are also offsite tools that you can’t exactly show up to official tpc events with, and those have become commonly used on smogon. i’m not saying they’re at the same degree, but idt unfair advantage is a reasonable claim when this could easily be integrated on site
 
Hope they account for this shit with updated RNG. This is huge, and seems to have more impact in earlier gens if I'm understanding correctly?

At it's core Pokemon is rendom numbers, so being able to consistently manipulate it could be a death knell for competitive simulator play.
 
I understand most of the video except the part of the RNG Calls. I don't get where would you get three RNG Calls from. One from the possible Speed tie, and one from the crit from Earthquake, but where would the third one come from?

Besides that, excellent investigation, you just made my 8 year old dream come true.
 
tbf damage calculators are also offsite tools that you can’t exactly show up to official tpc events with, and those have become commonly used on smogon. i’m not saying they’re at the same degree, but idt unfair advantage is a reasonable claim when this could easily be integrated on site
For in person events you would look up the common calcs ahead of time and memorize them, similary to prior to honko's calc people would keep lists of common calcs and rolls for use during games or planning. The current damage calc only made the using existing damage rolls and thinking more precise and easier to use, but looking at damage calcs was always part of part of the game.

Looking ahead for possible rng rolls would be a fundamental change to how the game is played and it is fair game to decide to if we want to include it as a viable tool or not (as unlike a damage calc you cant make one on your own and is not currently part of how the game is played). I think the changes would be mostly negative (eg seanobiwan brought up swagger zapdos being much more viable) but I agree if rng-reversing is approved it should be worked into the site.
 
I understand most of the video except the part of the RNG Calls. I don't get where would you get three RNG Calls from. One from the possible Speed tie, and one from the crit from Earthquake, but where would the third one come from?

Besides that, excellent investigation, you just made my 8 year old dream come true.
The end of my first RNG manip video goes quite in-depth into random calls in Gen3.

Every Earthquake does an Accuracy Check, a Critical Hit Check and a Damage Roll.

In Gen2-3 at the beginning of every turn there is a random roll, that determines whether Quick Claw will activate this turn (even if noone is using any Quick Claw).

Recover does 0 random rolls.

So if we just spam Earthquake and Recover, then between the damage rolls of two Earthquakes we always have a Quick Claw roll, an Accuracy Check and a Critical Hit Check. So between two damage rolls we always have exactly 3 random calls.
 
This will probably get patched out since knowing the rng seed is against the spirit of Pokemon and would radically change how we are used to playing this game.

I kinda think that's a shame, though? I'm imagining a silly hypothetical where this sort of thing was discovered back in the netbattle days or whatever and it became a norm in the community to play this game while knowing the rng seed at the very start of the battle. You would know not to stay in and click Recover cause otherwise your Pokemon would get crit. Ice beam will freeze this turn (for the second time?) so you could pick your best sac. 50/50s like double Protect or Speed ties wouldn't ever be turns where both players just accept what comes since the outcome would be known before the move is made. This would even open up a whole new dynamic to battles where both players are trying to manipulate the number of calls in a way that lines up favorably with how they are positioning their Pokemon so that could benefit/avoid the crit proc on the 13th call from current turn. For an adv ubers anecdote, I'm also thinking of all those Deo-A speed tie endgames that would be played completely differently. Common movesets would change a lot as there would be value to moves/items purely for their ability trigger varying amounts of rng calls. Protect would probably be more powerful since you could use it to skip bad rng turns and/or abuse the double tect turns for your passive damage stalling.

Basically, knowing the seed would almost completely removable the uncontrollable, third party factor of Pokemon that currently has so much unpredictable influence over the final outcome of battles. Maybe I'm just not thinking these things through far enough, though. Anyways, there's not much point to this, I just thought it was fun to consider.
 
This will probably get patched out since knowing the rng seed is against the spirit of Pokemon and would radically change how we are used to playing this game.

I kinda think that's a shame, though? I'm imagining a silly hypothetical where this sort of thing was discovered back in the netbattle days or whatever and it became a norm in the community to play this game while knowing the rng seed at the very start of the battle. You would know not to stay in and click Recover cause otherwise your Pokemon would get crit. Ice beam will freeze this turn (for the second time?) so you could pick your best sac. 50/50s like double Protect or Speed ties wouldn't ever be turns where both players just accept what comes since the outcome would be known before the move is made. This would even open up a whole new dynamic to battles where both players are trying to manipulate the number of calls in a way that lines up favorably with how they are positioning their Pokemon so that could benefit/avoid the crit proc on the 13th call from current turn. For an adv ubers anecdote, I'm also thinking of all those Deo-A speed tie endgames that would be played completely differently. Common movesets would change a lot as there would be value to moves/items purely for their ability trigger varying amounts of rng calls. Protect would probably be more powerful since you could use it to skip bad rng turns and/or abuse the double tect turns for your passive damage stalling.

Basically, knowing the seed would almost completely removable the uncontrollable, third party factor of Pokemon that currently has so much unpredictable influence over the final outcome of battles. Maybe I'm just not thinking these things through far enough, though. Anyways, there's not much point to this, I just thought it was fun to consider.

Bro you're overthinking it.

We play a luck management (read gambling, if you want) type game. Imperfect information is another part of it. You mess with either aspect, and we're in the realm of literal cheating.

We're talking about everyone going into a casino with loaded dice, or knowing everyone's hole cards in poker. We might as well mandate perfect knowledge of each other's team sets through the simulator, or maybe even screenshare each others' moves as we're choosing them.

Like, yes all these are different games, in a sense of the word, but almost certainly not a better one.
 
Last edited:
Back
Top