# IVs of Wild Pokemon

#### X-Act

##### np: Biffy Clyro - Shock Shock
This question is not very simple to answer, so I thought it warranted a thread of its own. Before asking the question, here is how I was reasoning.

I was thinking about how the IVs of wild Pokemon are created. If they're created completely at random, that means that there is a 1/32 chance for an IV to be 31. This means that the probability of an IV not being 31 is 31/32.

Continuing the argument further, the probability that a Pokemon in the wild has all its 6 IVs not 31 is (31/32)^6 = 0.82655.

This means that the probability that a wild Pokemon has at least one of its IVs a perfect 31 is 1 - 0.82655 = 0.17345, or 17.345%. This is roughly 1 in 6 wild Pokemon (slightly more than that, in fact).

I'd like to know if this translates to what really happens, since I'm thinking that "1 in 6" Pokemon is too high of a percentage. My hunch is, if there are indeed 1 in 6 Pokemon to have a perfect IV in at least one of the stats, then the IVs are truly generated at random when a wild Pokemon appears. If not, then the IVs for wild Pokemon are not generated completely randomly, but there is a bias towards low or high IVs.

Is there anyone having somehow already tested this can shed some light on the matter? Feedback would be appreciated even if you had done this in Advance, GSC or even RBY, instead of DP.

#### Peterko

##### Never give up!
lol I just wrote this in the *coughyouknowwhatweareworkingoncough* and wanted to ask you later if it´s accurate?

probability for a wild pokémon to have one flawless IV = 6/32 = 1 in 6 (rounded up)
probability for a wild pokémon to have two flawless IVs = 15/1024 = 1 in 69
probability for a wild pokémon to have three flawless IVs = 20/32 768 = 1 in 1639
probability for a wild pokémon to have four flawless IVs = 15/1 048 576 = 1 in 69 906
probability for a wild pokémon to have five flawless IVs = 6/33 554 432 = 1 in 5 592 406
probability for a wild pokémon to have six flawless IVs = 1/1 073 741 82

I think they are really randomly generated, during my ditto hunt there were always around 5 or 6 with a flawless IV in one box (and I ´ve caught hundreds of them)...I think there are two little samples of ditto catching results in the what to do in emerald topic (though it was for a different purpose)

BobDoily´s results
30 magikarps caught
15 were same nature
0 had 31 DEF IV
10 did have a flawless IV though
5 of them were on synchronized nature

my results:
jolly, wonderfully outstanding synchronize ralts, max speed (only one)
21 dittos caught
10 jolly
-> one of them had 31hp/x/31def/25 sA/24sD/25speed, jolly
-> 31 speed once, quirky
-> 31 defense, jolly

#### X-Act

##### np: Biffy Clyro - Shock Shock
Well, actually I needed this for the little project we're working on... are we maybe writing the same thing? :] Anyway, thanks.

#### Team Rocket Elite

##### Data Integration Thought Entity
I know it's not completely random as you can't get a program to do that. But I couldn't tell you how close it is to being truly random.

I know Emerald's method of wild Pokemon generation had a tendency to generate identical Pokemon if you use Soft Reset. I threw a Master Ball at Kyogre, marked down its stats, reset and repeated. Eventually I started seeing Kyogre with identical nature and stats to old Kyogre I had seen before. After I had around 200 Kyogre marked down, I decided to just choose the best of those 200+. Eventually it did come around around and that's the one I have right now.

Once again in Emerald, I was hunting for a Ditto. I would catch one, check it's stats then soft reset if I didn't like it. Eventaully I started seeing identical Ditto.

So far in DP, neither of these event seem to occur. I don't know if they occur in RS or FL, I don't think so but I haven't really tested it much.

#### ΩDonut

##### don't glaze me bro
Ah. Glad to see I'm not the only one seeing identical Dittos.

#### X-Act

##### np: Biffy Clyro - Shock Shock
I know it's not completely random as you can't get a program to do that. But I couldn't tell you how close it is to being truly random.

I know Emerald's method of wild Pokemon generation had a tendency to generate identical Pokemon if you use Soft Reset. I threw a Master Ball at Kyogre, marked down its stats, reset and repeated. Eventually I started seeing Kyogre with identical nature and stats to old Kyogre I had seen before. After I had around 200 Kyogre marked down, I decided to just choose the best of those 200+. Eventually it did come around around and that's the one I have right now.

Once again in Emerald, I was hunting for a Ditto. I would catch one, check it's stats then soft reset if I didn't like it. Eventaully I started seeing identical Ditto.

So far in DP, neither of these event seem to occur. I don't know if they occur in RS or FL, I don't think so but I haven't really tested it much.
Ah. Glad to see I'm not the only one seeing identical Dittos.
I'm thinking this happens because of the random number seed.

Random number generation in machines isn't random, as such. It is actually pseudo-random, which means that the random numbers are generated by a mathematical formula which gives the next random number in a sequence. The thing is, if you give it the same initial number (called the seed), it will generate the exact same sequence of 'random' numbers. The seed is usually generated by the amount of time that has passed since the machine started. This is how random number generation in computers works, and I suppose it's how it works in consoles, too.

It might be that the random number seed for Emerald is only one byte long, which is a number between 0 and 255. So that would mean that there would only be 256 possible IV lists/Natures/Personalities/etc. for any soft-resetted Pokemon, which is why people start seeing the same exact Pokemon after a number of resets.

#### Peterko

##### Never give up!
TEST: route 101 (emerald)

100 pkmn caught, of which
50 were wurmple (W) = 8/16
43 were poochyena (P) = 7/16
7 were zigzagoon (Z) = 1/16

the 100 were four sets of 25 pkmn (as I don´t have more room in my boxes)
A. 3 flawless IVs, 12P, 12W, 1Z
B. 12 flawless IVs, 12P, 13W, 0Z
C. 4 flawless IVs, 8P, 15W, 2Z
D. 5 flawless IVs, 11P, 10W, 4Z

flawless IVs:
HP: P, W
AT: P, P, P, W, P
DEF: W, P, W, P, W, Z
SP.AT: P, P
SP.DEF: W, P, W
SPEED: W, W, W, W, P

one poochyena got flawless HP and AT
one wurmple got flawless AT and SPEED

so...
probability for a wild pokémon to have one flawless IV = 6/32 = 1 in 6 = 18.75 in 100 <-> I got 24 (20 single flawless IVs+ 2 with two flawless)
probability for a wild pokémon to have two flawless IVs = 15/1024 = 1 in 69 = 1.46484375 in 100 <-> I got two

@ TRE: that´s exactly what happened to me...I was catching an EON latios in emerald and started to write them down because some of them came again, some of them even on a second emerald of a friend...Eeevee trainer actually asked the same thing a month ago, here´s the link - I´ve posted my latios list there

yeah I think what X-Act is saying is how it works

#### X-Act

##### np: Biffy Clyro - Shock Shock
Nice, Peterko.

You actually caught 22 Pokemon that have at least one perfect IV, not 24. The Pokemon having more than one flawless IVs are counted as one. :]

I had missed that EeveeTrainer post. I counted the amount of Latias that you found, and you got 169 in all. There, you had said the following:

Peterko said:
...if you save and meet a pkmn at a particular time (dunno what a frame is), you can meet it again after a soft reset if it happens at the same "time"
This is in line with my random number seed theory. The random number generator is usually fed the 'time' taken from the start of the game.

#### Chozo

It might be that the random number seed for Emerald is only one byte long, which is a number between 0 and 255. So that would mean that there would only be 256 possible IV lists/Natures/Personalities/etc. for any soft-resetted Pokemon, which is why people start seeing the same exact Pokemon after a number of resets.
IMO, the seed is probably larger than that. You only need one seed on startup, and I can't imagine they'd be hurt for space that badly where a couple bytes on one variable would make the difference. According to the birthday paradox if the seed was only one byte long you should start seeing identical legendaries by the first couple dozen rather than a couple hundred.

#### X-Act

##### np: Biffy Clyro - Shock Shock
I'm aware of the birthday paradox. TRE only said that 'eventually' he started seeing the same Pokemon.

Anyway, if the seed is only one byte long, you should see a Pokemon you have already seen by around the 19th soft reset.

If the seed is two bytes long (between 0 and 65535), you should see a Pokemon you have already seen by around the 302nd Pokemon. I don't think this is the case.

The rough formula to find these '19' and '302' is (1 + sqrt(1 + s * ln(256))) / 2, by the way, where s is the maximum seed.

emeralds random number seed is 4 bytes. calling rand() always returns 2 bytes generated from these 4 bytes and changes the 4 bytes by multiplying and adding something.
depending on the intrest i think i could reasearch how exactly the seeding is done (yes it it is something with the time but i don't remember if it was rtc or gametime). but i don't really think i will get you interesting results.

the funny part is that if you call rand() twice in a row (getting 4 bytes) and if you don't waste any of that data it might (should?) be possible to predict the next result. which would severely limit the possibilitys of pokemon which can be created (unless there are a lot of unpredictable interrupts during the process). it would basicly mean if you know the pid or the you know everything. And if thats really the case and if you could figure this out it would also be possible to detect every cheated pokemon to this day ;)) Now that would be interesting but a bitch to reverse engineer.

#### Striker

Nice, Peterko.

You actually caught 22 Pokemon that have at least one perfect IV, not 24. The Pokemon having more than one flawless IVs are counted as one. :]

I had missed that EeveeTrainer post. I counted the amount of Latias that you found, and you got 169 in all. There, you had said the following:

This is in line with my random number seed theory. The random number generator is usually fed the 'time' taken from the start of the game.
Odd. I at one time had theorized while Soft Resetting for a Shiny Treecko that possibly I was hitting A at the wrong time and therefore I'd keep getting the same Treecko unless I waited a couple minutes before I checked the briefcase. I eventually gave up, thinking it's be too much work for someone like I who doesn't know how the Treecko's are generated to try to guess at what time should I hit A to get a Shiny.

So, basically, I had theorized that Shiny chance was also a property of the Random Number Generator. To take it a step to the side, I can also see how the Random Number Generator also has an effect on the EVs of a Pokemon.

#### X-Act

##### np: Biffy Clyro - Shock Shock
emeralds random number seed is 4 bytes. calling rand() always returns 2 bytes generated from these 4 bytes and changes the 4 bytes by multiplying and adding something.
That is how most random number generators work. It's usually:

NextRandomNumber = (PreviousRandomNumber * N + R) mod M

where N, R and M are chosen accordingly. (Usually, M = 2^n for some n, N is a very number, and R is usually a prime number. For example, in this case, M is 65536, since calling rand() returns 2 bytes. This is probably done by reading the last two bytes.)

the funny part is that if you call rand() twice in a row (getting 4 bytes) and if you don't waste any of that data it might (should?) be possible to predict the next result. which would severely limit the possibilitys of pokemon which can be created (unless there are a lot of unpredictable interrupts during the process). it would basicly mean if you know the pid or the you know everything. And if thats really the case and if you could figure this out it would also be possible to detect every cheated pokemon to this day ;)) Now that would be interesting but a bitch to reverse engineer.
So it seems that when you soft reset, the seed is generated again according to the time it has passed. If the same time passes, then the same sequence of random numbers is generated, which means that the Pokemon with the exact same stats is displayed for you to catch.

#### Prime

How do yall check the IV's so quickly? Do you just feed them a bunch of rare candies, write down their stats, and use the calculator, and then reset?

#### FiveKRunner

So does Synchronize play a part in this? About 1/3 of the Dittos I was harvesting had a perfect Def IV, just like the Abra I was using.

#### yamipoli

##### the only person more obsessive than jumpman
Here's a small smidgen of research. This is out of 120 dittos. This is only the amount of perfects they had, some of them overlapped.

Adamant Dittos Perfect IVs (120)

HP: |||||||||||||||||||||
ATK: |||||||||||
DEF: ||||||||||||||
SpA: |||||||||||||
SpD: |||||
SPD: |||||||||||||||||||

Also X-Act, I'm still waiting for that guy to send his results, but it's the dreaded "exams time".

#### X-Act

##### np: Biffy Clyro - Shock Shock
Here's a small smidgen of research. This is out of 120 dittos. This is only the amount of perfects they had, some of them overlapped.

Adamant Dittos Perfect IVs (120)

HP: |||||||||||||||||||||
ATK: |||||||||||
DEF: ||||||||||||||
SpA: |||||||||||||
SpD: |||||
SPD: |||||||||||||||||||
Wait, I'm not understanding this exactly. Is it 1 per |? If so, we have:

HP: 21
Atk: 11
Def: 14
SpA: 13
SpD: 5
Spd: 19
None: 37

So 37 out of 120 Adamant Dittos didn't have a perfect IV. This is way less than the expected number (82.66% of them = 99).

This is catching Ditto having an Adamant Synchronizer? How did you get these numbers?

#### ΩDonut

##### don't glaze me bro
emeralds random number seed is 4 bytes. calling rand() always returns 2 bytes generated from these 4 bytes and changes the 4 bytes by multiplying and adding something.
depending on the intrest i think i could reasearch how exactly the seeding is done (yes it it is something with the time but i don't remember if it was rtc or gametime). but i don't really think i will get you interesting results.

the funny part is that if you call rand() twice in a row (getting 4 bytes) and if you don't waste any of that data it might (should?) be possible to predict the next result. which would severely limit the possibilitys of pokemon which can be created (unless there are a lot of unpredictable interrupts during the process). it would basicly mean if you know the pid or the you know everything. And if thats really the case and if you could figure this out it would also be possible to detect every cheated pokemon to this day ;)) Now that would be interesting but a bitch to reverse engineer.
This has some really awesome implications in breeding. If the seed number is generated by the game time (which TRE's observations seem to support), then it should be possible, with a little reverse-engineering, to program a calculator that lists all the possible combinations of IVs that will be passed down\generated for an egg.

Then all one would need to do is plug in a favorable time into the calculator, play the game to that time (and keep track of the time between then and the previous save), and then save in front of the Daycare Man at that time. After that it's just a matter of restarting when the egg doesn't have the wanted combination.

loadingNOW, how did you get a look at the disassembled game code?

#### X-Act

##### np: Biffy Clyro - Shock Shock
This has some really awesome implications in breeding. If the seed number is generated by the game time (which TRE's observations seem to support), then it should be possible, with a little reverse-engineering, to program a calculator that lists all the possible combinations of IVs that will be passed down\generated for an egg.

Then all one would need to do is plug in a favorable time into the calculator, play the game to that time (and keep track of the time between then and the previous save), and then save in front of the Daycare Man at that time. After that it's just a matter of restarting when the egg doesn't have the wanted combination.

loadingNOW, how did you get a look at the disassembled game code?
It's not as easy as it sounds. First of all, to find the random number generator algorithm will be extremely hard. Secondly, the internal clock is usually measured in 1/60 of a second (called a jiffy). To time this perfectly in your game, you'd need to be superhuman.

to find the random number generator algorithm will be extremely hard
no it's not.
in DP this is the RNG (translated to c):
Code:
``````u16 rand() {
randbuf = (randbuf*0x41C64E6D)+0x6073;
return (randbuf >> 16);
}``````
But it's hard to control it to exactly it's seeded on the product of a lot of values which i have not mapped and even if you had a good seed it changes very often so you'd still need a lot of tries to actually use this for breeding if you had all the knowledge you said. And in breeding it's actually even more complicated than for say legendary fights.
On the other hand in the worst case they write the current rnd state back to save and then we can't do anything.

for reference this is SeedRNG in DP (asm this time) but this should be quite simple to reverse
Code:
``````RAM:02000FA4 SeedRng                                 ; CODE XREF: start+524p
RAM:02000FA4
RAM:02000FA4 var_28          = -0x28
RAM:02000FA4 var_24          = -0x24
RAM:02000FA4 var_20          = -0x20
RAM:02000FA4 var_1C          = -0x1C
RAM:02000FA4 var_18          = -0x18
RAM:02000FA4 var_14          = -0x14
RAM:02000FA4
RAM:02000FA4                 PUSH    {R4,R5,LR}
RAM:02000FA6                 SUB     SP, SP, #0x1C
RAM:02000FA8                 ADD     R0, SP, #0x28+var_1C
RAM:02000FAA                 ADD     R1, SP, #0x28+var_28
RAM:02000FAC                 BL      sub_201265C
RAM:02000FB0                 LDR     R0, =dword_21C48B8
RAM:02000FB2                 LDR     R3, [SP,#0x28+var_18]
RAM:02000FB4                 LDR     R4, [R0,#0x2C]
RAM:02000FB6                 LDR     R1, [SP,#0x28+var_24]
RAM:02000FB8                 LDR     R0, [SP,#0x28+var_20]
RAM:02000FBA                 LDR     R5, [SP,#0x28+var_14]
RAM:02000FBC                 ADD     R0, R1, R0
RAM:02000FBE                 LSL     R2, R0, #0x18
RAM:02000FC0                 LDR     R0, [SP,#0x28+var_28]
RAM:02000FC2                 LSL     R3, R3, #8
RAM:02000FC4                 LSL     R1, R0, #0x10
RAM:02000FC6                 MUL     R3, R5
RAM:02000FC8                 LDR     R0, [SP,#0x28+var_1C]
RAM:02000FCA                 LSL     R3, R3, #0x10
RAM:02000FCC                 ADD     R0, R0, R3
RAM:02000FCE                 ADD     R0, R1, R0
RAM:02000FD0                 ADD     R5, R2, R0
RAM:02000FD2                 ADD     R0, R4, R5
RAM:02000FD4                 BL      sub_201BA1C     ; do some calculations
RAM:02000FD8                 ADD     R0, R4, R5
RAM:02000FDA                 BL      writeRNG
RAM:02000FDE                 ADD     SP, SP, #0x1C
RAM:02000FE0                 POP     {R4,R5,PC}
RAM:02000FE0 ; End of function SeedRng``````
In case you guys are actually interested i i'd suggest using an emulator and a breakpoint on srand (so you cnow the current rng state, i'd tell you how to do that if someone wants to try this experiment) you might get some somewhat useful results ala "rng at game start is about 200-500 "ticks" lower than when fighting zapdos" (standing directly in front of it and pressing a as quickly as possible, but not all the time). If the results range is very big it's not even wroth investigating.

anyway the most interesting thing for me is that if you take this seriously a lot of iv/gender/shiny/trait combinations are simply impossible.

#### ΩDonut

##### don't glaze me bro
In case you guys are actually interested i i'd suggest using an emulator and a breakpoint on srand (so you cnow the current rng state, i'd tell you how to do that if someone wants to try this experiment) you might get some somewhat useful results ala "rng at game start is about 200-500 "ticks" lower than when fighting zapdos" (standing directly in front of it and pressing a as quickly as possible, but not all the time). If the results range is very big it's not even wroth investigating.

anyway the most interesting thing for me is that if you take this seriously a lot of iv/gender/shiny/trait combinations are simply impossible.
My biggest obstacle here is not actually having an emulator with a debug feature. Do you happen to know of any others besides No\$GBA (which doesn't have a free debug version)?

#### striker64

Based on what you said with soft resetting for legendaries, does this mean there is only a certain number of possible combinations of natures and IVs and no more outside of that realm can possibly be obtained? I wonder if this is consistent from cart to cart or how exactly that works.

And can Synchronize also pass IVs? This is news to me.

vor gba? vba-sdl(-h) would do fine for what i suggested (-h is not even required). for nds you are right just no\$gba wich is 15\$ non comercial SW with debug.

@striker: it's probably not consistent from cart to cart. any yes shiny, fixed nature and one special some sets of ivs are probably be impossible. we just don't know what these combinations are. on the other hand without shiny most combinations should be possible.

#### yamipoli

##### the only person more obsessive than jumpman
X-Act > I caught these in Emerald, with a Syncronize Gardevoir w/ 31 SpA, 31 SpD. Also note I didn't keep track of which ones had multiple stats on them, for example I'm not sure if it was in that group, but I got a ditto with 31 HP, 31 ATK, and 31 SPD, and another with 31 ATK and 31 SpA. and yes, | means =1.
I have more data, but unfortunately I wrote it on actual paper, and this was the only bit I have on the computer.
I found these out by using Pokemon Box and sorting by the highest in each stat, marking those dittos, and taking them to the IV guy and telling him. It was a fairly simple task as the dittos were lv 38 or 40, so there was only 2? or possibly 3 numbers that each stat could of been.

I caught about ~5,000 dittos, about a third of them were tried to syncronize adamant, a third modest, and the rest jolly. I found AT LEAST 6 with 3 31s, but absolutely none with 4 31s or better. Unfortunately I threw most of them away due to I only have 4 memory cards I can use for Pokemon Box (it holds 1500 pokemon per card), but I still have about 200 dittos i saved for various reasons (again, most of their IVs are written on paper I can't find). I may record all of there stats, if it's wanted.

anyway the most interesting thing for me is that if you take this seriously a lot of iv/gender/shiny/trait combinations are simply impossible.
is trait [like swarm/guts for heracross] actually determined by the PID or is it separate?

Also of note if you're really wanting a shiny pokemon and you have an egg with good IVs, is that you can trade it around to other games. I had a Bagon hatch that was shiny and it was only because it was on my ruby version rather than the game it was bred on. Thus we get that most IV combos are possible, it depends entirely on what game it's hatched on.

#### X-Act

##### np: Biffy Clyro - Shock Shock
X-Act > I caught these in Emerald, with a Syncronize Gardevoir w/ 31 SpA, 31 SpD. Also note I didn't keep track of which ones had multiple stats on them, for example I'm not sure if it was in that group, but I got a ditto with 31 HP, 31 ATK, and 31 SPD, and another with 31 ATK and 31 SpA. and yes, | means =1.
I have more data, but unfortunately I wrote it on actual paper, and this was the only bit I have on the computer.
I found these out by using Pokemon Box and sorting by the highest in each stat, marking those dittos, and taking them to the IV guy and telling him. It was a fairly simple task as the dittos were lv 38 or 40, so there was only 2? or possibly 3 numbers that each stat could of been.

I caught about ~5,000 dittos, about a third of them were tried to syncronize adamant, a third modest, and the rest jolly. I found AT LEAST 6 with 3 31s, but absolutely none with 4 31s or better. Unfortunately I threw most of them away due to I only have 4 memory cards I can use for Pokemon Box (it holds 1500 pokemon per card), but I still have about 200 dittos i saved for various reasons (again, most of their IVs are written on paper I can't find). I may record all of there stats, if it's wanted.
This is very interesting.

How many out of those 5000 dittos did you get with at least one perfect IV? In view of your other previous post, you should have gotten around 3000 to 3500 of them. Is this something you can confirm?