The quest for immortality

More than four thousand years ago1, in the very first litterary Epic of history, Gilgamesh, the king of kings, went on a quest for immortality. Since then, mankind has been looking for ways to cheat death, but the results have never been very satisfactory.

Thanksfully, to make our Pokémon immune to death, we don't need to go down the crossroads at midnight, hide their aging portrait in our attic, or other deals that turn sour only to teach the reader a lesson on the benefits of seizing every day.

Thinking like a programmer

Gently close your eyes.

You are back in the summer of 1993, and you smile shyly as your Sony MZ-1 MiniDisc starts playing the notes of Yumi Matsutoya's hit song "VOYAGER2" in your ears. You are sitting, comfortably numb, in a good chair in the middle of your Tokyo office. Nintendo has greenlit the game you are currently working on, and things are looking good, so you don't pay too much attention when Satoshi Tajiri sits next to your office, and pitches you an idea.

"I got an idea, how about we make the wild Pokémon fight back?"
― Satoshi Tajiri, in your 1993 dream, probably thinking it takes 5 minutes to do

You think it quickly: the game's already got "attacks" and an idea of "hit points" when you are attacking a wild Pokémon, but they don't attack back, so your animal friends are in no danger of seeing their own HP count go down. As you ponder all the ramifications of this strange idea from the co-founder, he asks:

"You got an idea on how you would implement it?"
― Satoshi Tajiri, having no patience in your dream

You think back3 of that time when you played Dragon Quest on the NES some years ago: each combattant get a turn to attack, the opponent's HP go down, and the first one to zero is defeated. You jolt down some notes (in Japanese) for the boss that history will remember:

PLAYER TURN
-> Choose an attack
-> DAMAGE = CALCULATE(Player ATK - Enemy DEF)
-> Enemy HP = CALCULATE(Enemy HP - DAMAGE)
-> IF Enemy HP < 0
  -> Victory
ENEMY TURN
-> Attack
-> DAMAGE = CALCULATE(Enemy ATK - Player DEF)
-> Player HP = CALCULATE(Player HP - DAMAGE)
-> IF Player HP < 0
  -> Defeat
REPEAT

As you hand him the note so he can give you some observations, a lightbulb goes in your head, you wake up, and are whisked back to this book: you now KNOW what happens.

Yes, there is nothing too complicated in here: you know there are "attacks", you know there is "damage", and you know this "damage" is whittling down the Pokémon's "hit points". All you need now to achieve Poké-Immortality is make sure this "hit points" value never reaches zero, and why not use the same method as the one that made you rich? If only you knew where this value is stored in the game's memory...

Which way now, fellow hacker?


1

This number stands as of the writing time. Readers of the 30th century may need to review the math.

2

You remember this song from the 1984 SF movie "Sayonara Jupiter", and your 2024 self loved it too in the 2021 movie "Evangelion: 3.0+1.0 Thrice Upon a Time".

3

No recursion!