*Updated 13 February 2024*

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.

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.

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 the initial value at index 0 is position 0, index 1 is position 1, and so on. These positions 0-6 are not the same positions 1-7 that the community uses.

Now, it goes through a simple shuffling algorithm:

- The position at index 0 is swapped with the position at a random index
- Then, index 1's position is swapped with a new random index in the same manner
- Index 2 is swapped in the same way
- Index 3 is swapped
- Index 4 is swapped
- Index 5 is swapped
- Index 6 is swapped

The random swap index can be the same as the current index - if that happens, no swap occurs. And because a position can be swapped forward, it can be the subject of a swap multiple times.

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.

- rand():
- Takes the previous 32-bit randomness counter (e.g. 19088743)
- Multiplies by 214013 (randomness caused by many 32b overflows) (→ 725257163)
- Adds 2531011 (ensures both odd and even ouptuts) (→ 727788174)
- Stores the result for the next call to rand()
- Bitshifts right 16 times (16-bit output, less predictable randomness) (→ 11105)
- Returns the result AND 32767 (non-negative 15-bit output) (→ 11105)

- MGS1:
- Takes the result AND 4095 (i.e. modulo 4096) (→ 2913)
- Uses the result modulo 7 as the random index 0-6 (→ 1)

There's a very small uneven distribution in the RN generator. But moreso, 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.

After swapping, these items are placed at the positions at indexes 0 to 2:

- Index 0: PAL Key
- Index 1: Ration
- Index 2: Bomb

The positions for the last four indexes instead get either a pack of SOCOM ammo, or a pack of FAMAS ammo. This is decided by taking a value from the same random number function above, taking it modulo 2 instead:

- Result is 0: SOCOM ammo
- Result is 1: FAMAS ammo

Estimates of PAL Key and Bomb probabilities by position:

Internal | Community | PAL probability | Bomb probability | ||
---|---|---|---|---|---|

Before bomb | After bomb | Total | |||

3 | 6 | 14.66% | - | 14.66% | 16.71% |

5 | 5 | 9.87% | 2.40% | 12.27% | 14.32% |

4 | 4 | 8.51% | 4.87% | 13.38% | 15.42% |

2 | 3 | 7.64% | 8.52% | 16.16% | 12.54% |

1 | 2 | 5.70% | 12.21% | 17.91% | 13.35% |

0 | 1 | 2.14% | 12.15% | 14.29% | 14.28% |

6 | 7 | - | 11.33% | 11.33% | 13.38% |

Also see: Info about the Rat