Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
@@ -1,4 +1,4 @@
/* Overworld Re-anchor

Check warning on line 1 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=643 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -452,11 +452,12 @@

} // namespace

std::optional<Reanchor> plan_reanchor(

Check warning on line 455 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldReanchor.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::plan_reanchor( const std :: vector<MapData> & maps , const std :: vector<StopCandidate> & candidates , const RouteStep & step , const RouteCosts & costs , std :: optional<Direction> end_facing): function_lines=43 (advisory above 25, limit 50)
const std::vector<MapData>& maps,
const std::vector<StopCandidate>& candidates,
const RouteStep& step,
const RouteCosts& costs
const RouteCosts& costs,
std::optional<Direction> end_facing
){
if (candidates.empty() || step.action != RouteAction::WALK){
return std::nullopt;
Expand All @@ -478,9 +479,9 @@
const Direction facing = at.holds.empty() ? step.direction : at.holds.back().direction;
// The way back keeps clear of every trainer who may stand in it if
// it can, and must walk the same whether they do or not.
std::optional<std::vector<RouteStep>> back = plan_overworld_route(clear_of_trainers, at.at, RouteGoal{step.end, std::nullopt}, costs, facing);
std::optional<std::vector<RouteStep>> back = plan_overworld_route(clear_of_trainers, at.at, RouteGoal{step.end, end_facing}, costs, facing);
if (!back && !trainers.empty()){
back = plan_overworld_route(maps, at.at, RouteGoal{step.end, std::nullopt}, costs, facing);
back = plan_overworld_route(maps, at.at, RouteGoal{step.end, end_facing}, costs, facing);
}
if (!back || (!trainers.empty() && !walks_same_everywhere(worlds, positions, at.at, *back))){
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ struct Reanchor{
// the player, the one that walks the fewest tiles, holds and way back
// together, with tiles of open legs weighted over held ones. Nothing if
// no holds bring them all to one tile, or no way back walks the same from
// there.
// there. With `end_facing`, the way back ends facing that way: the route's
// last leg must leave the player facing as planned, or a step after it only
// turns them (16.03's rival_trigger, a tap west after a way back that ended
// "north 1 (to wall)" beside the trigger; console B, 2026-11-15 00:28).
std::optional<Reanchor> plan_reanchor(
const std::vector<MapData>& maps,
const std::vector<StopCandidate>& candidates,
const RouteStep& step,
const RouteCosts& costs = default_route_costs()
const RouteCosts& costs = default_route_costs(),
std::optional<Direction> end_facing = std::nullopt
);

// Holds to walls that bring the player to one tile from every one of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ class RouteRun{
if (candidates.size() < 2 || (!last && is_wall_hold(m_plan[m_next]) && hold_finds(*maps(), candidates, m_plan[m_next]))){
return;
}
const std::optional<Reanchor> anchor = plan_reanchor(*maps(), candidates, step, m_planning->costs);
const std::optional<Reanchor> anchor = plan_reanchor(*maps(), candidates, step, m_planning->costs, last ? std::optional(step.facing_after) : std::nullopt);
if (water_chain && (!anchor || anchor->holds.empty())){
m_calls.fail(std::format(
"walk_overworld_route(): {} on the water may have ended short with nothing seen, and {} after it is open too; "
Expand Down Expand Up @@ -871,7 +871,7 @@ class RouteRun{
}
const std::optional<Reanchor> anchor = candidates.empty()
? std::nullopt
: plan_reanchor(*maps(), candidates, step, m_planning->costs);
: plan_reanchor(*maps(), candidates, step, m_planning->costs, m_next + 1 == m_plan.size() ? std::optional(step.facing_after) : std::nullopt);
if (!anchor){
m_calls.fail(
"walk_overworld_route(): stopped part-way on " + to_string(step)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* AutoStory Silph Tests

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

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=585 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -295,6 +295,46 @@
return true;
}

// 16.03 to_rival_trigger from 7F's pad (5, 4): "west 2 (open)" to (3, 4)
// ends where a hold can't tell a tile short from none, so the walker finds
// the player at walls and walks back, its last leg "north 1 (to wall)". The
// route must still end facing west, as planned: the rival_trigger step's
// tap west then only turned the player, who never stepped onto the
// trigger (2, 4) (pokefirered data/maps/SilphCo_7F/map.json, coord_events
// (2, 4) and (2, 5), SilphCo_7F_EventScript_RivalTriggerTop) and the
// rival's battle never came (console B, 2026-11-15 00:28, 16.03 run 5).
UnitTestResult test_rival_trigger_walk_ends_facing_west(){

Check warning on line 306 in SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/AutoStory/PokemonFRLG_AutoStorySilph_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::test_rival_trigger_walk_ends_facing_west(): function_lines=31 (advisory above 25, limit 50)
const std::vector<MapData> maps = maps_after_16_02();
const MapPosition pad{"SilphCo_7F", {5, 4}};
const MapPosition beside_trigger{"SilphCo_7F", {3, 4}};
const std::optional<std::vector<RouteStep>> route = plan_overworld_route(
maps, pad, RouteGoal{beside_trigger, Direction::WEST}, story_route_costs(), Direction::WEST
);
if (!route || route->empty()){
return "No route from 7F's pad to (3, 4).";
}
OverworldSim sim(maps, pad, Direction::WEST);
OverworldSimWalker walker(sim);
const RoutePlanning planning{.maps = &maps, .costs = story_route_costs(), .start = pad, .label = "to_rival_trigger"};
if (const std::string failure = walker.run(*route, planning); !failure.empty()){
return std::format("The walk failed: {}", failure);
}
const std::vector<std::string>& log = walker.log();
const bool found_at_walls = std::any_of(log.begin(), log.end(), [](const std::string& line){
return line.find("finding the player at walls") != std::string::npos;
});
if (!found_at_walls){
return "Expected the walker to find the player at walls after \"west 2 (open)\", as on the console.";
}
if (!(sim.state().position == beside_trigger) || sim.state().facing != Direction::WEST){
return std::format(
"Expected {} facing west, got {} facing {}.",
to_string(beside_trigger), to_string(sim.state().position), direction_name(sim.state().facing)
);
}
return true;
}

// 16.03b's checkpoint: Gift RNG's Lapras, on 7F beside the employee.
UnitTestResult test_lapras_handoff(){
const StoryCheckpoint& gift = checkpoint("16.03b");
Expand Down Expand Up @@ -487,6 +527,10 @@
.input = {.name = "16.03 3F's Card Key door, the pad to 7F and the rival; 16.03b to the employee", .body = test_rival_row},
.expectation = {.description = "opens 3F's door_2, ends by the employee on 7F"},
},
{
.input = {.name = "16.03 the walk to the rival's trigger, found again at walls", .body = test_rival_trigger_walk_ends_facing_west},
.expectation = {.description = "after the holds and the way back, on (3, 4) facing west, the trigger (2, 4) a tap ahead"},
},
{
.input = {.name = "16.03b/16.04 the Lapras by Gift RNG", .body = test_lapras_handoff},
.expectation = {.description = "16.03b hands off to Gift RNG for a Lapras; 16.04 is the live save"},
Expand Down
Loading