Skip to content

PokemonFRLG: EXP Farmer (One Island / Seven Island VS Seeker rematches) - #1887

Open
thewhitewolfking wants to merge 1 commit into
PokemonAutomation:mainfrom
thewhitewolfking:frlg-exp-farmer
Open

thewhitewolfking wants to merge 1 commit into
PokemonAutomation:mainfrom
thewhitewolfking:frlg-exp-farmer

Conversation

@thewhitewolfking

Copy link
Copy Markdown
Contributor

Adds a new FRLG program, EXP Farmer, under the "Untested/Beta/WIP" section.

It farms EXP by rebattling trainers with the VS Seeker until a target level is reached.

Modes

  • One Island (Kindle Road): Black Belt Hugh, Black Belt Shea, Crush Kin Mik & Kia (double battle), Crush Girl Sharon. Flies to One Island, heals at the Pokémon Center, surfs to Kindle Road, burns the Max Repel in the Ember Spa while the VS Seeker recharges, battles every ready trainer, and heals at the spa between rounds.
  • Seven Island (Sevault Canyon): Cooltrainer rematches.

New pieces

  • PokemonFRLG_ExpFarmer.cpp/.h: the program
  • PokemonFRLG_OverworldReaders.cpp/.h: VS Seeker icon detection and screen-based position tracking for overworld navigation
  • PokemonFRLG_DialogTextReader.cpp/.h: dialog / bag-description OCR
  • PokemonFRLG_BattleMoveReader.cpp/.h and PokemonFRLG_BattleMoveData.cpp/.h: move selection and PP/type data for battles (singles and doubles)

Testing
Tested on Switch with FRLG over many full One Island cycles (fly, heal, trek, repel burn, VS Seeker, battles incl. the double battle, spa heal). Seven Island mode tested earlier. Still marked beta. Feedback welcome.

@dayfine

dayfine commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

curious about a couple things:

  1. without looking at the code very closely, what's the prerequisite on the team? e.g. if the mon is strong then we can just sweep it using any move, without needing a complicated battle AI (knowledge about moves / types etc etc). What is the choice here and how was that made?
  2. how much more efficient is this compared to the existing elite four farming program? Ideally I suppose we recommend users to pick the best one for their purposes, so maintaining two might become a liability. Is the other one's main benefit now earning the ribbon for hall of fame?
  3. for fastest leveling up, I assume the solution would be https://pokemonautomation.github.io/Programs/PokemonFRLG/ItemDuplication.html + Mail Glitch. Are you explictly looking to avoid using mail glitch?

@theastrogoth theastrogoth left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't really looked at the overworld navigation and path finding stuff in detail, but I have some feedback:

  • support languages other than English, either by adding resources to Packages or avoiding the need for OCR when possible
  • I think that this should probably be split into several PRs, since you're adding a lot here
    • auto battler stuff
    • overworld navigation stuff
    • new inference stuff
  • for small things that might be reusable (menu navigation, etc), it might make sense to separate them out of your ExpFarmer program and put them somewhere like PokemonFRLG_Navigation

Comment on lines +40 to +45
const MoveInfo MOVES[] = {
{"pound", "POUND", BattleType::NORMAL, 40, 100, MoveKind::NORMAL},
{"karate-chop", "KARATE CHOP", BattleType::FIGHTING, 50, 100, MoveKind::NORMAL},
{"doubleslap", "DOUBLESLAP", BattleType::NORMAL, 15, 85, MoveKind::MULTI_HIT},
{"comet-punch", "COMET PUNCH", BattleType::NORMAL, 18, 85, MoveKind::MULTI_HIT},
{"mega-punch", "MEGA PUNCH", BattleType::NORMAL, 80, 85, MoveKind::NORMAL},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of data usually lives in https://github.com/PokemonAutomation/Packages/ in a JSON file. The move data for the SwSh MaxLair programs and the SwSh MoveDatabase are worth looking at.

Ideally, will also support non-English versions (Spanish, French, German, Italian, and Japanese). Everything needed might already be in the move OCR data for SV, but I'm not sure if there were any translation changes between gen III and gen IX.

Comment on lines +22 to +41
enum class BattleType : uint8_t{
NORMAL,
FIGHTING,
FLYING,
POISON,
GROUND,
ROCK,
BUG,
GHOST,
STEEL,
NONE, // "???" (Curse). Never deals typed damage.
FIRE,
WATER,
GRASS,
ELECTRIC,
PSYCHIC,
ICE,
DRAGON,
DARK,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because auto battler stuff will be useful for other programs (e.g. AutoStory), it might be best separated out into its own PR

Comment on lines +58 to +74
{"summary", "SUMMARY"},
{"switch", "SWITCH"},
{"item", "ITEM"},
{"mail", "MAIL"},
{"cancel", "CANCEL"},
{"flash", "FLASH"},
{"cut", "CUT"},
{"fly", "FLY"},
{"strength", "STRENGTH"},
{"surf", "SURF"},
{"rock-smash", "ROCK SMASH"},
{"waterfall", "WATERFALL"},
{"teleport", "TELEPORT"},
{"dig", "DIG"},
{"milk-drink", "MILK DRINK"},
{"softboiled", "SOFTBOILED"},
{"sweet-scent", "SWEET SCENT"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other programs require HMs or other actions (e.g. Dig or Sweet Scent) to be in a particular position, avoiding the need for any OCR.

If you want to use OCR for this, support for other languages would be nice.

Comment on lines +700 to +702
if (text_contains_any(name, {"seven", "even isl"})){
return true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only really works for English, right?

Comment on lines +672 to +683
// The Six/Seven Island page of the Fly map is a 22 x 15 grid and the cursor
// stops at its edges (region_map.c and region_map_layout_sevii_67.h in the
// decomp). Seven Island's town is at (5, 8), Six Island's at (17, 5).
// How long to hold a direction on the Fly map to move the cursor n cells.
Milliseconds cursor_hold_ms(int cells){
return frames_to_ms(5.0 * cells - 2.5);
}

// Move the Fly map cursor one cell (a tap shorter than a cursor move).
void fly_cursor_tap(ProControllerContext& context, DpadPosition direction){
pbf_press_dpad(context, direction, 50ms, 300ms);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything that places the cursor for flying should probably live in PokemonFRLG_Navigation.

Blindly placing the cursor has been reliable enough for programs so far, though some extra detection (of something in the text display, even if it isn't read) might be a good addition

Comment on lines +1 to +15
/* Overworld Readers
*
* From: https://github.com/PokemonAutomation/
*
* Overworld helpers that work in GBA tiles around the player:
* - find a trainer with purple hair (Cooltrainer sprites) on given tiles,
* or a sprite's feet on tiles at the top of the screen,
* - find the VS Seeker's "!!" / "X" icon above a trainer,
* - find the Sevault Canyon house's roof (a landmark for the player's tile),
* - tell whether the screen scrolled by one tile (did a step happen?),
* - detect any region's Fly map (Kanto or the Sevii Islands).
*
* The camera keeps the player on the same tile of the screen: the 16x16
* tile whose top-left corner is at (112, 72) of the 240x160 GBA screen.
* (dx, dy) below are tile offsets from the player (right and down positive).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another thing that might merit its own PR, since it could be useful for other programs as well

@thewhitewolfking

Copy link
Copy Markdown
Contributor Author

curious about a couple things:

  1. without looking at the code very closely, what's the prerequisite on the team? e.g. if the mon is strong then we can just sweep it using any move, without needing a complicated battle AI (knowledge about moves / types etc etc). What is the choice here and how was that made?
  2. how much more efficient is this compared to the existing elite four farming program? Ideally I suppose we recommend users to pick the best one for their purposes, so maintaining two might become a liability. Is the other one's main benefit now earning the ribbon for hall of fame?
  3. for fastest leveling up, I assume the solution would be https://pokemonautomation.github.io/Programs/PokemonFRLG/ItemDuplication.html + Mail Glitch. Are you explictly looking to avoid using mail glitch?
  1. Slot 1 needs to be level 55+ (so Max Repel works on the trek to the spots), and users of Surf, Fly, and Cut (for Seven Island only) in the party (positions for each can be laid out on the wiki). The Pokémon being leveled either battles alone or, with Switch-In, leads and is swapped out right away, so the strong slot 1 does the fighting. I wanted to make this software as accessible as possible without hyper-specific requirements or preparation required, so this software doesn't require the strong mon to always OHKO and the moveset can be diversified a bit (so it would be fine if the first slot move is a status move, and if the opponent is immune to the default move the AI can know to use another move).
  2. This software is more efficient if the player wants to level up to a point where the E4 may be overkill (i.e. training up a Dragonair or Pupitar would be appropriate for the E4 farmer, whereas this software would be more appropriate for a more modest goal like evolving Pidgeotto, Omanyte, or Kabuto), or even if they're trying to prepare for the initial E4 run (where One Island would be the only option). Each cycle of Kindle Road or Sevault Canyon takes ~3-5 minutes depending on how many NPC's are battle-ready, as opposed to each E4 run which takes ~10 minutes. The E4 farmer is still the one to use for the league-win count (Lorelei’s dolls / Trainer Card star); this one is for leveling without resetting the league.
  3. Yes, I personally prefer to avoid glitches where possible and I'm sure there are other automation users in the same boat.

How the move choice works

Every turn, in use_best_move() (PokemonFRLG_BattleMoveChoice.cpp):

1. Read the situation

  • Our moves: the four names in the FIGHT list. Read once per Pokémon in single battles, every turn in the double battle.
  • Our species: from our HP box (single battles only; unknown if the Pokémon has a nickname, and then STAB/stats are skipped).
  • Opponent species: from its HP box, matched against the possible opponents.

2. Score each move (score_move()), starting from its power:

Factor Effect
Never used (score 0) Status moves, fixed damage (Seismic Toss, Dragon Rage, Super Fang), OHKO, Self-Destruct/Explosion, False Swipe, Dream Eater, Focus Punch, Counter, Fake Out, ...
Multi-hit ×3 (2–5 hits), Double Kick ×2, Triple Kick ×4
Slow moves Hyper Beam ×0.6; Solar Beam, Fly, Dig and other two-turn moves ×0.5
Accuracy × accuracy (80% → ×0.8)
STAB ×1.5
Attack stat × our base Atk, or base Sp. Atk for special types (Gen 3: the type decides)
Defense stat ÷ their base Def / Sp. Def
Type chart ×2 / ×0.5 / ×0 per opponent type (Gen 3 chart)
Ability immunities ×0 for Levitate, Flash Fire, Water Absorb, Volt Absorb; Wonder Guard blocks anything not super effective

Base stats stand in for the real stats. Moves are ranked by score; a move scoring 0 is never chosen to attack.

3. Situational rules

  • Out of PP: skipped, next move tried.
  • Can't be used now (Disable/Taunt/Torment): skipped for 3 turns, then retried.
  • Grudge: use the second-best attacking move, so the best one doesn't lose all its PP if the opponent faints. Always against opponents known to use Grudge; otherwise right after the Grudge message.
  • Double battle: confirms the target when the move asks for one.
  • Nothing usable: backs out to the battle menu and returns false to the caller.

Example: Starmie (Water/Psychic) with Surf / Psychic / Thunderbolt / Ice Beam vs. Primeape:
Psychic 90 × 1.5 (STAB) × 2 (super effective) = 270, Surf 95 × 1.5 = 142.5, Thunderbolt and Ice Beam 95 → uses Psychic. Against Golem it picks Surf (×4).

Not covered: predicting the opponent, switching, items, stat stages, weather, status, crits. It's a "strongest hit this turn" picker, not a full battle AI.

Why not just use move 1? The Pokémon being leveled can battle alone, so its moveset isn't controlled. Move 1 may be a status move or hit an immunity (Normal vs. Ghost, Ground vs. Levitate/Flying), and over hundreds of battles PP, Disable and Grudge come up. If you'd prefer the simpler route (require a strong battler and use spam_first_move() or a user-set move order, dropping the move data), I'm happy to switch to that.

@dayfine

dayfine commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

So the simpler the program, the more easily the users can use it correctly and reliably.

For example, maybe it's sufficient to just do the Seven Island routes? Then there is less walk, fewer different trainers, and a shorter loop.

If you limit the scope to Seven Island Cooltrainer rematches, マコト/Leroy & カズミ/Michelle each have 5 mons. So your lead needs a plan to defeat them reliably anyway (at least one of them). If not 1HKO, likely 2HKO; otherwise you have to consider the chance being fainted and need to do healing (inside the battle), right? So ideally there is a way to describe / require that in the problem, to prevent the user bring in too weak a lead.

So with a "functional" lead, how that lead should battle Leroy / Michelle is a much simpler problem. You can pre-plan it at the beginning of the program. e.g. for each of the Leroy / Michelle mon, the lead should choose a specific move, and you can say that at least there is some move to hit neutral, all move should be 100% accurate, at least 60 base power etc, etc. That could simplify it a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants