Story
This project is pretty odd in comparison to the rest. I love Pokémon and I can code, so I thought of making a Pokémon Bot that would play the entirety of Pokémon HeartGold for me. I liked this project, since I had to examine hexadecimal values primarily from memory and determine what address represented what attribute of the game.
Road block
My researches were a success, but I faced an enormous wall: game progression. Since most Pokémon games aren't a battle simulator, you can't just walk forward and beat the game. You must travel a complex map in order to beat the game. Sadly, it is not as easy as getting the end position and letting the computer pathfinding to it. There are a lot of cutscenes that opens paths that you couldn't walk through before. For a human, it's pretty easy to figure out. For a bot, it is hard. Very hard. Since I was lazy and didn't want to place every marker in order to complete the game, I had to search through the game's scripts to find which flag blocks my path and switch scripts set the flag to the correct value. Of course, it is easier said than done. In the first town only, I searched a long time to find where the flag gets set to the correct value. Sadly, after that, I wasn't feeling like continuing the project and left it to rot.
How does it work?
Obtaining map data
To make it, I used a combination of Lua and C# if I had to remake it, I would probably do Lua & C++. I decompiled the ROM using DSPRE. Afterward, I looked how the game manages the map and could find and decode the collisions. This is where the project truly starts.
Pathfinding
Then, I applied a pathfinding algorithm to determines the shortest path. In order to make the bot smarter, I made it so that it avoids grass as much as possible. My plan for the bot wasn't to have one bot doing all the hard lifting. I would have separated the work into two bots:
- One for the map
- One for the battles
This allows to write/maintain the code much easily.
Sudden End
To finish, before scrapping the project, I did a small "speedrun"
with the bot. Here, you can see the "run" where I tasked the bot to
move from the starter bed to the rival's bed
You can find the source code here, if you want to see.