Who out there hasn’t angrily thrown a game controller across the room after continually getting killed by some stupid game-controlled villain? That is such a bummer! You probably wished there was some way to ‘just get past that point’. To take a step in that direction, [Ben] created an Artificial Intelligence program that will win at Pokemon Blue for Game Boy Advance.
The game is run in a Game Boy Advance emulator known as Visual Boy Tracer, which itself is a modified version of the most common GBA emulator, Visual Boy Advance. What sets Visual Boy Advance apart from the rest is that it has a memory dump feature which allows the user to send both the RAM and the ROM out of the emulator. The RAM holds all values currently needed by the emulator, this includes everything from text arrow flash times to details about currently battling Pokemon to the players position in the currently loaded map. The memory dump feature is key to allow the AI to understand what is happening in the game.
The AI code is written in python and uses the pywin32 add-on that includes the Win32 API. The Win32 API allows the programs to interface with Windows, specifically simulating key presses. The AI uses these simulated key presses to interact with the emulator rather than building the emulator into the AI code. The AI Agent has two key goals: navigate the map to each new trainer and defeat each trainer with out loosing a Pokemon. These goals require separate modes, a ‘search’ mode and a ‘battle’ mode.
The search mode is the most basic form of AI, it’s a Reaction Agent. Reaction Agents simply react to what they can see at that particular time. In this case the agent is programmed to find the location next to the trainer. By knowing where it is and where it needs to go, the AI sends a simulated keystroke to move the player to the appropriate position. When in position, the AI will ‘challenge’ the trainer.
When in battle mode, the AI has a little bit more work to do. It starts by calculating the potential battle damage for all combinations of opposition Pokemons VS each of its own Pokemon. The AI then runs through a decision tree that dictates what decisions to make. For example, the decisions relating to health are higher in the decision tree and the AI will decide to heal a weak Pokemon before assessing any attacks. This ensures that no Pokemons are defeated.
Even if you are not a Pokemon fan you have to agree that this is an amazing exercise in DIY Artificial Intelligence. Check out the video to see this project in action.