Skip to content
Closed
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
Expand Up @@ -294,7 +294,7 @@ std::optional<size_t> ConsoleStoryStepIO::tap_to_banner(Direction direction, con
m_stream.log("[Banner] a fade, no \"" + banner + "\" banner after it: counting the fade.", COLOR_ORANGE);
}
if (look != TapLook::NOTHING){
m_context.wait_for(1000ms);
// No fixed wait: the step settles after it (talk_over()).
return tap;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BDSP AutoStory - Story walk steps

Check warning on line 1 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_StoryWalkSteps.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=750 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -129,15 +129,18 @@
const std::function<bool()>& inside, const std::function<void()>& line_up,
const std::string& label
){
// Every way in settles before the walk to the nurse: the inside can
// still fade in whether or not the run saw the fade.
CenterEntry entry = CenterEntry::LINED_UP;
if (io.run_into_door(Direction::NORTH, run).any()){
io.settle(BUTTON_B, label + ": into the Center", false, "");
return CenterEntry::FADED;
}
if (inside()){
return CenterEntry::INSIDE;
entry = CenterEntry::FADED;
}else if (inside()){
entry = CenterEntry::INSIDE;
}else{
line_up();
}
line_up();
return CenterEntry::LINED_UP;
io.settle(BUTTON_B, std::format("{}: into the Center", label), false, "");
return entry;
}

TappedEnd tapped_end(const StoryWorld& world, const std::string& map, const TilePos& pos, const Pokemon::StoryLeg& leg){
Expand Down Expand Up @@ -346,7 +349,11 @@
Outcome StoryWalkSteps::tap_to_banner(const Pose& from, const StoryStep& step){
const Direction direction = story_arg<Direction>(step.args, "direction");
const std::string map = step.pose_after ? Pokemon::grid_pose_of(*step.pose_after).map : "";
// After the way through, the far side may still fade in, and a walk
// then goes nowhere (lab-B 2026-11-10, 00.04b's Center): settle, as
// after a door.
if (through_already(step)){
m_io.settle(BUTTON_B, label_of(step), false, "");
return Pokemon::outcome_ok();
}
const size_t limit = taps_to_banner(from, direction);
Expand All @@ -360,6 +367,7 @@
}else{
log(std::format("[{}] {}: through to {} after {} taps {}.", m_row, step.name, map, *taps, direction_name(direction)));
}
m_io.settle(BUTTON_B, label_of(step), false, "");
return Pokemon::outcome_ok();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
*/

#include <cstdlib>
#include <format>
#include "CommonFramework/VideoPipeline/VideoFeed.h"
#include "CommonTools/Async/InferenceRoutines.h"
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
#include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_RouteWalk.h"
#include "Actions/PokemonBDSP_AutoStory_TalkOver.h"
#include "Actions/PokemonBDSP_AutoStory_Talks.h"
#include "Actions/PokemonBDSP_AutoStory_WildBattle.h"
#include "PokemonBDSP/Programs/AutoStory/Utils/PokemonBDSP_AutoStory_WalkResult.h"
Expand Down Expand Up @@ -200,7 +202,7 @@
// For a player inside a Pokemon Center after a whiteout, at the counter:
// out through the door. The door is straight south of the nurse in most
// Centers; in Oreburgh's it was two tiles east of where we stood (by hand).
void walk_out_of_center(VideoStream& stream, ProControllerContext& context, const std::string& label){

Check warning on line 205 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/PokemonBDSP_AutoStory_Walks.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::walk_out_of_center( VideoStream & stream , ProControllerContext & context , const std :: string & label): function_lines=37 (advisory above 25, limit 50)
finish_dialogue(stream, context, BUTTON_B, label + ": the nurse");
const int shifts[] = {0, 2, -4};
for (int shift : shifts){
Expand Down Expand Up @@ -229,16 +231,9 @@
// "No floor" also reads true on the door's black fade, and the game
// takes no input until it ends: the first D-pad taps after it were
// lost and the gym's door ended a tile away (r215d, r216d; a shot
// per press by hand showed the black frame). Wait for daylight.
const auto start = current_time();
while (current_time() - start < 6000ms){
context.wait_for(100ms);
const VideoSnapshot frame = stream.video().snapshot();
if (frame && mean_brightness(*frame.frame) > 40){
break;
}
}
context.wait_for(1000ms);
// per press by hand showed the black frame). Settle: the fade
// back up and a quiet overworld, not a fixed wait.
talk_over(stream, context, std::format("{}: out of the Center", label));
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
* (6, 9), lab-B 2026-11-09 17:29: the walk took it for a trainer and
* pressed through it). A variant also fails when the walk fights it.
* SimWorldKnobs::scene_at_walk_end.
* - SLOW_FADE_IN: every warp's fade-in runs long, so a move after a fade
* with no settle() between goes nowhere (lab-B 2026-11-10, 00.04b
* heal_sandgem: a fixed 1500 ms wait, then the walk to the nurse
* stopped on "transition"). SimWorldKnobs::slow_fade_in.
*
* Missed and short fades are swept by SimFailureCases_Tests (every single
* missed fade, banner and fade hold).
Expand Down Expand Up @@ -73,6 +77,7 @@ enum class FaultClass{
BATTLE_OPENING,
GRASS_BATTLES,
SCENE_EARLY,
SLOW_FADE_IN,
// Not swept yet: the measured movement table's lost taps (#293).
LOST_TAP,
};
Expand All @@ -86,6 +91,8 @@ std::string_view fault_class_name(FaultClass fault){
return "wild battles on every grass pass";
case FaultClass::SCENE_EARLY:
return "scene starts during the walk before it";
case FaultClass::SLOW_FADE_IN:
return "slow fade-in after every warp";
case FaultClass::LOST_TAP:
return "lost tap";
}
Expand Down Expand Up @@ -317,6 +324,18 @@ UnitTestResult sweep_grass_battles(Logger& logger, const StoryCheckpoint& row){
return sweep_result(logger, FaultClass::GRASS_BATTLES, row.id, 1, failures);
}

// Row `row` with every warp's fade-in slow, all through the row.
UnitTestResult sweep_slow_fade_in(Logger& logger, const StoryCheckpoint& row){
SimWorldKnobs knobs;
knobs.slow_fade_in = true;
const std::string stopped = run_row(logger, row.id, std::move(knobs));
std::vector<SweepFailure> failures;
if (!stopped.empty()){
failures.push_back({"", "a slow fade-in after every warp", stopped});
}
return sweep_result(logger, FaultClass::SLOW_FADE_IN, row.id, 1, failures);
}

// The route before scene step `c` of `steps`, right before it or before
// the plain step onto its trigger; none if there is none.
std::optional<size_t> route_before_scene(const std::vector<StoryStep>& steps, size_t c){
Expand Down Expand Up @@ -431,6 +450,8 @@ class Test_AutoStoryFaultSweep : public UnitTest{
return sweep_grass_battles(logger, m_row);
case FaultClass::SCENE_EARLY:
return sweep_scene_early(logger, m_row);
case FaultClass::SLOW_FADE_IN:
return sweep_slow_fade_in(logger, m_row);
case FaultClass::LOST_TAP:
break;
}
Expand All @@ -448,6 +469,7 @@ const FaultSweepCase FAULT_SWEEP_CASES[] = {
{.input = {.fault = FaultClass::BATTLE_OPENING}, .expectation = {}},
{.input = {.fault = FaultClass::GRASS_BATTLES}, .expectation = {}},
{.input = {.fault = FaultClass::SCENE_EARLY}, .expectation = {}},
{.input = {.fault = FaultClass::SLOW_FADE_IN}, .expectation = {}},
};

void add_tests_AutoStory_FaultSweep(UnitTestDatabase& database){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BDSP AutoStory - Console failure cases on the story simulation

Check warning on line 1 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

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

#include <cstdio>
#include <format>
#include <functional>
#include <map>
#include <optional>
#include <set>
#include <string>
#include <string_view>
#include <vector>
#include "Common/Cpp/Exceptions.h"
#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
Expand Down Expand Up @@ -281,6 +283,42 @@
return passes(early);
}

// How long talk_over() takes to settle inside a Pokemon Center after its
// fade (the heal's settle, lab-B 2026-11-10 00.04b), with the inside's
// visitors walking about the whole time. A visitor walking past changes
// the screen by 10 to 13.4 (WALK_TAP_BLOCKED_CHANGE's note, r244a), under
// its 16, so it reads still: settled TALK_OVER_QUIET after the fade. If the
// inside never read still (a screen moving more than that), the calm rule
// still ends it TALK_OVER_CALM after the fade. Either way it is bounded.
UnitTestResult center_inside_settles(Logger& logger){

Check warning on line 293 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_SimFailureCases_Tests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::center_inside_settles( Logger & logger): function_lines=28 (advisory above 25, limit 50)
struct Inside{
std::string_view what;
bool moving;
Milliseconds most;
};
const Milliseconds fade = 1500ms;
// A look per press: the quiet is seen a press or two after it begins
// (7680 ms for the still case).
const Milliseconds slack = 2000ms;
const Inside cases[] = {
{"visitors walking (reads still)", false, fade + Pokemon::TALK_OVER_QUIET + slack},
{"a screen never still", true, fade + Pokemon::TALK_OVER_CALM + slack},
};
for (const Inside& inside : cases){
const SimScene scene{
sim_fade("the Center's door fade", fade),
sim_pause(std::string(inside.what), 60000ms, inside.moving),
};
const std::string over = play_scene(scene, {});
logger.log(std::format("Center inside, {}: {}", inside.what, over));
long long ms = -1;
if (std::sscanf(over.c_str(), "judged over %lld ms in", &ms) != 1 || ms < fade.count() || ms > inside.most.count()){
return std::format("Center inside, {}: not settled between {} and {} ms: {}", inside.what, fade.count(), inside.most.count(), over);
}
}
return true;
}

// 01.07: after the tag battle the screen fades back from the battle and
// the grunts run off before anyone speaks: a scene that opens with no box,
// 6 s of people moving (Rowan's cutscene shape), then Rowan's and Dawn's
Expand Down Expand Up @@ -614,6 +652,7 @@
return wanderers_move(logger, "01.08");
}}, .expectation = {}},
{.input = {"01.04 Roark's badge speech: the fanfare's pause, then a scene", roark_badge_speech}, .expectation = {}},
{.input = {"inside a Pokemon Center, the settle after the door's fade ends in bounded time with visitors walking", center_inside_settles}, .expectation = {}},
{.input = {"01.07 after the tag battle the grunts run off before anyone speaks", grunts_run_off_before_rowan}, .expectation = {}},
{.input = {"00.03 Rowan's scene opens with no box and fades home", rowans_scene_opens_with_no_box}, .expectation = {}},
{.input = {"00.03 Mom's scene ends with a closing fade: over once it is back up (lab-B 2026-11-09)", moms_scene_ends_with_a_fade}, .expectation = {}},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BDSP AutoStory - Story simulation

Check warning on line 1 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=993 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -182,6 +182,7 @@
// walk's watchers take uniform frames only, so a fade whose hold they
// did not see is missed too.
void SimStoryStepIO::walk_until_stopped(Direction direction, size_t tiles, const std::string& label){
m_route.check_fade_in(label);
m_sim.tap(direction, ROUTE_TURN_TAP, false);
Milliseconds limit = ROUTE_START_DELAY + 800ms + route_ms_per_tile(direction) * (int64_t)(2 * tiles);
SimMove move = m_sim.hold(direction, limit, SimPace::WALK);
Expand All @@ -196,7 +197,8 @@

// The D-pad, a tile at a time, until `map`'s banner reads; through a door
// the walk goes on beyond it (the fade eats no tiles of a hold).
bool SimStoryStepIO::run_until_map(Direction direction, Milliseconds limit, const std::string& map, const std::string&){
bool SimStoryStepIO::run_until_map(Direction direction, Milliseconds limit, const std::string& map, const std::string& label){
m_route.check_fade_in(label);
const bool miss = banner_missed();
size_t on = 0;
for (Milliseconds ran = 0ms; ran < limit; ran += ROUTE_RUN_MS_PER_TILE_ACROSS){
Expand Down Expand Up @@ -230,6 +232,12 @@
// its hold seen or not; with the fade missed whole the look still sees the
// banner.
std::optional<size_t> SimStoryStepIO::tap_to_banner(Direction direction, const std::string& map, size_t max_taps){
const std::optional<size_t> taps = taps_to_banner(direction, map, max_taps);
// Through: the far side fades in as the step ends.
m_misses.fading_in = taps.has_value();
return taps;
}
std::optional<size_t> SimStoryStepIO::taps_to_banner(Direction direction, const std::string& map, size_t max_taps){

Check warning on line 240 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::SimStoryStepIO::taps_to_banner( Direction direction , const std :: string & map , size_t max_taps): function_lines=30 (advisory above 25, limit 50)
if (m_misses.through == m_misses.tap_steps++){
m_misses.missed = true;
if (m_far_side() && m_misses.through_banner){
Expand All @@ -239,6 +247,7 @@
if (std::exchange(m_misses.banner_up, "") == map){
return 0;
}
m_route.check_fade_in(std::format("{}: taps toward {}", m_step, map));
bool crossed = false;
for (size_t tap = 1; tap <= max_taps; tap++){
const SimMove move = m_sim.tap(direction, 160ms, false);
Expand All @@ -259,7 +268,19 @@
return std::nullopt;
}

void SimKnobRouteIO::check_fade_in(const std::string& label){
if (m_knobs.slow_fade_in && std::exchange(m_misses.fading_in, false)){
note(std::format("{}: moved while the last warp still faded in (no settle after it).", label), RouteNote::FAILURE);
}
}

WalkResult SimKnobRouteIO::walk_to_wall(const RouteWallWalk& walk){
check_fade_in(walk.label);
return GridSimRouteIO::walk_to_wall(walk);
}

WalkResult SimKnobRouteIO::walk_taps(Direction direction, size_t tiles, const std::string& label){
check_fade_in(label);
const WalkResult result = GridSimRouteIO::walk_taps(direction, tiles, label);
if (result.stop != WalkStop::LIMIT || m_slid_steps.contains(m_step)){
return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* BDSP AutoStory - Story simulation

Check warning on line 1 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h

View workflow job for this annotation

GitHub Actions / code-health

Code health (bypass)

<header>: header_symbols=9 over limit 8, bypassed by the tag at line 11: "story simulation executor, scenario runners and mock IO"

Check warning on line 1 in SerialPrograms/Source/PokemonBDSP/Programs/AutoStory/Simulation/PokemonBDSP_AutoStory_StorySim.h

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

<file>: file_lines=587 (advisory above 500, limit 1000)
*
* From: https://github.com/PokemonAutomation/
*
Expand All @@ -14,6 +14,7 @@
#ifndef PokemonAutomation_PokemonBDSP_AutoStory_StorySim_H
#define PokemonAutomation_PokemonBDSP_AutoStory_StorySim_H

#include <format>
#include <functional>
#include <map>
#include <memory>
Expand Down Expand Up @@ -177,6 +178,11 @@
// walk's last tiles (its target): its trigger lies on the way, so the
// walk runs into it (00.04's Mom's call on (6, 9), lab-B 2026-11-09 17:29).
std::function<bool(const std::string& row, const std::string& step)> scene_at_walk_end = nullptr;
// Every warp's fade-in runs long: a walk, a tap or a door run after a
// door's fade or a tap step's way through, with no settle() between,
// goes nowhere (lab-B 2026-11-10, 00.04b heal_sandgem walked to the
// nurse 1500 ms after the Center's fade and stopped on "transition").
bool slow_fade_in = false;
};

namespace detail{
Expand All @@ -198,8 +204,12 @@
, m_cross(std::move(cross))
{}

virtual WalkResult walk_to_wall(const RouteWallWalk& walk) override;
virtual WalkResult walk_taps(Pokemon::Direction direction, size_t tiles, const std::string& label) override;
virtual bool dialog_within(Milliseconds wait, Color color) override;
// With SimWorldKnobs::slow_fade_in, fails the move `label` if the last
// warp is still fading in (SimMisses::fading_in).
void check_fade_in(const std::string& label);

private:
WalkResult slide_on(const SimSlide& slide, WalkResult result);
Expand Down Expand Up @@ -310,6 +320,7 @@
// (story_arrival_banner(): the sim's maps have no banners of their own).
virtual WarpSeen run_into_door(Pokemon::Direction direction, bool run, Milliseconds timeout = Milliseconds(12000),
Milliseconds dark_from = Milliseconds(0), const std::string& banner = "") override{
m_route.check_fade_in(std::format("{}: run into the door", m_step));
const SimPace pace = run ? SimPace::RUN : SimPace::WALK;
if (false_dark() && dark_from <= detail::SIM_FALSE_DARK && detail::SIM_FALSE_DARK < timeout){
m_sim.hold(direction, detail::SIM_FALSE_DARK, pace);
Expand All @@ -331,6 +342,8 @@
virtual std::optional<size_t> tap_to_banner(Pokemon::Direction direction, const std::string& map, size_t max_taps) override;

private:
// tap_to_banner()'s taps, before it marks the far side fading in.
std::optional<size_t> taps_to_banner(Pokemon::Direction direction, const std::string& map, size_t max_taps);
// How the run shows its next fade (SimMisses): whole, its hold unseen,
// or not at all.
enum class FadeShown{
Expand Down
Loading