# R/B/Y Safari Mechanics (FAKE)

This page was a joke written for April Fools' Day 2013. Every word in it is a lie. This is NOT how the R/B/Y Safari Zone actually works; for that, go here.

When I analyzed the R/B/Y capture algorithm, I expected - like most likely everyone - that the Safari Zone used this same algorithm with some minor modifications. However, the reality turned out quite different as I delved into the depths of the game program.

## Capturing

### The Formula

The odds of capturing a Pokémon for a given Safari Ball you throw in the Safari Zone are usually given by the following formula:

`Chance = ((min(int(int(C * (R + 1) / (B + 1)) / 4) + 1, 151) / 151) * 86) / 256`

This is essentially the regular R/B/Y capture formula (as shown on my R/B/Y capture algorithm page) with the status and HP factors simplified out of it (since the health of Pokémon in the Safari Zone cannot be affected) and the ball factors set according to the Ultra Ball-like specifications of the Safari Ball, except that the capture rate C has become `int(int(C * (R + 1) / (B + 1)) / 4)`. Notably, as R and B both start out as 0 when you encounter a Pokémon, this means that your initial chances of catching a Pokémon in the Safari Zone are only a quarter of what they would normally be for a full-health Pokémon. This really stacks the deck against the player already at the beginning of the battle.

### The Variables

#### C (Capture Rate)

The catch rate of the Pokémon, identical to the regular catch rate (as explained on the main R/B/Y capture algorithm page).

#### R (Rocks)

The number of rocks you have thrown at the Pokémon. In order to get your chances of catching the Pokémon up to what they would be if it were a regular, non-Safari Zone Pokémon at full health, you must therefore throw three rocks. Once you have thrown 255 rocks, the addition of one in the formula will overflow to zero, negating your chances of capturing the Pokémon almost completely; throwing one more will cause the variable itself to overflow to zero, putting you back at square one. Of course, this is unlikely to happen, as in those 255 turns the Pokémon will most likely have run away (see the section on running).

#### B (Bait)

The number of times you have thrown bait at the Pokémon. Note that this is a divisor in the formula, so throwing bait makes the Pokémon harder to catch - a lot of people are unaware of this, despite that an NPC in the Safari Zone actually explains that rocks make Pokémon easier to catch but more likely to run while bait makes them harder to catch but less likely to run. As with rocks, the game assumes you'll never spend 255 turns fighting a Pokémon in the Safari Zone and the addition will overflow if the B value reaches 255, causing the game to freeze as it tries to divide by zero.

### Capture Bypassing

Surprisingly enough, those old cheats telling us to press and hold down buttons when catching Pokémon had a grain of truth to them. While the timing of button-presses does not affect the regular capture formula, it does affect capturing in the Safari Zone, as it turns out, which likely sparked the rumours that it applied everywhere and is the reason why it eluded the many hackers who have debunked the claim before.

Essentially, if you press and hold down A exactly as the Safari Ball sprite appears on the screen and release it exactly when the ball pops open around the Pokémon, the game will bypass the formula altogether, acting as if you had thrown a Master Ball rather than a Safari Ball. This timing has to be extremely precise - you need to both press and release the button at the exactly right frame of the animation - so this effect is very difficult to trigger reliably, but with a lot of practice and patience, you can actually train up a decent success rate - I've confirmed this myself, capturing multiple Scyther and Chansey in a single ball after working tirelessly at the timing for a few days. After a while, it becomes instinct to press the button at approximately the correct time, and although the precision required is greater than at least my instinct can conjure up quite reliably enough, I would estimate around 25% of the time I can now trigger the capture bypass.

For some Pokémon, especially Chansey (catch rate 30) but also Tauros, Tangela, Kangaskhan, Scyther and Pinsir (catch rate 45) to a somewhat lesser extent, trying to exploit this mechanic may be an easier way to capture them than the conventional method, as they are normally nearly impossible to catch before they run.

## Running

Of course, the capturing itself isn't the only problem facing the unwary player in the Safari Zone: they must also try to capture the Pokémon before it runs away. To determine whether a Pokémon should run in a given turn, the game uses a most ingenious method, most likely designed to simulate how wild animals might respond to different body language.

The chance that a Pokémon will run on any given turn is given by this formula:

`Chance = min(255, int(2 * S * (R + 1) / (B + 1)) + N) / 256`

The B and R values are the same bait and rock numbers used in the capture formula, with the same reservations - rocks make the Pokémon more likely to run while bait makes it less likely to, and in the extremely unlikely case they somehow reach 255, they will overflow. The S value is the base Speed of the Pokémon you're trying to catch - meaning Tauros (base Speed 110) and Scyther (base Speed 105) will run away more often than other Pokémon in the Safari Zone. But the really interesting part is the N value...

### N (Nervousness Modifier)

The N value, surprisingly, is calculated in a rather intricate way based on how hard and quickly you have pressed the buttons in the battle thus far, giving your more recent behaviour more weight. The basic gist of it is that if you have pushed the buttons like a madman - especially hammering one button over and over - the Pokémon will see that you're acting jumpy and jittery and be considerably more likely to run away, while if you select your options calmly and carefully, pressing the buttons only when needed and for no longer than necessary, it will calm the Pokémon down and make it more likely to stay.

N starts at zero at the beginning of a battle, and on each turn the following procedure is performed to modify it:

1. At the beginning of the turn, create a variable X, initialized at zero.
2. Each time a button is released during the turn, add a number to X equal to (5 * the duration of that button press / the time elapsed from the last time the button was released until it was pressed again), but no less than 1 and no more than 5. (X is capped at 255.)
3. At the end of the turn, divide N by two (this is integer division, so the result is effectively rounded down) and then add X to N, up to a cap of 255.

This means it is extremely important to try to calm your nerves while in the Safari Zone - while it is easy to get wound up when you finally find the Pokémon you want, if your button presses reflect this it may directly result in the Pokémon fleeing. The best strategy is to wait a few seconds between each time you press a button, and then press it only lightly - as you only need a few button presses per turn, N will rise quite slowly if you follow this method. Interestingly, throwing rocks or bait will increase your nervousness modifier compared to doing neither, since the "[Pokémon] is angry!" or "[Pokémon] is eating!" message requires an extra button press to scroll through.

## Encounters

As if all of that weren't enough, the Safari Zone uses a slightly different method to determine what Pokémon you will find in a wild encounter than the regular game. While the Safari Zone has seemingly normal encounter slots, each with its own default percentage chance, this isn't the full story: before determining which possible random numbers will result in which Pokémon slot, it will halve the chance for the slots containing Pokémon you do not have registered as caught in your Pokédex, then adjust the maximum value for the random number it generates to be equal to the remaining sum of the encounter chances.

For instance, in Area 1 in Pokémon Yellow, the encounter slots are as follows:

%Pokémon
20Nidoran (male)
20Nidoran (female)
15Exeggcute
10Nidorina
10Cubone
10Tauros
5Exeggcute
5Marowak
4Chansey
1Scyther

Say that you have already caught Nidoran of both genders, Nidorina, Exeggcute and Cubone, but have yet to capture Tauros, Marowak, Chansey and Scyther. In this case, the game will adjust the slot rarities as follows:

"%"Pokémon
20Nidoran (male)
20Nidoran (female)
15Exeggcute
10Nidorina
10Cubone
5Tauros
5Exeggcute
2Marowak
2Chansey
1Scyther

(Scyther remains at 1 because the encounter rate cannot drop to zero.)

Now, the rarities don't actually add up to 100, but to 90 - so rather than generating a random number between 0 and 99 inclusive, as the game usually would, it will instead generate a number from 0 to 89 to pick the appropriate encounter slot.

This is why you might search for hours in the Safari Zone for, say, a Tauros, only for them to be seemingly everywhere the moment you have already caught one. This feature was likely implemented to increase the player's frustration, so as to make the calm required for a low nervousness factor more elusive.

## Safari Zone Calculator

Calculate your chances of capturing a Pokémon in the Safari Zone, and of it running, here. Note that you will have to estimate your own nervousness factor, as I cannot access your button inputs.

Game: