Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Pokémon Discussion

2nd Gen Roaming Mechanics - Page 1

2nd Gen Roaming Mechanics

Posted by: IceFlame
Date: 2016-06-30 06:29:24
I took a rather obsessive interest in this recently, and thought I would write up my findings, to help others and put it up for checking.

All testing was on English Crystal V1.0, but I'm assuming it works the same on the other games unless some evidence comes up for otherwise.



[size=18pt]Johto Map showing connections[/size]

[img]http://i.imgur.com/D2UmKJs.png[/img]



[size=18pt]TLDR catching guide[/size]

Preparation
Buy about 50 Super Repels.
Catch a Hoppip and give it 10 Carbos.
Level it until it evolves to Jumpluff and gets at least 98 speed, not exceeding level 40.
Make sure it learns Sleep Powder. Teach it Headbutt so it can do a reasonable amount of damage.
Put it at the top of the party.

To find the Beasts for the first time
Go to the eastern patch of grass on Route 36 and get on the bike.
Use a Super Repel. Cycle around in the grass until it expires.
Go into the Ruins of Alph courtyard.
Go into the gatehouse and back out into the Ruins of Alph courtyard.
Head back to the patch of grass and repeat.
Make sure to never double back on yourself onto Route 36 (e.g. Route 36 -> Gatehouse -> Route 36, or Route 36 -> Violet -> Route 36). That makes the Beasts avoid you.
If you want to reject bad DVs, then once you see one for the first time, go hunt it and forget about the others for now. Don't save between the first time you see it and when you catch it and check its stats!
Otherwise, it's quicker to find all of them at this stage, and then track them in parallel. Save the game if you see one for the first time and it runs away, so you can reset if it gets killed later, without losing the "seen" status.

To find the Beasts (not for the first time)
Jump to the last section of this post and follow the instructions there.
Leave Jumpluff at the top of the party and keep using the Repels when searching the grass.

In battle
Use Sleep Powder on the first turn and if the Beast wakes up.
Reduce its health while it's asleep.
Reset the game if you kill it by accident.
Once it's at low health and asleep, throw Ultra Balls.
If it runs away, don't worry, just find it again using the "not for the first time" way.



[size=18pt]Memory Map[/size]

Probably for English Crystal only.


dfcf species (f3=Raikou)
dfd0 level (0x28=40)
dfd1 map group
dfd2 map number
dfd3 current HP
dfd4 DV
dfd5 DV

New game, not yet released from Burned Tower: 0000 ffff 00 0000
Roaming but not met in battle yet: f328 xxxx 00 0000
Roaming after it was met: as above (DVs generated when first met)
If caught or killed: 0028 ffff 00 xxxx (level and DVs stay)

dfd6 species (f4=Entei)
dfd7 level (0x28=40)
dfd8 map group
dfd9 map number
dfda current HP
dfdb DV
dfdc DV

Next 7 bytes unused Suicune:
0000 ffff 00 0000 (at all stages of game)

dfe4 map number player was last in
dfe5 map group player was last in
dfe6 map number player was in the time before last
dfe7 map group player was in the time before last
The above 4 are one step later most of the time,
but the description is for what they are during the instant when it matters.
Fly/teleport to the same place does rotate them (so they become the same).

dcb5 map group player is currently in
dcb6 map number player is currently in

Possible roaming location values (written map group, map number, route number):
1803 r29
1a01 r30
1a02 r31
0a01 r32
0806 r33
0b01 r34
0a02 r35
0a03 r36
0a04 r37
010c r38
010d r39
0205 r42
0905 r43
0206 r44
0508 r45
0509 r46
ffff n/a




[size=18pt]When do they move?[/size]

The Beasts stay where they are:
Move around within one area
Battle wild Pokémon
Cut
Surf
One of them is caught or killed

The Beasts move, most times to an adjacent route:
Move to next area
Move into or out of a building or cave
Go up or down a ladder
Dig
Use an escape rope
One of them flees (they all move)

The Beasts jump randomly:
Load game
Fly
Teleport



[size=18pt]What happens in battle?[/size]

The Beast's current HP is kept between encounters.
As above, the DVs are generated when first met in battle, and kept between encounters.
Sleep prevents fleeing.
The Beast doesn't flee the turn it wakes up.
It uses an attack the turn it wakes up (can be Roar).
Paralysis doesn't prevent fleeing.
Paralysis is not kept between encounters (would be a problem if it did!)
Mean Look prevents fleeing, but doesn't affect Roar. It might be worth using in addition to a sleep move.
Fast Balls are well-documented not to work on these guys.

Fleeing priority:
This depends on the in-battle speed of the two Pokémon (after the Badge Bonus is applied).
The Beasts usually flee before a slower Pokémon can use a regular attack, but not always. If Entei or Raikou's Roar is replaced with another attack, the slower Pokémon no longer has a chance to attack first.
Against Entei: a faster Pokémon, or a Pokémon using Quick Attack, always hits first.
Against Raikou: a faster Pokémon using a regular attack, or a slower Pokémon using Quick Attack, usually hits first, but not always. If Raikou's Quick Attack is replaced with something else, Raikou no longer has a chance to flee first in these cases.
A faster Pokémon using Quick Attack always hits first.
From this, I conclude that the Beast still chooses an attack even though it's trying to flee, and fleeing has the same priority as the attack chosen.

We need a faster Pokémon with a sleep move. But since Raikou knows Quick Attack, it will sometimes flee before the faster Pokémon can do anything. Too bad.
If the sleep move misses, or if the Beast wakes up and uses Roar, that's also too bad.



[size=18pt]Which Pokémon can hunt Raikou?[/size]

Raikou has base speed 115. With a 15 speed DV, it has 109 speed at level 40. The hunter needs a sleep move and at least 110 speed, which is 98 speed with the 9/8 Badge Bonus.

It would be reasonable to use Repels to find a Beast for the first time (with any Pokémon level 35-40 at the top). Then use the Pokédex to track it. Once on the same route, put a high-level Pokémon with a sleep move at the top, and just go through all the wild encounters until the Beast turns up. It doesn't seem to change route just from battling. My False Swiping Parasect would get 98 speed about level 80. At level 82, Level Balls become useful.

If we want to use Repels for the catch encounter, the hunter needs a maximum level of 40 (40 itself is OK).
Gengar/Jumpluff have base speed 110. They are comfortably fast enough. With 10 Carbos and the Badge Bonus, they outspeed Raikou at level 40 with any speed DV. In many cases the player won't be able to get Gengar because it's a trade evolution.
Haunter/Jynx have base speed 95. This seemed rather tight before I noticed about the Badge Bonus. With 10 Carbos and the Badge Bonus, they only need a Speed DV of 2.
Sleep Powder and Lovely Kiss are much more accurate than Hypnosis, and the most important thing here is to put the Beast to sleep on the first turn, so Jumpluff or Jynx are probably more suitable than the Ghosts.
Once the Beast is asleep, if the HP is not yet low enough, it might make sense to switch to a high level False Swiper, since the current HP is kept between encounters.



[size=18pt]How long to search?[/size]

Time for some asm reading.
In PokeCrystal, the function RandomEncounter is called every step if there are encounters in the current area.
Nonzero wWildEncounterCooldown (d452) prevents encounters and is decremented every step. I didn't follow the code that sets it, but watching it in-game, it is set to 4 when entering a map (which doesn't matter for grass routes). It is also set to 5 after a wild encounter, but it stays at 0 when using Repel.
Next is TryWildEncounter. It loads the encounter rate from wMornEncounterRate etc (d25a-d25c). Watching those in-game, they are always 25 on the relevant routes, except on Route 39 they are 5 for some reason. Better not search on Route 39 then.
Music can double this number (but the radio stops when we change route so that would be a pain).
We get a battle if a random number 0-255 is less than the modified encounter rate.
So generally, there is 25/256 chance of a battle per step.
Next is ChooseWildEncounter. Believing the comments there, if we are in the right map, there is 25/256 chance of this battle being a particular roaming Beast. If it's not a Beast, then a regular wild encounter is chosen (which could be nothing under some condition that I don't understand).
Repel is checked after all this.
As far as I can see, the bike doesn't affect anything here, so might as well ride it to cover more steps in the same amount of time.

If using Repel, it makes sense to think of it per step.
Each step there is 25/256 chance of a battle and of that, 25/256 chance of the wanted Beast. This gives 625/65536 per step overall (just under 1%).
This is a binomial probability calculation, giving 62% chance of finding the wanted Beast within 100 steps, 80% within 200 steps, or 91% within 250 steps.
So if we don't know whether the Beast is here, a possible strategy is to go to the patch of grass we want to search, use a Super Repel (200 steps) or Max Repel (250 steps) depending on preference, and move around in the grass until it expires.
This is much longer than most advice around the internet seems to be suggesting.

It not using Repel, it makes sense to think of it per battle.
There is 25/256 chance of meeting the wanted Beast per battle. That makes a 90% chance of finding it within 23 battles.
But in any case, it would be pointless to do this unless we already know the Beast is here, so keep going until finding it.



[size=18pt]How do they move?[/size]

The function UpdateRoamMons in PokeCrystal appears to be the thing for normal movement, and JumpRoamMons for a random reset e.g. when loading the game.

RoamMaps is a graph containing the available connections from each route. Studying UpdateRoamMons, for each Beast it loads the available connections from the current route, then tries to pick one. It picks a random number from 0-31. If this number is 0, it moves to a random route (JumpRoamMon). Otherwise, it takes this number mod 4 as an index into the list of available connections (so the 0th connection is slightly less likely than the others). If the number is too high for the length of the list, it starts again and picks a new random number from 0-31 (so it's more likely to jump to a random route if there were fewer connections available). As far as I can see, it also starts again if the selected connection matches the route the player was in before the last-but-one map change (but this doesn't apply to a random jump). This last point turns out to be very important.

For a random jump (JumpRoamMon), whether called from JumpRoamMons or from drawing a 0 in UpdateRoamMons, it picks with equal probability from the 16 available routes, excluding the route the player is currently in.



[size=18pt]How to find a Beast for the first time?[/size]

It's possible to simulate the above algorithm for a very large number of repetitions. If I understood the asm correctly, and implemented my Python correctly according to that understanding, this will tell us the chance of success of various strategies.

http://pastebin.com/U3jfMrMm

If the player is not around, e.g. going in and out of buildings in a city, the chance of a Beast being on a particular route will depend mostly on the connection graph. It works out with the highest chance of about 10% for Route 36 or 42, and a 7.5% chance for the next highest few. Route 39 has the lowest chance, so that's another reason not to search there. I thought that using Teleport/Fly (triggering a random reset) would negate the advantage of the unbalanced graph, but it seems that a random reset followed by one move gives close to the same distribution as roaming for a long time, and after 3 moves it's almost indistinguishable.

Sample results from 100000 trials:

route  reset  1 move  2 moves 3 moves many
29      6.2%    6.1%    5.8%    5.5%    5.0%
30      6.3%    4.9%    5.1%    5.1%    4.7%
31      6.2%    7.2%    7.4%    7.6%    7.5%
32      6.4%    6.8%    7.3%    7.2%    7.3%
33      6.2%    5.2%    5.3%    5.0%    4.9%
34      6.3%    6.2%    5.1%    5.5%    5.0%
35      6.3%    4.9%    5.4%    4.8%    5.1%
36      6.3%    9.3%    8.8%    9.8%    9.7%
37      6.2%    5.3%    7.6%    6.6%    7.3%
38      6.1%    9.4%    6.5%    8.1%    7.6%
39      6.1%    2.5%    3.4%    2.5%    2.8%
42      6.3%    8.9%    9.1%    9.2%    9.7%
43      6.2%    3.8%    4.9%    4.5%    5.0%
44      6.3%    7.7%    6.6%    7.5%    7.5%
45      6.3%    5.2%    5.8%    5.1%    5.3%
46      6.2%    6.6%    5.9%    6.1%    5.4%


So we know where the Beast is most likely to be. The problem is, there is a tendency for it not to be where the player is looking for it.

I have seen in a few places the advice to move back and forth between two maps where one map has grass close to the exit, e.g. search Route 37 going in and out of Ecruteak every so often, or search Route 42 going in and out of Mount Mortar. This sounds sensible. But if I'm not mistaken here, it will literally never work.

With Route 36 or 42 being the best, it seems plausible to search Route 36 and go in and out of the Ruins of Alph. (The National Park is further from the grass and dismounts the bike.) Just going into the gatehouse and back, the Beast never appears. It's important to go all the way through into the ruins courtyard. But the Beast is still avoiding the player here: I get 7% chance of it being on Route 36 during the search. Going out and in twice (on the ruins side, not the Route 36 side!) raises it to 8.5% which almost eliminates the "avoiding the player" effect. A third time makes little difference.

It also seems plausible to Teleport to Violet or Mahogany, and move onto Route 36 or 42 respectively. Again, if that's the only thing done, the Beast will never appear. Violet works out slightly better here. Using Teleport twice gives a 9% chance. Using Teleport once and walking in and out of the Pokémon centre gives a 8% chance. (This must be because the Beast can't walk onto the target route when the player enters the Pokémon centre, and the missing 1% is from the cases where it walks away from the target route and then straight back again.) Using Teleport twice and walking in and out of the Pokémon centre is up to 9.5%, pretty much as if the player wasn't there. "Fly to Violet, go in and out of Pokémon centre, move to route 36, Fly to Mahogany, go in and out of Pokémon centre, move to route 42" gives about 9%, and might be slightly quicker since Mahogany is closer to the grass.

Even if Teleport/Fly strategies can give a slightly higher chance of the Beast being on the target route, they require more concentration and the player spends less time in the grass than for the Ruins of Alph strategy, so that's a matter of preference.



[size=18pt]How to find a Beast (not for the first time)?[/size]

A possible strategy based on the above (not simulated):

Fly to Mahogany.
Check Pokédex.
If there is a Beast on Route 37, 38, 43 or 44 then move to Route 42.
Otherwise, if there's one on Route 42 or 45 then move to Route 44.
(Moving to Route 43 is no use because of the gatehouse: if the Beast could be met on Route 43 in two turns, it will be on Route 42 or 44 next turn.)
Otherwise, if it's anywhere else, Fly to Mahogany again.
Once on Route 42 or 44, check Pokédex again.
If the Beast is here, get ready to battle it.
If it went the wrong way, resist the temptation to chase it, and switch to Violet.

Fly to Violet.
Check Pokédex.
If there is a Beast on Route 32, 35 or 37 then move to Route 36.
Otherwise, if there's one on Route 31, 33 or 36 then move to Route 32.
(Moving to route 31 is almost no use for the same reason as above. In this case, the Beast could come from Route 29, but it's a long shot.)
Otherwise, if it's anywhere else, Fly to Violet again.
Once on Route 32 or 36, check Pokédex again.
If the Beast is here, get ready to battle it.
If it went the wrong way, resist the temptation to chase it, and switch to Mahogany.

It's reasonable to hunt more that one Beast at a time. Make sure the Pokédex is in Old or New Pokédex mode (not alphabetical), as then the Beasts will be adjacent. The Up and Down controls can switch between them when on the description screen, though not when on the map itself.

Re: 2nd Gen Roaming Mechanics

Posted by: Háčky
Date: 2016-06-30 09:00:05
Thank you! I was tempted to look into this the last time I was trying to track down the beasts, but never did.

Roar has 1 priority. If fleeing has the same priority as the selected move, that would explain why slower Pokémon can sometimes attack before the beast flees.

Re: 2nd Gen Roaming Mechanics

Posted by: IceFlame
Date: 2016-07-01 06:34:10

Roar has 1 priority. If fleeing has the same priority as the selected move, that would explain why slower Pokémon can sometimes attack before the beast flees.

You're right - if Roar is replaced with another attack, the slower Pokémon no longer gets a chance to attack first. I'll rewrite that section.

That's amusing. The Beast could have escaped, but because it chose to use Roar, it got trapped.

Re: 2nd Gen Roaming Mechanics

Posted by: Yeniaul
Date: 2016-07-01 14:13:12
MY GOD this is detailed! I eventually had to dump my save, fire up an emulator, use memory manipulation (Rewrote which pokemon was selected the frame of selection… I'm a dirty cheater :P) then republish to cart. (Pain in the ass, as Nintendo has SRAM set to direct access read-only on the hardware level of their carts, so only software can write to it. Lucky for me, the HW_WRITE contact was still on the board, so I just stuck a new pin in the SRAM unit and jumped it, allowing access… eat a fat one, Nintendo)

Re: 2nd Gen Roaming Mechanics

Posted by: SatoMew
Date: 2016-09-20 09:22:49
This is a very thorough and helpful guide, thank you :)

Re: 2nd Gen Roaming Mechanics

Posted by: Metarkrai
Date: 2017-09-11 16:18:29
Wow, what a nice guide with many resourceful explanations !

I worked on routines to find the roamers as fast as possible in order to shinyhunt them, and your data would have helped me a lot on that.

I ended up with 3 different methods that give the fastest average times with different ratios for each beast :
- Save before the generation, generate the roamer, search for a roamer in Route 37. (good for Crystal)(can be done with/without Pokédex entries)
- Save before the generation, generate the roamer, use an Escape Rope, search for a roamer in Route 37 (good for GS)(can be done with/without Pokédex entries)
- Have the roamers in the Pokédex thanks to the Celebi Egg Trick, go to Cherrygrove, save, reset until the roamer is on a good route, then follow a certain pattern of routes while checking the Pokédex.

More detailed procedure to hunt for the roamers : https://pastebin.com/4CGM4rmA

Since your explanations about the determination of a roamer's new location is a bit different from what I knew back then, most of the percentages and average times are incorrect, but maybe not that far from more accurate values (I don't know the size of the margin of error).

Re: 2nd Gen Roaming Mechanics

Posted by: Random Sonic Fan
Date: 2019-08-12 00:41:56
I registered just to thank you. I found Raikou quickly thanks to this guide, and I wish I read this sooner. So many months have been wasted…

Re: 2nd Gen Roaming Mechanics

Posted by: Torchickens
Date: 2020-03-06 11:21:47
Thank you IceFlame

Re: 2nd Gen Roaming Mechanics

Posted by: SSJRobbieRotten
Date: 2020-04-16 20:46:08
This is super helpful, thankyou!