Skip to content

FRLG League: fight-by-fight verification loop - #641

Closed
dayfine wants to merge 7 commits into
frlg/league-planfrom
frlg/e4-loop
Closed

dayfine wants to merge 7 commits into
frlg/league-planfrom
frlg/e4-loop

Conversation

@dayfine

@dayfine dayfine commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Depends on #638 (base frlg/league-plan; the diff shows only this change).

The League now runs fight by fight: run_league_fight() loads each fight's start save, tops up, checks the plan's entry contract (contract.entry, now parsed; hard on item counts), fights, and checks the caps and reserves. Phase 1 runs min_pass_of tries without saving and stops below min_pass; phase 2 tries up to reset_budget times and saves the first pass. The loop drives a LeagueFightRunner seam. In the console battle, a Roar or Whirlwind in a fight that resets on one, or the plan's early reset (Bruno after Onix #1), now ends the battle at once as ROARED / EARLY_RESET, and its step fails so the loop reloads the save. Tested with new fake-runner cases in the fake engine's test file (phases, over-cap win, Roar and early reset, a failed precondition, the one-heal branches and the Elixir before the Champion); CI runs them. Not in yet: the console runner, the per-fight story rows, and removing plan_league().

run_league_fight() tries a fight from its start save through a
LeagueFightRunner: load, top up, check the entry contract (hard on
items), fight, check the caps and reserves. Phase 1: min_pass_of tries,
none saved, stop below min_pass; phase 2: up to reset_budget tries,
save the first pass. The plan's contract.entry is read for the check.

Tests run the loop on a fake runner whose fights are the fake engine's
scripted battles.
A planned fight that resets on Roar or Whirlwind soft resets when the
lead is dragged out, instead of switching it back; the planned policy
soft resets on the plan's early reset (league_early_reset(), Bruno's
after Onix #1) when the foe it names falls. The battle ends ROARED or
EARLY_RESET and its step fails with league_roar_reset or
league_early_reset: the try didn't pass and the game is at its save.
The battle no longer soft resets itself: a Roar or Whirlwind in a fight
that resets on one, or the plan's early reset, ends the battle at once
(TurnChoice::END_TRY) as ROARED or EARLY_RESET, and the League loop's
next try reloads the fight's save. Keeps PokemonFRLG_AutoStoryBattle.cpp
and BattleDecisions within code health's limits; the League loop header
gets its missing comments.
The loop's fake-runner tests move out of #638's PlannedBattleFake_Tests.cpp
into PokemonFRLG_AutoStoryLeagueLoop_Tests.cpp, which this PR owns. Each
try's battle is now scripted as its end and the items it spent; the fake
battle engine file is back to #638's version.
@dayfine

dayfine commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #652 (frlg/lean), which continues from this branch's tip; the branch stays.

@dayfine dayfine closed this Nov 18, 2026
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.

1 participant