Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
f930d22
FRLG 00.26: the Bike Voucher from the Fan Club, back to Cerulean, the…
dayfine Nov 4, 2026
f9d0e01
FRLG tests: register the story rows' sim tests together
dayfine Nov 4, 2026
51c0ce6
FRLG 00.27: east over Route 9 to Route 10's Pokemon Center
dayfine Nov 4, 2026
cc43650
Merge commit '130344db1cb2a394693019d734145f8c295c589b' into HEAD
dayfine Nov 5, 2026
7eb6517
FRLG: use shared wall recovery without changing navigation behavior (…
dayfine Nov 5, 2026
4f40579
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon (align wi…
dayfine Nov 6, 2026
dd43ed6
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 6, 2026
8d6bbe7
Use string views for Celadon test checkpoint lookups
dayfine Nov 7, 2026
34c559b
Merge Vermilion Gym test portability fix into Celadon
dayfine Nov 7, 2026
fa131a8
FRLG: build maps from pinned Packages resources (#238)
dayfine Nov 7, 2026
9ea101e
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 7, 2026
184bb0e
Merge remote-tracking branch 'origin/frlg/stage6-vermilion' into frlg…
dayfine Nov 8, 2026
e6de8c8
Fix missing native test fixtures and MSVC narrowing warning (#243)
dayfine Nov 8, 2026
fc23a7f
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 8, 2026
74d0471
Merge remote-tracking branch 'origin/frlg/stage6-vermilion' into HEAD
dayfine Nov 9, 2026
20d6eca
FRLG: author Parcel checkpoint in JSON and execute it through the sto…
dayfine Nov 9, 2026
14dc3bc
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 9, 2026
3e4cbd8
Merge frlg/stage6-vermilion (story action table) into frlg/stage7-cel…
dayfine Nov 9, 2026
0a1bba1
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 9, 2026
c5c2604
Merge frlg/stage6-vermilion: check the save stands at the checkpoint'…
dayfine Nov 9, 2026
37f1ca3
Merge frlg/stage6-vermilion: keep the simulation tests' line endings
dayfine Nov 9, 2026
a328c4c
FRLG AutoStory: 00.27 itself from a save below Cerulean Center's door
dayfine Nov 9, 2026
78c01f9
FRLG AutoStory: red tests for row 00.27's walk to Route 10's Center
dayfine Nov 9, 2026
85c3890
Merge frlg/stage6-vermilion: time an interrupt's step from its screen…
dayfine Nov 9, 2026
2e2cebc
FRLG: sim test for a wild battle seen after an open leg's hold
dayfine Nov 9, 2026
0e732b4
FRLG AutoStory: 00.27 finds its place on walls on the way to Route 10…
dayfine Nov 9, 2026
3d62951
FRLG: place a wild battle seen after an open leg's hold by its screen…
dayfine Nov 9, 2026
25d866b
Merge frlg/stage7-celadon: 00.27 finds its place on walls on the way …
dayfine Nov 9, 2026
6ce3846
Merge frlg/stage6-vermilion: run the sim through the action table
dayfine Nov 9, 2026
4447711
Merge frlg/stage6-vermilion: check a loaded save's start against a ke…
dayfine Nov 9, 2026
eb2dfc8
Merge b0f7e3faa (#122 via parent) into frlg/stage7-celadon
dayfine Nov 9, 2026
cf8535e
Merge FRLG between-step interrupts (52103a26f) into #224
dayfine Nov 9, 2026
3052e09
Merge FRLG between-step interrupts (effe4c008) into #224
dayfine Nov 9, 2026
802099e
Merge FRLG sim interrupts (141797149) into #224
dayfine Nov 9, 2026
9eab4d7
Merge FRLG interrupt actions move (fe3210ec6) into #224
dayfine Nov 9, 2026
4f85f30
Merge frlg/stage6-vermilion into frlg/stage7-celadon (hold watchers f…
dayfine Nov 9, 2026
f2d20c7
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 9, 2026
195ed57
Merge frlg/stage6-vermilion into frlg/stage7-celadon (wait for a batt…
dayfine Nov 9, 2026
b83cc4c
Merge frlg/stage6-vermilion into frlg/stage7-celadon (scene ends afte…
dayfine Nov 9, 2026
a4e3de3
Merge frlg/stage6-vermilion into frlg/stage7-celadon: a step on the S…
dayfine Nov 9, 2026
93d602b
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 10, 2026
ac8a50e
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 10, 2026
93703c5
Merge frlg/stage6-vermilion (#337) into frlg/stage7-json: stage 7's r…
dayfine Nov 10, 2026
9d78b82
FRLG AutoStory: delete stage 7's C++ story rows, parity proven
dayfine Nov 10, 2026
f6bdfd4
Merge pull request #338 from dayfine/frlg/stage7-json
dayfine Nov 10, 2026
4685868
Merge frlg/stage6-vermilion (0bba8ab42) into frlg/stage7-celadon
dayfine Nov 11, 2026
469b48a
Merge branch 'frlg/stage6-vermilion' into frlg/stage7-celadon
dayfine Nov 11, 2026
a1214ae
Merge branch 'frlg/stage6-vermilion' into frlg/stage7-celadon
dayfine Nov 11, 2026
71a3f4c
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 12, 2026
d0823a2
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 13, 2026
9c31743
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 14, 2026
19288b3
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 14, 2026
3b02c9a
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 14, 2026
9c296fe
Merge frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 14, 2026
6eb6cd6
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
dayfine Nov 14, 2026
1ffa65d
Merge origin/frlg/stage6-vermilion into frlg/stage7-celadon
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
4 changes: 2 additions & 2 deletions .github/workflows/cpp-ci-serial-programs-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ jobs:
uses: actions/checkout@v7
if: inputs.run-tests
with:
# The fork's fixtures: upstream's plus the SystemKeyboardDetector screenshots.
# The fork's fixtures: upstream's, the SystemKeyboardDetector screenshots and pending FRLG image submissions.
repository: 'dayfine/CommandLineTests'
ref: '5de4ff774f9141d904c4b5c557fa7b9dc85eaef1'
ref: '3a6708327b225e71a329d77d8d067305ea4058d2'
path: 'CommandLineTests'

# The unit tests assume the downloadable resources they need are already downloaded
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Overworld Late Battle
*
* From: https://github.com/PokemonAutomation/
*
*/

#include <algorithm>
#include <format>
#include "PokemonFRLG_OverworldWalk.h"
#include "PokemonFRLG_OverworldLateBattle.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


const std::vector<Pokemon::EventLag>& wild_battle_lags(){
static const std::vector<Pokemon::EventLag> LAGS{
{ScreenEvent::BATTLE_STARTED, OverworldWalkSteps::LATE_WILD_BATTLE_DELAY},
};
return LAGS;
}

int tile_reached(Milliseconds since_hold, Milliseconds tile_time, int tiles){
if (tile_time.count() <= 0){
return tiles;
}
if (since_hold.count() < 0){
return 0;
}
const int begun = (int)((since_hold + tile_time / 2) / tile_time) + 1;
return std::clamp(begun, 0, tiles);
}

LateStop place_late_stop(
const RouteStep& step, Milliseconds tile_time,
const ScreenEventLog& log, WallClock hold_start, WallClock now
){
LateStop out;
out.verdict = Pokemon::classify_interrupt(log, {hold_start, now}, {});
if (out.verdict.kind != Pokemon::InterruptKind::WILD_ENCOUNTER){
return out;
}
const std::optional<WallClock> pressed = Pokemon::interrupt_step_time(out.verdict, wild_battle_lags());
if (!pressed){
return out;
}
const Milliseconds since_hold = std::chrono::duration_cast<Milliseconds>(*pressed - hold_start);
out.walked = walked_near(step, tile_reached(since_hold, tile_time, step.tiles), tile_time);
return out;
}

std::string late_stop_line(const RouteStep& step, const LateStop& stop, WallClock hold_start){
std::string out = std::format(
"Route: seen after the hold of {}: {}",
to_string(step), Pokemon::describe(stop.verdict, hold_start)
);
if (stop.walked){
return out + std::format("; {} to {} tiles in.", stop.walked->min, stop.walked->max);
}
return out + "; not placed.";

Check warning on line 61 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle.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")
}



} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* Overworld Late Battle
*
* From: https://github.com/PokemonAutomation/
*
* Where a wild battle seen only after an open leg's hold stopped the
* player. The walker records the leg's screens as timed events
* (ScreenEventLog) through the hold and the watch after it. The
* shared classifier (Pokemon::classify_interrupt()) says what stopped the
* player, and a wild battle is placed by when its first timed event
* showed, not by when the watcher that cleared it fired: that is after the
* hold, and the leg could have stopped anywhere along it.
*
*/

#ifndef PokemonAutomation_PokemonFRLG_OverworldLateBattle_H
#define PokemonAutomation_PokemonFRLG_OverworldLateBattle_H

#include <optional>
#include <string>
#include <vector>
#include "Common/Cpp/Time.h"
#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "Pokemon/AutoStory/Pokemon_Interrupts.h"
#include "CommonTools/ScreenEvents/ScreenEvents.h"
#include "PokemonFRLG_OverworldReanchor.h"
#include "PokemonFRLG_OverworldRoute.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


// The events of a wild battle FRLG has timed from its step: its text box
// ("Wild <Pokemon> appeared!", BATTLE_STARTED), LATE_WILD_BATTLE_DELAY
// after the step on Route 1 (console B, 2026-11-01, run 7). The flashes
// are what the walker missed, and the wipe isn't timed on the console yet.
const std::vector<Pokemon::EventLag>& wild_battle_lags();

// The tile of a leg (from 1) that a step begun `since_hold` into its hold
// reaches: the steps begin a tile apart from the hold's start. At most
// `tiles`.
int tile_reached(Milliseconds since_hold, Milliseconds tile_time, int tiles);

// What stopped an open leg after its hold, and where.
struct LateStop{
Pokemon::InterruptVerdict verdict;
// The tiles of the leg the player may be on. Set for a wild battle
// whose step the log times.
std::optional<WalkedTiles> walked;
};

// For `step`, an open leg held from `hold_start` at `tile_time` a tile,
// after which something was seen and cleared by `now`: what `log` shows
// stopped the player there, and for a wild battle, the tile its step
// reached (tile_reached()), give or take walked_near()'s slack.
LateStop place_late_stop(
const RouteStep& step, Milliseconds tile_time,
const ScreenEventLog& log, WallClock hold_start, WallClock now
);

// "Route: seen after the hold of <step>: wild encounter: +5035 ms battle
// started rose; 5 to 7 tiles in.", times from `hold_start`.
std::string late_stop_line(const RouteStep& step, const LateStop& stop, WallClock hold_start);


// Registers the late battle unit tests, on the sim. add_tests_OverworldSim()
// calls it.
void add_tests_OverworldLateBattle(UnitTestDatabase& database);



} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/* Overworld Late Battle Tests
*
* From: https://github.com/PokemonAutomation/
*
* A wild battle seen only after an open leg's hold, on the sim: the walker
* must place the player within a few tiles of where the battle stopped
* them, find them again and finish the route.
*
*/

#include <cstdio>
#include <format>
#include <optional>
#include <string>
#include <vector>
#include "Common/Cpp/Exceptions.h"
#include "Common/Cpp/TestRunners/UnitTest.h"
#include "PokemonFRLG_OverworldLateBattle.h"
#include "PokemonFRLG_OverworldMaps.h"
#include "PokemonFRLG_OverworldReanchor.h"
#include "PokemonFRLG_OverworldSim.h"
#include "PokemonFRLG_OverworldWalk.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonFRLG{


namespace{

using namespace std::chrono_literals;

struct LateBattleInput{
std::string name;
// The leg's step (from 1) the battle starts on.
int battle_step = 1;
};

struct LateBattleExpectation{
// The most the walker's bound on the player's tile may span, in tiles.
int max_spread = 0;
};

struct LateBattleCase{
LateBattleInput input;
LateBattleExpectation expectation;
};

const std::vector<MapData>& maps(){
static const std::vector<MapData> MAPS = overworld_maps();
return MAPS;
}

// The bound run_route() logged for the stop: "<leg> stopped <min> to <max>
// tiles in; ...".
std::optional<WalkedTiles> logged_bound(const std::vector<std::string>& log){
for (const std::string& line : log){
const size_t at = line.find(" stopped ");
WalkedTiles bound;
if (at != std::string::npos && std::sscanf(line.c_str() + at, " stopped %d to %d tiles in", &bound.min, &bound.max) == 2){
return bound;
}
}
return std::nullopt;
}

// A walk on the sim: how it ended, and what the walker and the sim logged.
struct LateBattleRun{
std::string failure;
SimState state;
std::vector<std::string> log;
};

std::string describe(const LateBattleRun& run){
std::string out = std::format("\n ended on {}, failure: \"{}\"", to_string(run.state.position), run.failure);
for (const std::string& line : run.log){
out += "\n " + line;

Check warning on line 77 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.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")
}
for (const std::string& line : run.state.log){
out += "\n " + line;

Check warning on line 80 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.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")
}
return out;
}

const MapPosition LEG_START{"Route10", {5, 10}};
const MapPosition LEG_END{"Route10", {16, 10}};

// "east 11" from LEG_START through Route 10's grass, with a battle on
// `battle_step` whose flashes are missed.
LateBattleRun walk_with_battle(int battle_step, SimWalkerRules rules){
RouteStep east;
east.direction = Direction::EAST;
east.tiles = 11;
east.wild = true;
east.facing_after = Direction::EAST;
east.end = LEG_END;
SimScript script;
script.encounters = {{.grass_step = battle_step, .seen_late = true}};
script.timing.battle_opening = OverworldWalkSteps::LATE_WILD_BATTLE_DELAY;
script.timing.battle_screen = OverworldWalkSteps::LATE_WILD_BATTLE_DELAY + 800ms;
OverworldSim sim(maps(), LEG_START, Direction::EAST, script);
OverworldSimWalker walker(sim, rules);
const RoutePlanning planning{.maps = &maps(), .costs = default_route_costs(), .start = LEG_START, .label = "Sim"};
LateBattleRun run;
run.failure = walker.run({east}, planning);
run.state = sim.state();
run.log = walker.log();
return run;
}

std::string bound_text(const std::optional<WalkedTiles>& bound){
return bound ? std::format("{} to {}", bound->min, bound->max) : std::string("no bound");
}

// Console B, FRLG 00.27 run 2, 2026-11-09 (~/FRLGLab/captures/
// 2026-11-09-0027-route10-legs.log): on the open leg "east 11" across
// Route 10, wild battles (Voltorb) showed only after the hold. The walker
// took the player to be anywhere on the leg ("stopped 0 to 11 tiles in")
// and walked "east 12 (to wall)" to find them, into a second battle. Here
// the leg crosses Route 10's grass on row 10, the battle's flashes are
// missed, its text box ("Wild <Pokemon> appeared!") shows
// LATE_WILD_BATTLE_DELAY after its step and its HP boxes 800 ms after
// that, as in Mt. Moon (console B, 2026-11-03, row 00.13). After running,
// the walker must bound the player to a few tiles around the battle's.
class Test_OverworldLateBattle : public UnitTest{

Check failure on line 125 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

test-case: construct each UnitTest from one case struct with name, input and expectation fields (input and expectation structs, the name outside the input); register a named table of designated cases in a range-for
public:
explicit Test_OverworldLateBattle(LateBattleCase test_case)
: UnitTest("PokemonFRLG::OverworldLateBattle - " + test_case.input.name)

Check warning on line 128 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.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")
, m_case(std::move(test_case))
{}
virtual UnitTestResult run(Logger&, CancellableScope&) const override{
try{
return run_case();
}catch (Exception& e){
return std::string(e.name()) + ": " + e.message();

Check warning on line 135 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.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")
}
}

private:
UnitTestResult run_case() const{
const int battle = m_case.input.battle_step;
const LateBattleRun now = walk_with_battle(battle, {});
if (!now.failure.empty() || !(now.state.position == LEG_END) || !now.state.violations.empty()){
return "Expected the battle run from and " + to_string(LEG_END) + " reached:" + describe(now);

Check warning on line 144 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.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")
}
const std::optional<WalkedTiles> bound = logged_bound(now.log);
if (!bound || bound->min > battle || bound->max < battle || bound->max - bound->min > m_case.expectation.max_spread){
return std::format(
"Expected the player placed within {} tiles around tile {} of the leg, got {}:{}",
m_case.expectation.max_spread, battle, bound_text(bound), describe(now)
);
}
SimWalkerRules unplaced;
unplaced.place_late_battle = false;
const LateBattleRun old = walk_with_battle(battle, unplaced);
const std::optional<WalkedTiles> whole = logged_bound(old.log);
if (!whole || whole->min != 0 || whole->max != 11){
return "Expected the whole leg, 0 to 11 tiles, without the rule, as on the console, got " + bound_text(whole) + ":" + describe(old);

Check warning on line 158 in SerialPrograms/Source/VideoGames/PokemonFRLG/Overworld/PokemonFRLG_OverworldLateBattle_Tests.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")
}
return true;
}

LateBattleCase m_case;
};

} // namespace


const LateBattleCase LATE_BATTLE_CASES[] = {
{
.input = {.name = "a battle on step 3 of an open leg, seen after the hold", .battle_step = 3},
.expectation = {.max_spread = 2},
},
{
.input = {.name = "a battle on step 6 of an open leg, seen after the hold", .battle_step = 6},
.expectation = {.max_spread = 2},
},
{
.input = {.name = "a battle on step 10, its HP boxes after the leg's watch", .battle_step = 10},
.expectation = {.max_spread = 2},
},
};

void add_tests_OverworldLateBattle(UnitTestDatabase& database){
for (const LateBattleCase& item : LATE_BATTLE_CASES){
database.add<Test_OverworldLateBattle>(item);
}
}



} // namespace PokemonFRLG
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ constexpr std::string_view MAP_NAMES[] = {
"SSAnne_CaptainsOffice",
// Vermilion Gym, past the tree Cut fells.
"VermilionCity_Gym",
// The BIKE VOUCHER and the BICYCLE.
"VermilionCity_PokemonFanClub",
"CeruleanCity_BikeShop",
// East over Route 9 to Route 10's Pokemon Center.
"Route9",
"Route10",
"Route10_PokemonCenter_1F",
"CeruleanCave_1F",
"CeruleanCave_2F",
"CeruleanCave_B1F",
Expand Down
Loading
Loading