Repository navigation
Conversation
StoryCheckKind (save place, start screen, menu row, leg end tap, bag contents, party stats) maps each kind of check to the lowest StoryCheckLevel that runs it; every FRLG check site asks runs_check() by its kind. A plan action that is a pure check carries its kind in its spec, and TableExecutor skips it below its level, logged as "<step>: skipped (checks: default)". Bag reads and LEVEL steps now run at Thorough and above only. Level checks pass up to LEVEL_CHECK_TOLERANCE (3) below their minimum, with a warning.
At Checks=Default, #613 skipped the Items-pocket read after a load, and that read was what set the battle's counts: 19.01's rival was fought with 0 Potions and no X item (console B, 2026-11-15). A precheck now only verifies: the load's Bag check and the Viridian Mart check log the pocket against the counts kept and change none. The steps that act on the counts read them themselves when they are a row's guess (Supplies::counts_read): a battle reads the Items pocket through BAG before its first turn (and stops if nothing reads), a recovery reads it from the START menu.
Owner
Author
|
Fix for the 19.01 regression at Checks=Default (7bac365): rival fought with 0 Potions, no X item. Rule now: a precheck only verifies and nothing downstream reads its result; a step that acts on screen data reads it itself.
Tests: BattlePolicy suite (guessed counts make a battle read first; 19.01 rival sets up from the battle's own read), Items suite (Bag check compares and changes no count). Local compile skipped (console run on, heavy gate exit 5); CI: https://github.com/dayfine/Arduino-Source/actions/runs/43822614940 |
…g-pointer warning)
…r on top 19.01b's rival (console B, 2026-11-16) was fought with no setup. The battle did read its Items pocket, but the read left the cursor on row 14 of 16; the battle bag's 12 UP then stopped one row short, so the X Special's DOWN presses landed on the X Speed and the row check refused it. - read_whole_pocket() puts the cursor back on the top row after the read, for the field bag and the battle bag alike; the battle bag homes with UP presses for the pocket's rows, not a fixed 12. - use_battle_item() (new BattleBag seam): a row that reads as another item gets the pocket read again and the item tried once more at its new row, instead of skipping the setup. - items_pocket_change(): one row per story action saying what it does to the Items pocket (NONE, COUNTED, STALE). A STALE step (Marts, talks, use_item) and a reload clear Supplies::counts_read, so the next battle reads the pocket first. A test checks every action spec has a row. - The battle's supply line lists Super Potions and other medicines; the story's own heal uses a Super Potion once the Potions are gone.
…he screen In FRLG a tap into a boulder pushes it while the player walks in place (pokefirered DoBoulderDust), so the console's one tap a tile left the player a tile short of the plan: 19.04b push_south left them on VictoryRoad_1F (7, 17), not (7, 18), every walk after it ran a row off, and by_boulder_3_corner failed (console B, 2026-11-16). push_boulder_tiles() now taps to push (the map still, the two tiles ahead changed) and taps onto the tile the boulder left (the map scrolled), reading each tap with read_boulder_press(); a wild battle that eats a tap is run from and the tap repeated. A push that stops short fails with the player's tile from the counted steps. The console and the row sim share the sequence, the sim through SimBoulderPresses.
…ere it stands 19.04b failed twice at push_east_row19 (console B, 2026-11-16 01:14 and 01:16): by_boulder_2_corner planned from (7, 18) south onto (7, 19), where push_south had just put the boulder, as the maps still had it on its map tile (7, 18). The leg bumped the boulder, was taken as walked, and every leg after ended a row off, so the first tap of push_east_row19 had no boulder to push. A push now records where the boulder stands as a run flag (BOULDER_AT_FLAG, like TRAINER_AT_FLAG), run_story_maps() moves it there for every walk planned after, and leaving the map clears the flags, as the game puts its boulders back. The console and the row sim record it the same way.
… taps again 19.04b push_onto_switch failed (console B, 2026-11-16 01:28): the boulder landed on 1F's floor switch, whose script (pokefirered VictoryRoad_1F_EventScript_FloorSwitch: lockall, the barrier's metatiles, SE_ICE_BREAK, waitse, releaseall) locks the player until its sound ends, and the step tap after the push came inside it. The interrupt check only looked for a wild battle, found none, and failed the push. After a tap that didn't do what the push needs, the console now waits for the quiet overworld (the settle rule, AFTER_BATTLE_QUIET), running from a battle or closing a box on the way, and taps again. The sim locks the player for a switch's script and settles the same way.
19.04b below_ladder (console B, 2026-11-16 01:40, run 3) went from Victory Road 1F (19, 15) out of the cave mouth onto Route 23 and straight back in, two warps being cheaper than an open stop by the mouth. Re-entering made the run flags drop the boulder pushed onto the switch, so the maps put it back on (7, 18); the game keeps it on the switch (copyobjectxytoperm), and "south 4 (to wall)" from (10, 11) ran into it. plan_overworld_route() and its gated form now plan a route whose start and goal share a map on that map alone first, and on all the maps only when no route stays on it (Route 16's halves, Silph Co's teleporters). A boulder resting on a floor switch's button keeps its run flag across map changes; other pushed boulders still go back.
…again A wild battle that stops a leg onto a warp is run from, then the walker holds on toward the warp. That hold watched for the black only while it held, and failed with "no fade holding on toward the warp" otherwise. On console B (2026-11-16 02:13, 19.04c ladder_3f) the black onto Victory Road 3F's ladder came a moment after that watch ended. The hold on now watches for the black as long as a warp leg's end does, and with none it reports the warp not taken: the route finds the player again on the leg and plans on from there, as after any other stop.
… wipe On console B (2026-11-16 02:18, 19.04c ladder_3f) "north 5 (warp)" reached Victory Road 3F, then a wild battle started there. The walker took the ladder's fade for the battle's wipe, held on north toward a ladder it had passed, and stopped on no fade with the player on 3F, 2 tiles past it. One rule now decides every warp's end from the screens: if the new map's overworld shows after the fade and before the battle (WarpBattle::AFTER), the warp was taken. The battle is run from, the leg ends WARPED, and the route finds the player again on the new map, up to 2 tiles on from the warp's tile, as the start of the step after the warp, then plans on. A hold on toward a warp returns the same check. A walk without maps fails with the player's tile unknown. The warp's fade timeout is one constant (WalkTimes.h). The sim can start a battle a set time after a warp's fade (SimScript::battle_after_warp), and OverworldBattleAfterWarp walks Victory Road 2F's ladder with a battle 1 s and 3 s after it. Also fixes the Recovery tests' hold_to_warp stub for the changed return type.
…r from below 19.04c used Strength on Victory Road 3F and saved there. Continue (pokefirered CB2_ContinueSavedGame) doesn't clear FLAG_SYS_USE_STRENGTH; only a warp's ClearTempFieldEventData does. So in 19.04d the hold east "to wall" at the boulder (33, 18) pushed it into the hole (34, 18), the check tap stepped onto its tile, and push_into_hole pressed A at the open hole and waited 60 s for a YES/NO (console B, 2026-11-16, both attempts). - Sim: Strength state (SimScript/SimState::strength_on, SimField::STRENGTH); a step into a boulder with Strength on pushes it; a warp turns it off; using it when on, or with no boulder ahead, is a violation. - Row sim: push_boulder's activate uses Strength on the sim. - cave_floor carries Strength from the previous row's sim end. - 19.04d: below_hole (34, 19), then behind_hole_boulder (32, 18) from below; push_into_hole without activate (Strength on from the save). - Console: use_strength() fails at once with "no boulder <dir> of <tile>" when A shows nothing, instead of waiting for the YES/NO.
19.04d push_into_hole pushed Victory Road 3F's boulder (33, 18) into the hole (34, 18), but the maps the walks plan on kept it standing there, so drop_to_2f went round by 3F's west room and the (34, 9) ladder, into Cooltrainer Colby's line at (5, 17), and lost his battle (console B, 2026-11-16). with_boulders_moved() now drops a boulder whose tile is a FALL_HOLE, as OverworldSim::push_boulder() does; the walk is one step east.
Against Colby's Water party (19.04d, console B, 2026-11-16) the lead used Bite, as 1x as Strength and first in the plan's order, until its PP ran out, and fought on paralysed with 2 Parlyz Heals in the bag. - moves.json carries each move's power (pret battle_moves.h) in place of the 0/1 damaging flag; attack_slot_against() breaks matchup ties by power, half again for the lead's own type: Strength over Bite on Water foes, Surf still over Blizzard on neutral ones. - cure_of() moves next to status_name() as the one cure table; a trainer battle without a policy uses a Parlyz Heal on PAR unless the bar is red (a Super Potion first at yellow), and the cure clears the status.
20.01a's withdraw failed at the Indigo Plateau (console B, 2026-11-16): 0.8 s after A on WITHDRAW the screen is still the black fade with a white line, and its black has the PKMN DATA panel's hue, so read_pc_screen took it for the box grid and the step failed with the hand unread. The box is up by 3 s. read_pc_screen now reads a dark frame as OTHER before anything else, and the PC dialog waits (up to PC_MAX_OTHER_IN_A_ROW reads, about 5 s) on a screen still changing: a fade, or before the transfer a box screen whose hand isn't read yet. That covers every box screen change: into WITHDRAW's grid and DEPOSIT's party panel, and out of them to the storage menu. Tests: PcScreenReader frames WithdrawOpening (the fade) and IndigoWithdrawBox (the box at 3 s), CommandLineTests pin bumped to dayfine/CommandLineTests 2ce6e68; the fake PC fades into and out of box screens, with the box up 2.5 s after A for a withdrawal and a deposit, and a fade that never ends fails with nothing pressed into it.
… the save's failure frame 19.04d's save came right after exit_route23's warp: START pressed blind 0.5 s after the fade was lost, and on attempt 1 the screen was no overworld at all (the retry's launch read it as an unknown screen), so six blind START + B rounds failed the save and replayed the checkpoint. open_start_menu_settled() reads the screen before every START (StartMenuOpening): waits for a quiet overworld, closes a box with B, fails at once on a battle, and presses START at most three times. Every AutoStory START menu (save, read_save_place, options) opens through it. A failed checkpoint save now saves its frame like a failed step (InterruptLogGuard::save_frame()).
Lorelei (console B, 2026-11-16, 20.01) fainted Blastoise with 13 Full Restores in the bag: the policy took the smallest medicine that clears the foe's hit, a Super Potion or the Potion, and left it in the red. A risk x HP band table now picks the heal: against the rival, gym leaders, bosses, the Elite Four and the Champion a Full Restore (then a Max or Hyper Potion) at yellow or red; low-risk fights keep the hit-based rules.
…included Lorelei (console B, 2026-11-16, 20.01): after four X Specials Blastoise hit Dewgong with Strength for 11 turns; the picker ranked the type multiplier first, then power, and knew no stages or stats. attack_slot_against() now takes the move with the most Gen 3 damage: the lead's level, Attack or Sp. Atk by the move's type at the stage the X Attacks and X Specials used give, the foe's Defense or Sp. Def (the battle step's new foe_stats rows, Lorelei's from the PokeGuy doc), power (Thick Fat halves Fire and Ice), STAB and the type multiplier; ties go to more PP left. Dewgong's worst normal hit goes from 22 to the 30 seen on the console.
20.02 enter_brunos_room failed interrupt_unsettled every time: the step into Lorelei's door returned before its black, and the look before the scene saw the fade back up while the room's script walked the player in. A door's fade was looked at three times (1.2 s on FRLG), well inside battle_after_fade (8 s), so it never settled. Every unsettled screen is now looked at up to max_unsettled_looks (40), as a battle's opening was: a door's fade settles as a warp once no battle came, after any scripted walk, and is cleared as any other.
…re Bruno and Agatha Bruno (console B, 2026-11-16, 20.02): against his first Onix Blastoise used four X Specials, towards the Torrent stall's Sp. Atk +4 (the doc's target_torrent on the opening foe), while Surf KOs Onix at +0; then Onix's Roar sent Blastoise out with its stages, read as a faint. The policy now spends no X item against a foe that the lead's best attack KOs from full HP at the lowest roll (foe_stats rows gain the foe's HP; most_damage_against() gives the estimate), nor against one that phazes (foe_threats' new eighth column: Bruno's first Onix, the Champion's Pidgeot and Arcanine). foe_stats with HP for all five League fights, from PokemonSimulation's pokeguy-conditions table. heal_to_full takes below_percent: 20.02 and 20.03 heal with a Full Restore before the fight only below half HP, the in-battle high-risk rule's line, where it costs no turn.
…ack in Bruno (console B, 2026-11-16, 20.02): Onix's Roar sent Blastoise out at 104/165; the battle loop read the lead's vanished box as a faint and fought on with Lapras and the back row, each using move 1. One rule at a trainer's battle menu (lead_on_field()): our Pokemon out read as the lead's species, the lead is out; another member read out while the loop sent none from the party list, the lead was dragged out and is alive; else a vanished box is a faint. Dragged out, the turn is SWITCH_LEAD: POKEMON, the party list's slot that reads the lead (never the slot out), SHIFT; the policy's stages start over. A switch that can't be made turns the rule off for the battle. read_own_battler() reads the player's HP box name, party_slot_of() the party list's names. Frame tests on the Roar frame (Lapras), the turn before (Blastoise) and Party_6.png; CommandLineTests pinned to the fork commit that adds the two Bruno frames.
No behaviour change; code health for the forced-switch commit. - PokemonFRLG_AutoStoryLeadOut: LeadOnField, lead_on_field() (now taking LeadOnFieldInput instead of two bools), read_own_battler() and party_slot_of(), with their tests (the rule's table, the Bruno frames, Party_6.png) moved from BattleData_Tests and Items_Tests. - PokemonFRLG_AutoStoryBattleSwitch: send_member() and switch_lead_in() out of the battle loop (AutoStoryBattle.cpp was 1004 lines). - take_turn() reads the battlers in read_battlers(); turn_done() hands a turn not done to turn_not_done(). - Param comments on the new presses and read_name() calls; std::format for the own-battler test name.
…d_in's comment names it
… its start league_start reads the Items pocket, stops before Lorelei's door when the bag holds less than the League's minimum (the bag of 2026-11-16), and plans each fight's item budget from it (PokemonFRLG_AutoStoryLeaguePlan). The five fights fight by budgeted C2 (budgeted-setup): a Full Restore only on KO risk, attack a sure KO first, setup capped by the budget, an Elixir when Surf is empty; every turn's state and choice is logged on one line. league_between_fights replaces the per-checkpoint heals: Super Potions up to the next fight's entry HP, a Full Restore only for status or when they run out, Elixirs to the PP floors, and no fight entered on unknown HP. 20.02 to 20.05 fold into 20.01, with no save until the Hall of Fame.
The story planner weighed no trainer's sight (SIGHT_TILE 0), so routes kept out of lines only by chance; #599's open-leg cost moved several into them. 05.06's below_franklin_line went "north 6 (to wall)" up Route 25's column 12, through (12, 4) in Franklin's line (sight 4 east from (11, 4)), and the sim fought him before franklin_line ("no trainer saw the player"). 10.01 fought the beauty, 18.01 met a trainer, and the Route 3 lines test failed on the same walk. story_route_costs() now weighs SIGHT_TILE 100 and SIGHT_OVERSHOOT 10 (the values the Rocket Hideout B2F drawn-route test plans with). The costs count only trainers who stand and look one way: one who wanders or looks around can't be planned round, and the walk watches for them (the lines test's rule: a leg across their sight ends on a wall). Battles the story wants have their own step into the line (03.02's liam_line), so the old reason to leave the costs off is gone. Default costs keep them at 0, so the plan goldens don't change.
…ILE); Cameron's control walks legs 220632a turned SIGHT_TILE on for the story, every trainer counted. The Route 3 lines test then failed on 12.02b's below_warden: the cheapest way crossed Edgar's sight (he looks all four ways, Fuchsia Gym (13, 4)) with an open leg, "south 6" down column 12, where the walker's rule wants a leg across a looker's sight held to a wall. Counting only fixed lines in SIGHT_TILE instead broke the B2F drawn-route test, which plans with SIGHT_TILE round the turning Grunt. SIGHT_TILE keeps its meaning, every trainer, and stays 0 in the story. A new RouteCost::LINE_TILE (0 by default) weighs a tile in the line of a trainer who stands and looks one way; story_route_costs() sets it to 100 and no longer sets SIGHT_TILE or SIGHT_OVERSHOOT. 05.06, 10.01, 18.01, the Route 3 lines test and the B2F drawn route pass. Saffron Gym's "Cameron sees a walk along row 21" is the control that the sim sees Cameron; a planned route now goes round his line, so it walks legs west 8 along row 21 instead.
…nel's sims one floor at a time - story_route_costs(): RouteCost::OPEN_CHECK 0. FRLG walks a tile per step on land, so an open leg lands where it was planned; weighed, the check sent routes to touch walls on the way (12.03 mansion_door: east 3 and north 2 to walls, west 11, north 1, for the console-passed north 3, west 8). The person-as-wall rule (stops_at()) and the walk's own check are unchanged. - 08.01's wild-battle sims run one Rock Tunnel floor per case (PokemonFRLG_AutoStoryRockTunnel_Tests.cpp): each floor from where a clean run of the row reaches it, the trainers fought before it beaten. The whole-row runs took 145 s (12 seeds) and 314 s (30 seeds at the game's odds) on Fork Draft CI. - The B1F dark sims split by steps: row 38's old legs in 4 cases, with the walks without the dark cave's rules in their own case that stops at the first failure; Martha's line in 4 cases. - Each split case logs its time against STAGE_BUDGET (timed_case()). Plan goldens not regenerated: the local build was gated by a console run.
…alation and Strength finisher; Hyper Potion and Full Heal budgets After the 2026-11-16 15:35 run lost at Agatha: - budgeted-setup is one state -> action table (choose_budgeted()'s rows); - asleep: Awakening / Full Heal (never attack asleep with a cure held); a status at KO risk: Full Restore; - a KO-risk heal must gain the foe's best hit plus its mean hit, else the bigger heal: a budgeted Hyper/Max Potion, then a Full Restore; - two medicine turns with the foe's bar unmoved: escalate or attack; - Strength finishes a foe its lowest roll KOs (Bite/Surf keep PP); - the planner budgets Hyper (and Max) Potions and Full Heals per fight; - between fights: Super, Hyper, Max Potion, a Full Restore last; - the League's minimum bag is a restock list, not a precondition; 20.01a's buys are if_affordable, 4 Full Heals.
…turn is no KO risk Every 20.01 foe_threats row was computed against PokeGuy's Lv55 Blastoise (Def 118, Sp. Def 134); console B's is Lv54 (171 HP, Def 135, Sp. Def 150). The rows are regenerated with PokemonSimulation's planning_risk() (#110 tip 9734110) for those stats at full HP; Dewgong keeps its console-seen 30. Venusaur's row said its worst hit (Solar Beam, 222) KOs from full HP, so the policy only ever attacked it (the sim's Champion at 0%). A ninth column marks a foe whose only hit charges a turn first (Venusaur, Cloyster's Dive): its row is a KO risk only after its charge text ("took in sunlight", "hid underwater") or while Sunny Day's sun is out. The battle loop reads the battle text in League fights (read_battle_text()) and hands it to the policy with the turn.
… an override table StoryData/frlg-league-plan.json is the sim's plan.json (4a79ccc), read by league_plan_data(); the checkpoint loader skips it. choose_planned() ports planned.py's rows (locked, sure_ko, sleep_cure, status_ko, ko_heal, cure, kill_order, pp_restore, plan:setup, plan:move) and names the row of each choice; planned_between() ports between(). Gen 3 damage, speed and accuracy helpers follow @smogon/calc as the sim runs it. Tests mirror test_planned.py's cases. Not wired into the battle loop yet.
ConsoleBattleBag::use_row moved the cursor to the top with one UP per row plus CANCEL before every use. The bag keeps its cursor between uses, so the battle now remembers the row it left the cursor on (BattleBagCursor) and moves from there; only the battle's first use, with the cursor unknown, re-homes. A pocket read leaves the cursor on the top row.
took_recovery_item() restored PP for an Elixir only; a Max Elixir fell through to the cure branch, so its count went but the lead's PP stayed as before. That is the Blizzard 0/5 read after the Max Elixir before the Champion (console B, 2026-11-16): the item was used, the count was stale.
The League's fights now go through choose_planned() each turn instead of choose_budgeted() and the steps' foe_threats rows: - StoryData/frlg-league-foes.json: the League trainers' parties (species, level, ability, raw stats, held item, moves) and items, and the moves' data. Exported, not hand-typed, from PokemonSimulation 4a79ccc (sim/frlg-league-plan) data/runs/pokeguy-leafgreen-15934/battle-reference.json, stats from engines/frlg-showdown's teamMember() (pokemon-showdown Gen 3): `node export.cjs battle-reference.json BattleData/moves.json` (the script reads the sim's engine at that commit; Champion: the Bulbasaur rival only, the one the reference has). - PlannedBattle: each turn's PlannedState with every move's damage from Gen3Damage at our tracked stages (X items, Guard Spec's Mist, Intimidate) and badge boosts; Water Absorb, Levitate and the like, Thick Fat, Dragon Rage's fixed 40, multi-hit totals as the sim's 32 quantiles. The trainer's Full Restores used (its "used FULL RESTORE" text) and Pokemon left feed trainer_item_open(); Hyper Beam's recharge, Solar Beam / Dive charges and Sunny Day from the texts. Stages reset when the lead is switched back in after Roar or Whirlwind. - BattleDecisions: a League trainer's battle uses PlannedBattle and no step policy; each turn logs the state and the row that chose. Tests: League foes data built in; damage rolls against @smogon/calc 0.12 with the same stats.
league_between_fights takes the planned policy's between row for the next fight (frlg-league-plan.json): a cure, Super Potions then a Full Restore to the HP target, a PP item to the PP floor, one item at a time, the next fight's item reserve held (the Max Elixir stays until after Lance). After an Elixir or Max Elixir the lead's PP is read off its summary again. An unknown HP still stops the step before the fight. Tests: the planned battle's cases as name / input / expectation tables.
…ts as the sim does The planned policy's state now has both sides' stat stages (Growth, Double Team, Amnesia, Screech, Scary Face from the texts; ours rise from our X items), the foe's sleep, freeze, paralysis, burn and poison, and Sunny Day's sun or Rain Dance's rain, kept by a new BattleTrack. Gen3Damage applies the weather modifier and the physical-only floor of 1 as @smogon/calc does; Guts and a burn reach the foe's hits; Thick Fat stays where calc halves it. Code health: PlannedPolicy.h split into PlannedState, PlannedRisk and PlannedBetween; the plan lookups move to LeagueFightData; choose_planned and planned_between split; use_item becomes a BattleLoop member.
…tat text parse flattened
StoryData/frlg-league-parity.json is 10 League chains of PokemonSimulation's planned policy (pokesim.cli.frlg_league_parity, sim/frlg-league-parity e1fba38, seed parity): 628 turns and top-ups. The test builds the program's state from each turn as the program sees it, then with the sim-only part (the foe's exact HP, sleep counter, PP) put back, and logs the differences by row; with the hidden part back none may differ.
pret's AbilityBattleEffects acts on Intimidate at its holder's entry only (STATUS3_INTIMIDATE_POKES), as the sim's engine does.
The sim's engine (@smogon/calc) gives our Blastoise's Surf x1.5 power at a third of its HP or less; the program's damage didn't, in 110 of the parity file's 597 turns.
…nused heavy includes
The FRLG sims got slower and runs on a slow runner hit the 60-minute limit before the tests finish.
The wild battles class was ~39% of the test step's CPU at 30 seeds a row. A known-failing wild-battles row that passes on the first 5 seeds is skipped, not reported as fixed.
dayfine
added a commit
that referenced
this pull request
Nov 17, 2026
Owner
Author
|
Merged into #652 (frlg/lean); fixes continue there. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #599
The AutoStory "Checks" option only gated two things (FRLG's
checks_screen()and the Master Ball), so Default still read the Bag after every load and ran 17.04'slead_lv50_for_giovannisummary read. This adds one shared table (Pokemon/AutoStory/Types/Pokemon_StoryCheckLevel.h:StoryCheckKind→ lowestStoryCheckLevel, asked throughruns_check()), and every FRLG check site now asks it by kind. A plan action that is a pure check declares its kind in itsStoryActionSpec;TableExecutorskips it below its level and logs<step>: skipped (checks: default). The option's help is generated from the same table. Level checks now pass up toLEVEL_CHECK_TOLERANCE(3) below their minimum, with an orange warning (17.04: 47+ passes, 46 stops), inTypes/Pokemon_StoryLevelCheck.h.check_save_place()after a reload (Events.cpp)add_start_check()inbuild_checkpoint()(Events.cpp)buy_items(), Actions.cpp); item row before using it (bag_row_is(), Battle.cpp)wall_check()(Events.cpp)read_bag_supplies(), Events.cpp; the status/HP recovery after it still runs); Items pocket after the Viridian Mart (ViridianMart.cpp)level(17.02, 17.04, 19.01, 20.01–20.05), via its specLeft as they are, since they are not checks:
read_lead_moves()(battle input),grind_checkand the Fly/TEACH summary reads (decisions),master_ball_skipped(an errand Speedrun skips), Slope Run'scount_items(that dev program's purpose). Planpostconditionsare parse-time only in FRLG. BDSP and PLZA don't useStoryRunOptionson this branch; to adopt it they would pass the level to theirTableExecutor/StoryActionRegistry::dispatch()(the registry has no level yet) and tag their check actions' specs.Tests:
Pokemon::StoryCheckLevel(kind × level matrix and help text),Pokemon::StoryActions(executor skips a check step), FRLG Abilities (level 49/47 pass, 46 fails against 50), and a new FRLG simulation of 17.04 + 17.04b at Default (level check skipped) and Thorough (level check reached). Not compiled locally (a console run held the heavy gate); Fork Draft CI builds and runs them. Nothing run on hardware.The League is now one checkpoint too: 20.01 runs from Lorelei's door to the Hall of Fame with no save between fights (20.02 to 20.05 are folded in).
league_startreads the bag, stops before the door if it holds less than today's bag (8 Full Restores, 15 X Special, 5 X Speed, 3 X Accuracy, 2 Guard Spec, 1 Max Elixir, 1 Elixir, 6 Super Potions), and plans a per-fight item budget from it (PokemonFRLG_AutoStoryLeaguePlan.h); unused budget rolls forward. The fights use budgeted C2 (budgeted-setup): a Full Restore only on KO risk, attack when we move first and the hit surely KOs, setup capped by the budget, an Elixir when Surf is empty, and one log line per turn with our HP, the foe's bar, our stages and the budget left. Between fights,league_between_fightstops HP up with Super Potions to each fight's entry target, uses Elixirs for the PP floors, and never enters a fight on unknown HP. Tested by PokemonSimulation's League chain sim (54% for the whole League with this bag) and new unit tests (League plan, minimum, between fights, budgeted turns); not run on the console.The League policy from PokemonSimulation #111 (4a79ccc) is ported as data plus an override table, not wired in yet.
StoryData/frlg-league-plan.jsonis the sim'splan.json, byte for byte;league_plan_data()reads it and the checkpoint loader skips it.choose_planned()(PokemonFRLG_AutoStoryPlannedPolicy.h) portsplanned.py's rows (locked, sure_ko, sleep_cure, status_ko, ko_heal, cure, kill_order, pp_restore, plan:setup, plan:move) and names the row with each choice.planned_between()portsbetween(), which holds the Max Elixir until after Lance through Lance's item reserve. Gen 3 damage, speed and accuracy follow @smogon/calc, as the sim does, with badge boosts on our side. The Blizzard 0/5 read after the Max Elixir was a stale count:took_recovery_item()restored PP for an Elixir only. A Max Elixir now restores all of it. In battle, the bag remembers where it left the Items pocket's cursor, so only the first item use of a battle re-homes it. Still to do: the battle loop doesn't callchoose_planned()yet, foe party data (levels, moves, Attack) for a live D, the trainer's Full Restore count, switching Blastoise back in after Roar/Whirlwind, and replacingleague_between_fightswithplanned_between(). Tests:PokemonFRLG::AutoStoryPlannedPolicy(built-in plan, Gen 3 rolls checked against @smogon/calc, and one case for each case in test_planned.py plus the Max Elixir PP fix). Nothing run on hardware.