Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f210912
FRLG AutoStory: 00.12c the Magikarp into BOX 1, 00.13 through Mt. Moon
dayfine Nov 3, 2026
0a59803
FRLG OverworldSim: Mt. Moon's ladders, Grunt, short leg and way out
dayfine Nov 3, 2026
1c8be3a
Merge frlg/autostory-run-plan-tests into frlg/mt-moon-story
dayfine Nov 3, 2026
6fb1789
Merge frlg/autostory-run-plan-tests into frlg/mt-moon-story
dayfine Nov 3, 2026
9aec2ea
FRLG AutoStory 00.12c: skip the Magikarp's deposit without Gift RNG
dayfine Nov 3, 2026
91542ff
Merge frlg/autostory-run-plan-tests into frlg/mt-moon-story
dayfine Nov 3, 2026
aedac4e
FRLG OverworldSim: Mt. Moon's wild battle on the leg onto 1F's ladder
dayfine Nov 3, 2026
aa9cca6
Merge frlg/autostory-run-plan-tests into frlg/mt-moon-story
dayfine Nov 3, 2026
3913136
Merge frlg/autostory-run-plan-tests into frlg/mt-moon-story
dayfine Nov 3, 2026
45d3092
FRLG sim: a battle seen only after a leg to a wall in Mt. Moon B1F
dayfine Nov 3, 2026
0ad1ce8
Merge frlg/autostory-run-plan-tests (battle loop: end on the overworl…
dayfine Nov 3, 2026
77ca962
Merge frlg/autostory-run-plan-tests (walker: a battle's black after a…
dayfine Nov 3, 2026
d645d18
FRLG sim tests: Mt. Moon B2F's black after "east 7", and a battle see…
dayfine Nov 3, 2026
ba78400
Merge frlg/autostory-run-plan-tests (a cave's floor closed on one sid…
dayfine Nov 3, 2026
c8651c9
FRLG sim tests: Mt. Moon B2F's "east 7" is now planned wild; the test…
dayfine Nov 3, 2026
1d229f1
Merge frlg/autostory-run-plan-tests (a disabled move, and a move list…
dayfine Nov 3, 2026
8d873d8
Merge frlg/autostory-mvp (matchup attacks in every battle) into frlg/…
dayfine Nov 3, 2026
108b79e
Merge frlg/autostory-run-plan-tests (HP bar share, nurse for yellow H…
dayfine Nov 3, 2026
79265c8
Merge frlg/autostory-run-plan-tests (79a453694: verify mode from #122…
dayfine Nov 3, 2026
6ec171b
Merge frlg/autostory-run-plan-tests (5ae6e4897: battle sim from #120)…
dayfine Nov 3, 2026
643a75e
Merge frlg/autostory-run-plan-tests into frlg/mt-moon-story
dayfine Nov 3, 2026
7ded3ae
Merge frlg/autostory-run-plan-tests (the console's TEACH through the …
dayfine Nov 3, 2026
a6d342c
Merge frlg/autostory-run-plan-tests (GRIND until the boss is winnable…
dayfine Nov 3, 2026
0cc55f5
Merge frlg/autostory-run-plan-tests (GRIND/CAPTURE missed flash, TEAC…
dayfine Nov 3, 2026
fe519ed
Merge frlg/autostory-run-plan-tests (bag rows below an item the reade…
dayfine Nov 3, 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
@@ -1,4 +1,4 @@
/* Overworld Sim Tests

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

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=807 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand All @@ -12,6 +12,8 @@
*
*/

#include <algorithm>
#include <cstdlib>
#include <format>
#include <functional>
#include <optional>
Expand Down Expand Up @@ -503,6 +505,274 @@
return true;
}

// Mt. Moon (story row 00.13): every floor tile has wild encounters, and
// the floors join by ladders taken on stepping onto them. From the Moon
// Stone (3, 2) on 1F down to the foot of B2F's ladder: two ladders, each
// a fade.
UnitTestResult test_mt_moon_ladders(){
const SimCase c{.start = at("MtMoon_1F", 3, 3), .facing = Direction::NORTH, .goal = at("MtMoon_B2F", 26, 21)};
const SimRun now = run_case(c);
if (!arrived(now, c.goal) || now.state.warps != 2){
return "Expected B2F reached by two ladders:" + describe(now);
}
return true;
}

// The Moon Stone's ball (3, 2) on Mt. Moon 1F is a short way off the way
// down: from (11, 3), where 00.13's walk up column 11 ends, to face it
// and then on to B1F costs a few tiles more than going straight, and
// both walks end where they were planned to.
UnitTestResult test_moon_stone_detour(){

Check warning on line 525 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldSim_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonFRLG::test_moon_stone_detour(): function_lines=26 (advisory above 25, limit 50)
const MapPosition from = at("MtMoon_1F", 11, 3);
const MapPosition ball_front = at("MtMoon_1F", 3, 3);
const MapPosition b1f = arrival("MtMoon_B1F", "warp_0");
const auto tiles = [](const std::vector<RouteStep>& route){
int count = 0;
for (const RouteStep& step : route){
count += step.tiles;
}
return count;
};
const SimCase straight{.start = from, .facing = Direction::NORTH, .goal = b1f};
const SimCase to_ball{.start = from, .facing = Direction::NORTH, .goal = ball_front};
const SimCase on{.start = ball_front, .facing = Direction::NORTH, .goal = b1f};
const int extra = tiles(planned(to_ball)) + tiles(planned(on)) - tiles(planned(straight));
if (extra > 8){
return std::format("Expected the detour to cost 8 tiles or fewer, not {}:", extra) + describe(planned(to_ball)) + describe(planned(on));
}
for (const SimCase& c : {to_ball, on}){
const SimRun run = run_case(c);
if (!arrived(run, c.goal)){
return "Expected the detour walked:" + describe(run);
}
}
return true;
}

// Mt. Moon B2F: the Grunt at (37, 21) looks around (sight 3) over the
// only way east. 00.13 crosses his room on legs to walls; the sim's
// trainers see every way they may look, so he sees the player on
// (37, 22), is fought, and the leg is held on to its wall.
UnitTestResult test_mt_moon_grunt_mid_leg(){
SimCase c{.start = at("MtMoon_B2F", 32, 22), .facing = Direction::SOUTH, .goal = at("MtMoon_B2F", 39, 14)};
c.route = std::vector<RouteStep>{
leg(Direction::EAST, 8, at("MtMoon_B2F", 40, 22), true),
leg(Direction::NORTH, 3, at("MtMoon_B2F", 40, 19), true),
leg(Direction::WEST, 1, at("MtMoon_B2F", 39, 19), false),
leg(Direction::NORTH, 5, c.goal, true),
};
const SimRun now = run_case(c);
if (!arrived(now, c.goal) || now.state.trainers_beaten != std::vector<std::string>{"rocket_m"}){
return "Expected the Grunt fought once and the legs walked:" + describe(now);
}
return true;
}

// Mt. Moon B2F: 00.13's open leg east along the bottom row, (8, 38) to
// (11, 38), ends a tile short with nothing on screen. The hold north
// after it would end on (10, 21), a column west of the Grunt's line the
// table steps into from (11, 21): the walker finds the player at walls
// and walks back first. Taken as walked, the route ends on (10, 21).
UnitTestResult test_mt_moon_short_leg(){
SimCase c{.start = at("MtMoon_B2F", 8, 38), .facing = Direction::WEST, .goal = at("MtMoon_B2F", 11, 21)};
c.route = std::vector<RouteStep>{
leg(Direction::EAST, 3, at("MtMoon_B2F", 11, 38), false),
leg(Direction::NORTH, 17, c.goal, true),
};
c.script.short_holds[1] = 1;
const SimRun now = run_case(c);
if (!arrived(now, c.goal)){
return "Expected the player found at walls after the short leg, and the route walked:" + describe(now);
}
SimCase trusted = c;
trusted.open_leg_check = OpenLegCheck::TRUST;
const SimRun old = run_case(trusted);
if (!old.failure.empty() || !(old.state.position == at("MtMoon_B2F", 10, 21))){
return "Expected the walk claimed done on (10, 21) without the check:" + describe(old);
}
return true;
}

// Mt. Moon: a wild battle whose flashes are missed stops a leg to a wall
// part-way (every cave tile can start one); it is run from and the leg
// walked again, and the route goes on down the ladders.
UnitTestResult test_mt_moon_late_battle(){
SimCase c{.start = at("MtMoon_1F", 3, 3), .facing = Direction::NORTH, .goal = at("MtMoon_B2F", 26, 21)};
c.script.encounters = {{.grass_step = 9, .seen_late = true}};
const SimRun now = run_case(c);
if (!arrived(now, c.goal)){
return "Expected the battle run from, then B2F reached:" + describe(now);
}
return true;
}

// Console B, 2026-11-03 (row 00.13, b2f_ladder_foot): a wild battle whose
// flashes were missed started on "south 3 (warp)" from (5, 3) to 1F's
// ladder; its wipe passed for the ladder's fade, and the walker stopped as
// off the route, with the player on (5, 5). A battle on the leg's first or
// second step is now run from, the player found again on the leg, and the
// route goes on down both ladders. Without the rule it stops as it did.
UnitTestResult test_mt_moon_battle_on_ladder_leg(){
const SimCase c{.start = at("MtMoon_1F", 3, 3), .facing = Direction::NORTH, .goal = at("MtMoon_B2F", 26, 21)};
for (size_t tile : {1, 2}){
const std::optional<SimRun> now = run_with_battle_on_warp_leg(c, tile);
if (!now){
return std::format("Expected a leg onto 1F's ladder with a cave step {}:", tile) + describe(planned(c));
}
if (!arrived(*now, c.goal) || now->state.warps != 2){
return std::format("Expected the battle on step {} run from, then B1F and B2F reached:", tile) + describe(*now);
}
}
SimCase off = c;
off.rules.find_player_after_warp_battle = false;
const std::optional<SimRun> old = run_with_battle_on_warp_leg(off, 2);
if (!old || !stopped_with(*old, "a wild battle, not the warp to MtMoon_B1F: the player is off the route.")
|| !(old->state.position == at("MtMoon_1F", 5, 5))
){
return "Expected a stop as off the route on (5, 5) without the rule:" + (old ? describe(*old) : "");
}
return true;
}

// Console B, 2026-11-03 (row 00.13, b2f_ladder_foot): on B1F a wild
// battle started part-way down "south 15 (to wall)" from (3, 3), with its
// flashes missed. Its HP boxes came over 5 s after the step, after the
// leg's watch had ended on the battle's empty text box: the leg was taken
// as walked to (3, 18), and "east 19 (warp)" was walked into the battle
// from a tile it wasn't on. The console ran (133 ms a tile) and the sim
// walks, so the battle starts a few steps later here, for the same
// timing. The text box after the watch is now watched on for, the leg
// walked again to its wall, and the route reaches B2F's ladder. Without
// the rule the leg is taken as walked, and the run stops on no fade onto
// the ladder down to B2F, as it did.
UnitTestResult test_mt_moon_battle_seen_after_wall_leg(){
SimCase c{.start = at("MtMoon_B1F", 3, 3), .facing = Direction::SOUTH, .goal = at("MtMoon_B2F", 26, 21)};
c.script.encounters = {{.grass_step = 13, .seen_late = true}};
c.script.timing.battle_opening = Milliseconds(4500);
c.script.timing.battle_screen = Milliseconds(5300);
const std::vector<RouteStep> route = planned(c);
if (route.empty() || to_string(route[0]) != "walk south 15 (to wall) -> MtMoon_B1F (3, 18)"){
return "Expected the route to start with \"south 15 (to wall)\":" + describe(route);
}
const SimRun now = run_case(c);
if (!arrived(now, c.goal) || now.state.warps != 1){
return "Expected the battle run from, the leg walked again and B2F reached:" + describe(now);
}
SimCase off = c;
off.rules.watch_on_for_unseen_battle = false;
off.rules.battle_before_step = false;
const SimRun old = run_case(off);
const bool taken_as_walked = std::any_of(old.log.begin(), old.log.end(), [](const std::string& line){
return line.find("south 15 (to wall): ended at MtMoon_B1F (3, 18) (walked)") != std::string::npos;
});
if (!taken_as_walked || !stopped_with(old, "no fade in and out after walking onto the warp to MtMoon_B2F.")){
return "Expected the leg taken as walked and the run stopped on no fade, as on the console, without the rule:" + describe(old);
}
return true;
}

// Console B, 2026-11-03 (row 00.13, b2f_south): on Mt. Moon B2F a wild
// battle started on the first step of "east 7 (to wall)" from (39, 14),
// along tiles closed on their north side, which the maps didn't mark as
// wild then: the leg watched only for messages, and the screen was black
// after it. The leg was taken as walked to (46, 14); "south 14 (to
// wall)" saw the battle, ran, and was held again from (40, 14), to
// (40, 17), and every leg after it went on about 6 tiles off. The sim
// walks the route from (39, 14) on to below Miguel's trigger (14, 12),
// with the battle's wipe black from 1 s after its step and its HP boxes
// at 5.3 s, as on the console.
SimCase b2f_east_battle_case(){
SimCase c{.start = at("MtMoon_B2F", 39, 14), .facing = Direction::NORTH, .goal = at("MtMoon_B2F", 14, 12)};
c.route = std::vector<RouteStep>{
leg(Direction::EAST, 7, at("MtMoon_B2F", 46, 14), true),
leg(Direction::SOUTH, 14, at("MtMoon_B2F", 46, 28), true),
leg(Direction::WEST, 9, at("MtMoon_B2F", 37, 28), true),
leg(Direction::SOUTH, 10, at("MtMoon_B2F", 37, 38), true),
leg(Direction::WEST, 29, at("MtMoon_B2F", 8, 38), true),
leg(Direction::EAST, 3, at("MtMoon_B2F", 11, 38), false),
leg(Direction::NORTH, 17, at("MtMoon_B2F", 11, 21), true),
leg(Direction::EAST, 3, at("MtMoon_B2F", 14, 21), false),
leg(Direction::NORTH, 9, c.goal, false),
};
// As the planner marked them on the console: all but "east 7", whose
// floor closed on the north the maps didn't yet mark wild.
for (RouteStep& step : *c.route){
step.wild = to_string(step) != "walk east 7 (to wall) -> MtMoon_B2F (46, 14)";
}
c.script.wild_floor_maps = {"MtMoon_B2F"};
c.script.encounters = {{.grass_step = 1, .seen_late = true}};
c.script.timing.battle_wipe = Milliseconds(1000);
c.script.timing.battle_opening = Milliseconds(4500);
c.script.timing.battle_screen = Milliseconds(5300);
return c;
}

bool logged(const SimRun& run, const std::string& text){
return std::any_of(run.log.begin(), run.log.end(), [&](const std::string& line){
return line.find(text) != std::string::npos;
});
}

// The black after "east 7" is now a battle on its way: it is run from,
// the leg walked again to its wall, and the route reaches (14, 12).
// Without the rule, and without the check before the next step, the sim
// goes the console's way: "east 7" is taken as walked, and the route ends
// far from (14, 12).
UnitTestResult test_mt_moon_black_after_unmarked_leg(){
const SimCase c = b2f_east_battle_case();
const std::vector<RouteStep> planned_route = plan_overworld_route(maps(), c.start, RouteGoal{at("MtMoon_B2F", 46, 14), std::nullopt}).value_or(std::vector<RouteStep>{});
if (planned_route.size() != 1 || to_string(planned_route[0]) != "walk east 7 (to wall) -> MtMoon_B2F (46, 14)"){
return "Expected the planner's \"east 7 (to wall)\" from (39, 14):" + describe(planned_route);
}
const SimRun now = run_case(c);
if (!arrived(now, c.goal) || !logged(now, "a battle's wipe after walk east 7 (to wall)")){
return "Expected the black after \"east 7\" watched on, the battle run from and (14, 12) reached:" + describe(now);
}
SimCase off = c;
off.rules.watch_on_after_unmarked_leg = false;
off.rules.battle_before_step = false;
const SimRun old = run_case(off);
const int off_by = std::abs(old.state.position.point.x - c.goal.point.x) + std::abs(old.state.position.point.y - c.goal.point.y);
if (!logged(old, "east 7 (to wall): ended at MtMoon_B2F (46, 14) (walked)") || (old.failure.empty() && off_by < 6)){
return "Expected \"east 7\" taken as walked and the route ended or stopped far from (14, 12), as on the console, without the rules:" + describe(old);
}
return true;
}

// The same battle, its black seen only before the next step (on the
// console the check after the leg can come before the wipe): the step
// isn't walked, and the player is found on "east 7", walked again to its
// wall, not on "south 14"'s line.
UnitTestResult test_mt_moon_battle_before_next_leg(){
SimCase c = b2f_east_battle_case();
c.rules.watch_on_after_unmarked_leg = false;
c.wall_check = WallCheck::SKIP;
const SimRun now = run_case(c);
if (!arrived(now, c.goal) || !logged(now, "a battle's wipe before walk south 14 (to wall)")){
return "Expected the battle seen before \"south 14\", \"east 7\" walked again and (14, 12) reached:" + describe(now);
}
SimCase off = c;
off.rules.battle_before_step = false;
const SimRun old = run_case(off);
if (old.state.position == c.goal){
return "Expected the route to end off (14, 12) without the check before a step:" + describe(old);
}
return true;
}

// Mt. Moon B2F, after the HELIX FOSSIL: the player steps onto (14, 7),
// where it lay, and the way out goes north through the gap, west to the
// ladder (5, 10), up to B1F and out of its east end onto Route 4, walked
// a tile south of the cave mouth.
UnitTestResult test_mt_moon_way_out(){
const SimCase c{.start = at("MtMoon_B2F", 14, 7), .facing = Direction::NORTH, .goal = at("Route4", 32, 6)};
const SimRun now = run_case(c);
if (!arrived(now, c.goal) || now.state.warps != 2 || now.state.facing != Direction::SOUTH){
return "Expected Route 4 east of the mountain reached by two warps, facing south:" + describe(now);
}
return true;
}

}


Expand All @@ -518,6 +788,16 @@
database.add<Test_OverworldSim>("a short leg, nothing seen", test_short_leg_unseen);
database.add<Test_OverworldSim>("a trainer on the way out of Pewter Gym", test_trainer_on_way_out);
database.add<Test_OverworldSim>("out of Viridian Mart from the clerk's scene", test_mart_exit);
database.add<Test_OverworldSim>("Mt. Moon: down the ladders to B2F", test_mt_moon_ladders);
database.add<Test_OverworldSim>("Mt. Moon: the Moon Stone is a short detour", test_moon_stone_detour);
database.add<Test_OverworldSim>("Mt. Moon: the Grunt who looks around stops a leg to a wall", test_mt_moon_grunt_mid_leg);
database.add<Test_OverworldSim>("Mt. Moon: a short open leg before the Grunt's line", test_mt_moon_short_leg);
database.add<Test_OverworldSim>("Mt. Moon: a late wild battle in the cave", test_mt_moon_late_battle);
database.add<Test_OverworldSim>("Mt. Moon: after the HELIX, out to Route 4", test_mt_moon_way_out);
database.add<Test_OverworldSim>("Mt. Moon: a battle on the leg onto 1F's ladder", test_mt_moon_battle_on_ladder_leg);
database.add<Test_OverworldSim>("Mt. Moon: a battle seen only after a leg to a wall", test_mt_moon_battle_seen_after_wall_leg);
database.add<Test_OverworldSim>("Mt. Moon: black after a leg not marked wild", test_mt_moon_black_after_unmarked_leg);
database.add<Test_OverworldSim>("Mt. Moon: a battle seen only before the next leg", test_mt_moon_battle_before_next_leg);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Test_RunPlan : public UnitTest{
};

void add_tests_RunPlan(UnitTestDatabase& database){
const std::string TODAY = "00.01 00.02 00.03 00.04 00.05 00.06 00.07 00.08 00.09 00.10 00.11 00.12";
const std::string TODAY = "00.01 00.02 00.03 00.04 00.05 00.06 00.07 00.08 00.09 00.10 00.11 00.12 00.12c 00.13";
const RunPlanScenario scenarios[] = {
{.name = "handoffs off: the story as before", .first = "00.01", .expected_ids = TODAY},
{.name = "handoffs off: a range", .first = "00.02", .last = "00.04", .expected_ids = "00.02 00.03 00.04"},
Expand Down Expand Up @@ -163,8 +163,8 @@ void add_tests_GiftRunPlan(UnitTestDatabase& database){
.expected_ids = "00.11 00.12",
.expected_stop = StoryHandoff::GIFT_RNG,
},
{.name = "Gift RNG off: 00.12b is passed over", .first = "00.11", .expected_ids = "00.11 00.12"},
{.name = "Gift RNG off: 00.12b runs when started at", .first = "00.12b", .expected_ids = "00.12b"},
{.name = "Gift RNG off: 00.12b is passed over", .first = "00.11", .expected_ids = "00.11 00.12 00.12c 00.13"},
{.name = "Gift RNG off: 00.12b runs when started at", .first = "00.12b", .expected_ids = "00.12b 00.12c 00.13"},
{
.name = "Gift RNG: started at 00.12b, from the save beside the salesman",
.first = "00.12b",
Expand All @@ -179,7 +179,7 @@ void add_tests_GiftRunPlan(UnitTestDatabase& database){
.expected_ids = "",
.expected_stop = StoryHandoff::GIFT_RNG,
},
{.name = "Starter RNG alone: 00.12b runs when started at", .first = "00.12b", .handoffs = {.starter_rng = true}, .expected_ids = "00.12b"},
{.name = "Starter RNG alone: 00.12b runs when started at", .first = "00.12b", .handoffs = {.starter_rng = true}, .expected_ids = "00.12b 00.12c 00.13"},
{
.name = "Starter RNG first, with both on",
.first = "00.03",
Expand Down
Loading
Loading