Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
891b8f9
FRLG AutoStory stage 1: core navigation and battles
dayfine Nov 3, 2026
482067e
Merge commit 'bb6db58990bd528ef9f0c54534ea3492dbbcf1e3' into HEAD
dayfine Nov 5, 2026
375f3b3
Merge remote-tracking branch 'origin/nav/story-steps' into frlg/stage…
dayfine Nov 5, 2026
6cd80bc
FRLG AutoStory stage 1: align with PR #231 lint conventions
dayfine Nov 5, 2026
0e4162e
PokemonFRLG: use string_view for file_json to avoid dangling referenc…
dayfine Nov 6, 2026
f29a54e
Merge origin/nav/story-steps into frlg/stage1-core
dayfine Nov 6, 2026
34e6996
Merge origin/nav/story-steps into frlg/stage1-core
dayfine Nov 7, 2026
194ef15
Merge remote-tracking branch 'origin/nav/story-steps' into frlg/stage…
dayfine Nov 8, 2026
c9f9638
Merge branch 'sync/story-export-steps' into sync/story-export-frlg
dayfine Nov 8, 2026
30daacc
Merge branch 'sync/story-export-steps' into sync/story-export-frlg
dayfine Nov 8, 2026
b5c41d3
Export evaluated FRLG story checkpoints for offline validation (#251)
dayfine Nov 8, 2026
7f24578
Merge nav/story-steps into frlg/stage1-core
dayfine Nov 8, 2026
db02350
Merge remote-tracking branch 'origin/nav/story-steps' into HEAD
dayfine Nov 9, 2026
cd32d3f
Merge nav/story-steps into frlg/stage1-core
dayfine Nov 9, 2026
5eb60f1
Merge remote-tracking branch 'origin/nav/story-steps' into HEAD
dayfine Nov 9, 2026
0f79fd2
FRLG AutoStory: run the console executor through the story action table
dayfine Nov 9, 2026
adba2e8
FRLG AutoStory: register the step table tests with the simulation tests
dayfine Nov 9, 2026
ef16b37
FRLG AutoStory: a sim test for a save off the checkpoint's start pose
dayfine Nov 9, 2026
7d5be2c
FRLG AutoStory: check the save stands at the checkpoint's start pose
dayfine Nov 9, 2026
6f235d3
FRLG AutoStory: add the start pose check to a checkpoint already built
dayfine Nov 9, 2026
77c0d8d
FRLG AutoStory: shorten the start pose sim test
dayfine Nov 9, 2026
3343a87
Merge nav/story-steps: time an interrupt's step from its screen events
dayfine Nov 9, 2026
7f0dd9b
FRLG AutoStory: check a loaded save's start against a kept frame
dayfine Nov 9, 2026
b085825
FRLG AutoStory: set up the start frames with the story's state
dayfine Nov 9, 2026
a9dfe15
FRLG AutoStory: test the start check on frames on its own checkpoint
dayfine Nov 9, 2026
a8cc3e7
FRLG AutoStory: keep the start check with the start frames
dayfine Nov 9, 2026
b51bddf
Merge nav/story-steps (#122) into frlg/stage1-core
dayfine Nov 9, 2026
bde6bac
FRLG AutoStory: clear interrupts between story steps on the console
dayfine Nov 9, 2026
3876fbd
FRLG AutoStory: step interrupts test returns its pass
dayfine Nov 9, 2026
40ee31f
FRLG AutoStory: the console's interrupt actions beside the table
dayfine Nov 9, 2026
aaf4fd3
Merge nav/story-steps into frlg/stage1-core (hold watchers for the wa…
dayfine Nov 9, 2026
0b8e597
Merge nav/story-steps into frlg/stage1-core
dayfine Nov 9, 2026
8679be4
Merge nav/story-steps into frlg/stage1-core (wait for a battle's open…
dayfine Nov 9, 2026
1325e52
Merge nav/story-steps into frlg/stage1-core (scene ends after its fad…
dayfine Nov 9, 2026
8c007f5
FRLG AutoStory: log the screen before every step
dayfine Nov 9, 2026
bee7206
Merge nav/story-steps into frlg/stage1-core: a step on the Switch HOM…
dayfine Nov 9, 2026
5e00efa
FRLG AutoStory: look for the Switch HOME menu before each step
dayfine Nov 9, 2026
f5b35c5
Merge nav/story-steps into frlg/stage1-core
dayfine Nov 10, 2026
b3b4cdc
Merge nav/story-steps (one-line route plan) into frlg/stage1-core
dayfine Nov 10, 2026
495c170
FRLG AutoStory: expect the route plan on one log line
dayfine Nov 10, 2026
e4636eb
Merge origin/nav/story-steps into frlg/stage1-core
dayfine Nov 10, 2026
51cb266
FRLG AutoStory: checkpoints 00.01-00.10 as authored JSON, on #312's a…
dayfine Nov 10, 2026
3f0b338
FRLG AutoStory: delete the C++ story rows, parity proven
dayfine Nov 10, 2026
3091169
Merge pull request #330 from dayfine/frlg/stage1-json
dayfine Nov 10, 2026
d0b6ad0
FRLG AutoStory: mark stage 1's checkpoints "phase": "testing"
dayfine Nov 10, 2026
7b9ceb5
Merge pull request #341 from dayfine/frlg/stage1-metadata
dayfine Nov 10, 2026
ac8dd8d
Merge nav/story-steps into frlg/stage1-core
dayfine Nov 10, 2026
4984b17
FRLG: build maps from pinned Packages resources from stage 1 on
dayfine Nov 10, 2026
47a2914
Merge frlg/detectors into frlg/stage1-core
dayfine Nov 10, 2026
43624ca
Merge branch 'frlg/detectors' into maps-pkg/stage1-core
dayfine Nov 10, 2026
d136b1a
FRLG AutoStory: drop the battle sim, strongest move as the fallback
dayfine Nov 10, 2026
0e4cf01
Merge branch 'frlg/detectors' into maps-pkg/stage1-core
dayfine Nov 10, 2026
269b567
FRLG AutoStory: record_story_counts() takes its output last
dayfine Nov 10, 2026
c1a3861
FRLG AutoStory stage 1: std::string_view for char* (code health)
dayfine Nov 10, 2026
61ebf79
FRLG AutoStory: split the large Overworld and AutoStory headers
dayfine Nov 10, 2026
46bfa14
FRLG AutoStory: cut the battle data to what the program reads
dayfine Nov 10, 2026
5da83db
Merge frlg/stage1-program into frlg/stage1-core
dayfine Nov 10, 2026
fb41d2d
Merge branch 'frlg/stage1-program' into frlg/stage1-core
dayfine Nov 11, 2026
0170526
Merge branch 'frlg/stage1-program' into frlg/stage1-core
dayfine Nov 11, 2026
a6067e4
Merge origin/frlg/stage1-program into frlg/stage1-core
dayfine Nov 12, 2026
0c87bba
Merge frlg/stage1-program into frlg/stage1-core
dayfine Nov 14, 2026
2849ab4
Merge frlg/stage1-program into frlg/stage1-core
dayfine Nov 14, 2026
149dc78
Merge frlg/stage1-program into frlg/stage1-core
dayfine Nov 14, 2026
06eb660
Merge frlg/stage1-program into frlg/stage1-core
dayfine Nov 14, 2026
b992860
Merge frlg/stage1-program into frlg/stage1-core
dayfine Nov 14, 2026
7d14b2f
Merge origin/frlg/stage1-program into frlg/stage1-core
dayfine Nov 14, 2026
36be995
Merge origin/frlg/stage1-program into frlg/stage1-core
dayfine Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
/* Overworld Recovery Walk
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <format>
#include <memory>
#include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonFramework/ImageTools/ImageDiff.h"
#include "CommonFramework/VideoPipeline/VideoFeed.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "CommonTools/VisualDetectors/BlackScreenDetector.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h"
#include "PokemonFRLG_OverworldRecoveryWalk.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{

using namespace OverworldWalkSteps;


namespace{

// An open leg stops at its first interruption: walking on from how far it
// got went wrong too often on the console. The timing only narrows where
// the player is, and the route finds them again at a wall. See
// walk_overworld_route_with_recovery().
Pokemon::LegSpec leg_spec(const RouteStep& step, MoveSpeed speed){
Pokemon::LegSpec leg;
leg.direction = step.direction;
leg.tiles = step.tiles;
leg.to_wall = step.to_wall;
leg.tile_time = tile_time(step, speed);
leg.stop_on_interrupt = !step.to_wall;
leg.stop_if_blocked = step.to_wall;
return leg;
}

// One step of a route, for a player facing `facing`. If an open leg
// stopped part-way, returns how far the timing puts the player along it.
std::optional<WalkedTiles> walk_step(

Check warning on line 45 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::walk_step( ConsoleHandle & console , ProControllerContext & context , const RouteStep & step , std :: optional<Direction> facing , const OverworldInterruptSet & interrupts , MoveSpeed speed): function_lines=39 (advisory above 25, limit 50)
ConsoleHandle& console, ProControllerContext& context,
const RouteStep& step, std::optional<Direction> facing,
const OverworldInterruptSet& interrupts, MoveSpeed speed
){
switch (step.action){
case RouteAction::WALK:{
// Turning first, with a tap, makes the hold start from a standstill
// facing the right way: holding through a turn lost a tile on the
// console, while holds from a standstill were exact over 15 tiles.
if (facing != step.direction){
pbf_press_dpad(context, dpad(step.direction), TURN_TAP, TURN_SETTLE);
}
if (const std::string note = speed_note(step, speed); !note.empty()){
console.log(note);
}
const Pokemon::LegResult result = Pokemon::walk_leg(
console, context, leg_mover(step, speed), step.wild ? interrupts.wild : interrupts.other,
leg_spec(step, speed), MAX_INTERRUPTIONS_PER_LEG
);
if (result.stopped){
return walked_near(step, result.tiles, tile_time(step, speed));
}
if (step.warps){
wait_out_warp(console, context, step);
static_assert(AFTER_WARP_BATTLE_WATCH >= AFTER_WARP);
check_warp_was_no_battle(console, context, step);
}
break;
}
case RouteAction::SURF:
start_surf(console, context, step.direction, facing == step.direction);
break;
case RouteAction::FACE:
pbf_press_dpad(context, dpad(step.direction), FACE_HOLD, STEP_RELEASE);
break;
}
return std::nullopt;
}

// walk_step(), then a watch for what its last step set off. Not DONE if
// the player may have stopped short of the step's end: an open leg
// stopped, or something seen after the hold, which may have stopped it
// before the end (after a warp, it was checked for already).
StepOutcome walk_and_watch(
ConsoleHandle& console, ProControllerContext& context,
const RouteStep& step, std::optional<Direction> facing,
const OverworldInterruptSet& interrupts, MoveSpeed speed
){
if (const std::optional<WalkedTiles> walked = walk_step(console, context, step, facing, interrupts, speed)){
return StepOutcome{.end = StepEnd::STOPPED, .walked = walked};
}
if (step.action == RouteAction::FACE){
return StepOutcome{};
}
const Milliseconds watch = step.wild ? AFTER_WILD_LEG_WATCH : AFTER_LEG_WATCH;
const size_t late = Pokemon::clear_late_interrupts(console, context, step.wild ? interrupts.wild : interrupts.other, watch, MAX_INTERRUPTIONS_PER_LEG);
// After a warp it was checked for already.
const bool done = late == 0 || step.warps || step.action != RouteAction::WALK;
return StepOutcome{.end = done ? StepEnd::DONE : StepEnd::LATE, .walked = std::nullopt};
}

// Holds on along `step`, stopped part-way off the grass, until its warp's
// fade. Off the grass only a message stops a leg (a trainer who saw the
// player, a Repel wearing off), and the player then stands on the leg's
// line, so holding on reaches the warp however far they got (console B,
// 2026-11-01: Camper Liam stopped "south 9 (warp)" out of Pewter Gym).
// After a trainer the player faces them, so this turns first.
void hold_to_warp(

Check warning on line 113 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::hold_to_warp( ConsoleHandle & console , ProControllerContext & context , const RouteStep & step , const OverworldInterrupts & interrupts , MoveSpeed speed): function_lines=39 (advisory above 25, limit 50)
ConsoleHandle& console, ProControllerContext& context,
const RouteStep& step, const OverworldInterrupts& interrupts, MoveSpeed speed
){
const Pokemon::LegMover<ProControllerContext> mover = leg_mover(step, speed);
for (size_t count = 0; count <= MAX_INTERRUPTIONS_PER_LEG; count++){
BlackScreenWatcher fade(COLOR_RED);
std::vector<std::unique_ptr<VisualInferenceCallback>> watchers;
std::vector<PeriodicInferenceCallback> callbacks{fade};
for (const auto& interrupt : interrupts){
watchers.emplace_back(interrupt->make_watcher());
callbacks.emplace_back(*watchers.back());
}
context.wait_for_all_requests();
const int ret = run_until<ProControllerContext>(
console, context,
[&](ProControllerContext& context){
pbf_press_dpad(context, dpad(step.direction), TURN_TAP, TURN_SETTLE);
mover(context, step.direction, tile_time(step, speed) * (step.tiles + 2));
},
callbacks
);
if (ret == 0){
wait_out_warp(console, context, step);
check_warp_was_no_battle(console, context, step);
return;
}
if (ret < 0){
break;
}
console.log("Route: " + interrupts[ret - 1]->name() + " on the way to the warp.", COLOR_ORANGE);

Check warning on line 143 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
interrupts[ret - 1]->clear(console, context);
}
OperationFailedExceptionWithScreenshot::fire(
ErrorReportMode::SEND_ERROR_REPORT,
"walk_overworld_route(): no fade holding on toward the warp to " + step.end.map + ".",

Check warning on line 148 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

style: build strings with std::format, not + on a literal / std::to_string / std::string (fork AGENTS.md "Strings")
console
);
}

// A trainer who sees the player stops them, a "!" shows over the trainer,
// the trainer walks up, then speaks. The leg's hold may run on past the
// tile the player was stopped on, so the watch counts from the hold's end,
// with room to spare: on Route 3 (console B, 2026-11-02) Lass Robin's
// message showed after the 500ms watch after the leg had ended. Not
// measured on the console yet.
constexpr Milliseconds TRAINER_NOTICE(1500);
constexpr Milliseconds TRAINER_SPEAKS(1000);

// After `step`, which crosses a trainer's sight: watches for the trainer
// to walk up `approach_tiles` tiles and speak, and clears what shows.
StepEnd watch_for_trainer(
ConsoleHandle& console, ProControllerContext& context,
const RouteStep& step, int approach_tiles, const OverworldInterruptSet& interrupts
){
const Milliseconds watch = TRAINER_NOTICE + TILE_TIME * approach_tiles + TRAINER_SPEAKS;
console.log(std::format("Route: {} crosses a trainer's sight; watching {} ms for them.", to_string(step), watch.count()));
const size_t seen = Pokemon::clear_late_interrupts(
console, context, step.wild ? interrupts.wild : interrupts.other, watch, MAX_INTERRUPTIONS_PER_LEG
);
return seen == 0 ? StepEnd::DONE : StepEnd::LATE;
}

// TODO(forest drift, 2026-11-01): diagnostic; remove or turn into a recovery once the cause is known.
// How much the game screen's top quarter, clear of the player in the
// middle, may change when a tap toward a wall only bumps the player (the
// player's own animation, an animated tile). A step scrolls the whole map
// by a tile. Not yet measured on the console: a guess on the safe side.
constexpr double WALL_TAP_MOVED_RMSD = 20.0;

// Taps once toward the wall `step` ended at (the player faces it, so a tap
// steps if it can) and says whether the map scrolled: whether the player
// moved instead of bumping into the wall.
bool moved_past_wall(ConsoleHandle& console, ProControllerContext& context, const RouteStep& step){
context.wait_for_all_requests();
VideoSnapshot before = console.video().snapshot();
pbf_press_dpad(context, dpad(step.direction), TURN_TAP, TILE_TIME + TURN_SETTLE);
context.wait_for_all_requests();
VideoSnapshot after = console.video().snapshot();
if (!before || !after){
return false;
}
const ImageFloatBox game = GameSettings::instance().GAME_BOX;
const ImageFloatBox band(game.x, game.y, game.width, game.height * 0.25);
const double change = ImageMatch::pixel_RMSD(extract_box_reference(before, band), extract_box_reference(after, band));
console.log(std::format("Position check: a tap toward the wall of {} changed the screen by {:.1f}.", to_string(step), change));
return change > WALL_TAP_MOVED_RMSD;
}

} // namespace


void walk_overworld_route_with_recovery(

Check warning on line 205 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::walk_overworld_route_with_recovery( ConsoleHandle & console , ProControllerContext & context , const std :: vector<RouteStep> & route , const RoutePlanning & planning , std :: optional<Direction> facing , const OverworldInterruptSet & interrupts , MoveSpeed speed): function_lines=36 (advisory above 25, limit 50)
ConsoleHandle& console, ProControllerContext& context,
const std::vector<RouteStep>& route,
const RoutePlanning& planning,
std::optional<Direction> facing,
const OverworldInterruptSet& interrupts,
MoveSpeed speed
){
if (route.empty()){
return;
}
if (!facing){
facing = read_facing(console, context);
}
RouteCalls calls;
calls.walk = [&](const RouteStep& step, std::optional<Direction> from_facing){
clear_open_message(console, context, step.wild ? interrupts.wild : interrupts.other, step);
check_overworld(console, context, step);
return walk_and_watch(console, context, step, from_facing, interrupts, speed);
};
calls.hold_to_warp = [&](const RouteStep& step){
hold_to_warp(console, context, step, interrupts.other, speed);
};
calls.log = [&](const std::string& message){ console.log(message, COLOR_ORANGE); };
calls.fail = [&](const std::string& message){
OperationFailedExceptionWithScreenshot::fire(ErrorReportMode::SEND_ERROR_REPORT, message, console);
};
calls.moved_past_wall = [&](const RouteStep& step){
return moved_past_wall(console, context, step);
};
calls.watch_for_trainer = [&](const RouteStep& step, int approach_tiles){
return watch_for_trainer(console, context, step, approach_tiles, interrupts);
};
run_route(route, facing, &planning, calls);
context.wait_for_all_requests();
}



} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/* Overworld Recovery Walk
*
* From: https://github.com/PokemonAutomation/
*
* The console side of run_route() (PokemonFRLG_OverworldRecovery.h): walks
* a route with the walker's steps (PokemonFRLG_OverworldWalk.h), except
* that an open leg stops at its first interruption, and the route finds
* the player again around where the timing puts them, instead of walking
* on from a count.
*
*/

#ifndef PokemonAutomation_PokemonFRLG_OverworldRecoveryWalk_H
#define PokemonAutomation_PokemonFRLG_OverworldRecoveryWalk_H

#include <optional>
#include <vector>
#include "NintendoSwitch/Controllers/Procon/NintendoSwitch_ProController.h"
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
#include "PokemonFRLG_OverworldRecovery.h"
#include "PokemonFRLG_OverworldRoute.h"
#include "PokemonFRLG_OverworldWalk.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


// Walks `route`, planned with `planning`, at `speed`, as
// walk_overworld_route() does, from the same start: standing still on the
// overworld, not on the bike, facing `facing` (read from the screen if not
// given).
//
// When a battle or a message stops an open leg part-way, where the player
// is isn't guessed: the stop's timing narrows it to a few tiles of the leg
// (walked_near()), from which run_route() finds them again with
// `planning`'s maps and costs, and walks the rest of the route as planned.
//
// After a leg that crosses a trainer's sight it watches for the trainer,
// long enough for them to walk up and speak, and hands what shows to
// `interrupts`; where the maps place the stop, the route goes on from
// there (run_route()).
//
// After each leg to a wall it taps once more toward the wall, and logs
// whether the screen moved (a diagnostic; RoutePlanning::wall_check SKIP
// turns it off, as the Fast checks level does).
//
// A message open before a step is handed to `interrupts` once
// (clear_open_message()). Throws OperationFailedException if a menu or
// message is still open before a step, a warp's fade or the Surf prompt
// doesn't show, a warp's fade turns out to be a wild battle's, a leg is
// interrupted too many times, or the player can't be found again from
// every tile they may be on. A wild battle that starts as the last leg
// ends is cleared before it returns.
void walk_overworld_route_with_recovery(
ConsoleHandle& console, ProControllerContext& context,
const std::vector<RouteStep>& route,
const RoutePlanning& planning,
std::optional<Direction> facing = std::nullopt,
const OverworldInterruptSet& interrupts = default_overworld_interrupts(),
MoveSpeed speed = MoveSpeed::WALK
);



} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Events

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=612 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand All @@ -13,6 +13,7 @@
#include "Pokemon/AutoStory/Pokemon_TilePose.h"
#include "Pokemon/Navigation/Pokemon_RouteLog.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldMaps.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h"
#include "VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldWalk.h"
#include "PokemonFRLG_AutoStoryBattleData.h"
Expand Down Expand Up @@ -93,7 +94,13 @@
env.console.log(std::string(Pokemon::ROUTE_LOG_TAG) + Pokemon::route_arrived_line(label, {{map, tile}}));
}

// The walker's check that each leg to a wall ended at it (a diagnostic):
// with Thorough checks only, as Fast trusts the walk.
WallCheck wall_check(const StoryEnv& env){
return checks_screen(env.checks) ? WallCheck::TAP : WallCheck::SKIP;
}

Outcome walk_route(StoryEnv& env, RunState& state, const StoryStep& step){

Check warning on line 103 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStoryEvents.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::walk_route( StoryEnv & env , RunState & state , const StoryStep & step): function_lines=34 (advisory above 25, limit 50)
const std::vector<TilePos> tiles = Pokemon::tiles_of(state.pose);
if (tiles.size() != 1 || state.pose.certainty != Pokemon::PoseCertainty::TILE){
return Pokemon::outcome_failed("no_pose", Pokemon::to_string(state.pose));
Expand All @@ -119,7 +126,10 @@
return Pokemon::outcome_failed("no_route", to_string(start) + " to " + to_string(goal.position));
}
const OverworldInterruptSet interrupts = story_interrupts(env.supplies, arg<bool>(step, "fight_wild"), env.checks, env.language);
walk_overworld_route(env.console, env.context, *route, facing, interrupts, move_speed(step));
// Planning lets the walker recover a stopped open leg: it plans back to
// the leg's end, then walks the rest as given.
const RoutePlanning planning{.maps = &story_maps(), .costs = default_route_costs(), .start = start, .label = step.name, .wall_check = wall_check(env)};
walk_overworld_route_with_recovery(env.console, env.context, *route, planning, facing, interrupts, move_speed(step));
log_arrival(env, step.name, target->map, target->tile);
const std::optional<Direction> end_facing = route->empty() ? facing : std::optional<Direction>(route->back().facing_after);
return Pokemon::outcome_ok(to_pose(StoryPose{target->map, target->tile, end_facing}));
Expand All @@ -140,7 +150,10 @@
return Pokemon::outcome_failed("bad_legs", to_string(start));
}
const OverworldInterruptSet interrupts = story_interrupts(env.supplies, arg<bool>(step, "fight_wild"), env.checks, env.language);
walk_overworld_route(env.console, env.context, *route, facing, interrupts, move_speed(step));
// Planning lets the walker recover a stopped open leg: it plans back to
// the leg's end, then walks the rest as given.
const RoutePlanning planning{.maps = &story_maps(), .costs = default_route_costs(), .start = start, .label = step.name, .wall_check = wall_check(env)};
walk_overworld_route_with_recovery(env.console, env.context, *route, planning, facing, interrupts, move_speed(step));
log_arrival(env, step.name, route->back().end.map, route->back().end.point);
return Pokemon::outcome_ok(to_pose(StoryPose{route->back().end.map, route->back().end.point, route->back().facing_after}));
}
Expand Down
2 changes: 2 additions & 0 deletions SerialPrograms/cmake/SourceFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2010,6 +2010,8 @@ file(GLOB LIBRARY_SOURCES
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor_Tests.cpp
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.cpp
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery.h
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.cpp
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecoveryWalk.h
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRecovery_Tests.cpp
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.cpp
Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldRoute.h
Expand Down
Loading