← Back

MGS1 Pal Key Randomness

The PAL Key is one of the biggest sources of randomness, lost runs and frustration in MGS1. Shortly after reaching the Underground Base, you lose the PAL Key and have to find it again. Outside of the Big Boss set of categories, the favoured approach is to reenter Underground Base 1 with 11 (or more) Alerts, which causes the card to be in one of seven drainage ditch locations at random.

The seven possible locations. Source: MGSR Wiki

Players will go west through positions 6 to 1, then if they still haven't found the key, backtrack to position 7 on the other side of the map. Generally positions 1, 2 and 7 (and maybe 3) are considered bad and will often prompt a reset.

Every so often, someone decides to try and figure out a way to manipulate the selection of the key's position through gameplay. The short answer is that you can't - the selection is done using true [pseudo]randomness. The longer answer is that some positions are more likely than others, although it's unlikely to help in practice. This page is really just for documentation since I found the process interesting.

The position selection occurs when you'd expect it to - the moment you enter UGB1. At this point, the game creates an 7-value array where index 0 initially contains position 0, index 1 contains position 1, and so on. Then, it goes through a simple swapping algorithm:

In the case that the original index and the random index are the same, no swap occurs for that step. And because a position can be swapped forward, it can be swapped multiple times - e.g. if 0 is swapped with 1 in step 1, it's now in index 1 and will be swapped again in step 2.

The randomness is provided (on PC) by Windows' rand() function (with all 7 calls performed in succession), and the game uses modulo arithmetic itself to generate a value 0 to 6. The game on console may use a different random number function.

There's a very small uneven distribution, mostly caused by the modulo 7. But more importantly, because of how the positions are swapped one after another, earlier positions are more likely to be swapped multiple times. This means some permutations are more likely than others. This would normally create distinct curves on a frequency distribution chart (see further down), but because the game's positions 0 to 6 are not the same as the community's positions 1 to 7, some points are swapped around.

After swapping, the positions in indexes 0 to 4 are used to place five items:

Estimations (by repeated simulation) of PAL Key (left) and Bomb (right) position probability: