Exploration AI in Pokemon Red - Is there an easy way to skip battles?
Hi, I’m new here and I’ve only been using PyBoy for about two months. I’ve already done some research and created small projects, like automatic exploration using Q-learning or battling with randomly chosen buttons.
Ok, now to the point. I’ve started a somewhat more complex project using Double Deep Q-learning for exploration and I’d like to make it as effective as possible. I need help with one thing:
Is there an easy way to skip battles? I know there’s a special flag that indicates whether a battle is occurring, but is there a simple method to automatically run away or just skip it? In the worst case, is there some tuning I can apply to make running away 100% successful? That way I could have the AI run every time, even if that might be overly optimized.
12 Replies
Yes
For trainer battles you can set the event flag
https://github.com/drubinstein/pokemonred_puffer/blob/main/pokemonred_puffer/data/events.py
GitHub
pokemonred_puffer/pokemonred_puffer/data/events.py at main · drubi...
Contribute to drubinstein/pokemonred_puffer development by creating an account on GitHub.
For wild battles I setup auto repel https://github.com/drubinstein/pokemonred_puffer/blob/6cff87c13582cec3785e7833fb94cf6f7d364bba/pokemonred_puffer/environment.py#L1481
GitHub
pokemonred_puffer/pokemonred_puffer/environment.py at 6cff87c13582c...
Contribute to drubinstein/pokemonred_puffer development by creating an account on GitHub.
You can also reset the wild encounter rng between steps
First of all, thanks so much for so fast response
Second of all, the idea with repel is awesome. I mean, I still need to somehow use it, but still, great idea.
Ok, I might not be very smart, but how is knowing whether a battle with a trainer has started supposed to help me skip it? Maybe there’s a way to automatically win. it would make more sense.
You set the bit before the battle started
There's probably a way to hack three enemy HP to 0. But I've never tried it. Trainer battles are rarely a blocker from my experience
https://drubinstein.github.io/pokerl/
current report (this is ongoing work for me)
Pokémon RL
Learning Pokémon With Reinforcement Learning
Hi! Since 2020, we’ve been developing a reinforcement learning (RL) agent to beat the 1996 game Pokémon Red. As of February 2025, we are able to beat Pokémon Red with Reinforcement Learning using a <10 million parameter policy (60500x smaller than DeepSeekV3) and with minimal simplifications. The output is not a policy capable of beating Pok...
wait.... so you’re saying I can just flip that bit in WRAM and it skips the battle as if nothing ever happened?
It should
Never tried it, but I wouldn't be surprised since that's what happens in ram
good point
Wow, I’m really grateful. When I get to that point, I’ll let you know here. Thanks again. You’ve been a great help.
Feel free to join the pokerl discord
another discord channel... wow. I'll join for sure.