From 944abe85a79b0a3187732d13dfad5b134bbf3173 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 00:15:35 -0800 Subject: [PATCH 1/3] AutoStory: launch a game to its save, through the Switch prompts --- .../AutoStory/Engine/Pokemon_StoryLaunch.cpp | 313 ++++++++++++++ .../AutoStory/Engine/Pokemon_StoryLaunch.h | 176 ++++++++ .../Engine/Pokemon_StoryLaunch_Tests.cpp | 381 ++++++++++++++++++ .../Engine/Pokemon_StoryLaunch_Tests.h | 23 ++ .../AutoStory/Pokemon_AutoStory_Tests.h | 2 + .../AutoStory/Pokemon_StorySwitchPrompts.cpp | 53 +++ .../AutoStory/Pokemon_StorySwitchPrompts.h | 33 ++ SerialPrograms/cmake/SourceFiles.cmake | 6 + 8 files changed, 987 insertions(+) create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp create mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp new file mode 100644 index 0000000000..e72453540a --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp @@ -0,0 +1,313 @@ +/* Story Launch + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include "NintendoSwitch/Inference/NintendoSwitch_HomeTileReader.h" +#include "Pokemon_StoryLaunch.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + +using namespace NintendoSwitch; + + +namespace{ + + +// What a look shows, as far as a launch cares. +enum class LaunchScreen{ + HOME, + NEW_GAME, + PROMPT, + TITLE, + OVERWORLD, + OTHER, +}; + +struct LaunchLook{ + LaunchScreen screen = LaunchScreen::OTHER; + // The prompt on screen, for PROMPT. + const StoryLaunchPrompt* prompt = nullptr; +}; + +// Which of the policy's loose checks a look may pass. +struct LaunchReadable{ + // The launch launched or closed the game: the checks read only after. + bool launched = false; + // No title press's fade holds the title check off, and a title read + // only after the launch (title_after_launch) waits for the A on the + // game's tile: right after the close, before HOME, a screen passes + // PLZA's loose title check (console B, 2026-11-14). + bool title = true; +}; + +// `look` as `policy` reads it. HOME first: a game's detectors may read +// HOME's plain screen as a quiet overworld. +LaunchLook read_launch_look(const StoryLaunchPolicy& policy, const ScreenObservation& look, LaunchReadable readable){ + const bool launched = readable.launched; + if (look.events.has(ScreenEvent::SWITCH_HOME_MENU)){ + return {.screen = LaunchScreen::HOME}; + } + if (policy.new_game && policy.new_game(look)){ + return {.screen = LaunchScreen::NEW_GAME}; + } + for (const StoryLaunchPrompt& prompt : policy.prompts){ + if ((launched || !prompt.after_launch) && prompt.matches && prompt.matches(look)){ + return {.screen = LaunchScreen::PROMPT, .prompt = &prompt}; + } + } + if (readable.title && (launched || !policy.title_after_launch) && policy.title(look)){ + return {.screen = LaunchScreen::TITLE}; + } + const bool overworld = policy.overworld ? policy.overworld(look) : look.events.has(ScreenEvent::PLAYER_CAN_MOVE); + return {.screen = overworld ? LaunchScreen::OVERWORLD : LaunchScreen::OTHER}; +} + +Outcome launch_failed(std::string detail){ + return outcome_failed(std::string(STORY_LAUNCH_FAILED), std::move(detail)); +} + +// Why `policy` cannot launch `request`, before any press; nothing when it +// can. +std::optional launch_problem(const StoryLaunchPolicy& policy, StoryLaunchRequest request){ + if (!policy.tile_selected || !policy.title){ + return launch_failed(std::format("{}: the launch policy has no tile or title check", policy.game)); + } + if (request.save == StoryLaunchRequest::Save::BACKUP && policy.backup_save.empty()){ + return launch_failed(std::format("{}: the game has no backup save", policy.game)); + } + return std::nullopt; +} + + +// One launch: a look, one thing done about it, until the overworld has +// settled or a screen took too many presses. +template +class LaunchDriver{ +public: + LaunchDriver(StoryBackend& backend, const StoryLaunchPolicy& policy, StoryLaunchRequest request) + : m_backend(backend) + , m_policy(policy) + , m_request(request) + {} + + // One look and its answer; the launch's end when this look ended it. + std::optional step(){ + const Observation observation = m_backend.observe(); + const LaunchLook look = read_launch_look(m_policy, observation, {.launched = m_launched || m_loading, .title = m_title_held_looks == 0 && (m_launched || !m_policy.title_after_launch)}); + count_title_hold(observation); + if (look.screen != LaunchScreen::OVERWORLD){ + m_settled = 0; + } + switch (look.screen){ + case LaunchScreen::HOME: + return on_home(observation); + case LaunchScreen::NEW_GAME: + return launch_failed(std::format("{}: the game shows a new game: no save to load, and a launch never starts one", m_policy.game)); + case LaunchScreen::PROMPT: + return on_prompt(*look.prompt); + case LaunchScreen::TITLE: + return on_title(observation); + case LaunchScreen::OVERWORLD: + return on_overworld(); + case LaunchScreen::OTHER: + break; + } + return on_other(); + } + +private: + // Whether an overworld up now is not yet the save asked for. + bool needs_load() const{ + return !m_loading && (m_request.running == StoryLaunchRequest::Running::RESTART || m_request.save == StoryLaunchRequest::Save::BACKUP); + } + + // The cursor to the game's tile, then the game closed if it must + // load again, then A on the tile. + std::optional on_home(const ScreenObservation& observation){ + if (m_launch_pressed && m_home_waited < m_policy.launch_wait){ + if (m_home_waited == Milliseconds(0)){ + log("home", "waiting for the game to start"); + } + m_home_waited += m_policy.poll; + m_backend.wait(m_policy.poll); + return std::nullopt; + } + if (!m_policy.tile_selected(observation)){ + return move_to_tile(); + } + if (needs_load()){ + m_loading = true; + return press("home", {.button = BUTTON_X}, m_policy.presses_per_screen, "close the game"); + } + m_launched = true; + m_launch_pressed = true; + m_home_waited = Milliseconds(0); + return press("home", {.button = BUTTON_A}, m_policy.presses_per_screen, "launch the game"); + } + + std::optional move_to_tile(){ + const size_t left = m_policy.tile_search; + if (m_tile_moves >= 3 * left){ + return launch_failed(std::format("{}: the game's tile is not on HOME: {} tiles searched", m_policy.game, m_tile_moves)); + } + const Button button = m_tile_moves < left ? BUTTON_LEFT : BUTTON_RIGHT; + m_tile_moves++; + log("home", std::format("not on the game's tile: {}", button_to_string(button))); + m_backend.press(button, Milliseconds(80), Milliseconds(400)); + return std::nullopt; + } + + // The prompt's lead-in presses, then its press. + std::optional on_prompt(const StoryLaunchPrompt& prompt){ + if (m_presses[prompt.name] < prompt.max_presses){ + for (const StoryLaunchPress& each : prompt.before){ + m_backend.press(each.button, each.hold, each.release); + } + } + return press(prompt.name, prompt.press, prompt.max_presses); + } + + std::optional on_title(const ScreenObservation& observation){ + m_loading = true; + m_launched = true; + const bool backup = m_request.save == StoryLaunchRequest::Save::BACKUP && !m_backup_sent; + if (backup && m_policy.backup_title && !m_policy.backup_title(observation)){ + m_backend.wait(m_policy.poll); + return std::nullopt; + } + if (backup){ + m_backup_sent = true; + log("title", "the backup save"); + for (const StoryLaunchPress& each : m_policy.backup_save){ + m_backend.press(each.button, each.hold, each.release); + } + } + m_title_pressed = true; + return press("title", m_policy.title_press, m_policy.presses_per_screen); + } + + // A black fade after a title press starts the title's hold; each + // other look shortens it. + void count_title_hold(const ScreenObservation& observation){ + if (m_title_pressed && observation.events.has(ScreenEvent::FADE_BLACK)){ + m_title_pressed = false; + m_title_held_looks = m_policy.title_load_looks; + }else if (m_title_held_looks > 0){ + m_title_held_looks--; + } + } + + std::optional on_overworld(){ + if (needs_load()){ + return press("overworld", {.button = BUTTON_HOME}, m_policy.presses_per_screen, "HOME, to load the save"); + } + if (++m_settled >= m_policy.settled_looks){ + log("overworld", std::format("settled for {} looks", m_settled)); + return outcome_ok(); + } + m_backend.wait(m_policy.poll); + return std::nullopt; + } + + // A screen the policy doesn't know: the game's boot or a load once + // launched; before that the game was in front already, left with HOME + // to load the save, or B toward its overworld. + std::optional on_other(){ + if (m_launched || m_loading){ + m_backend.wait(m_policy.poll); + return std::nullopt; + } + if (needs_load()){ + return press("unknown screen", {.button = BUTTON_HOME}, m_policy.presses_per_screen, "HOME, to load the save"); + } + return press("unknown screen", {.button = BUTTON_B}, m_policy.presses_per_screen, "B, toward the overworld"); + } + + // `what` on `screen`, unless `screen` already took `max` presses. + std::optional press(std::string_view screen, const StoryLaunchPress& what, size_t max, std::string_view why = {}){ + size_t& count = m_presses[std::string(screen)]; + if (count >= max){ + return launch_failed(std::format("{}: stuck on {}: {} presses changed nothing", m_policy.game, screen, count)); + } + count++; + log(screen, why.empty() ? button_to_string(what.button) : std::string(why)); + m_backend.press(what.button, what.hold, what.release); + return std::nullopt; + } + + void log(std::string_view screen, std::string_view what){ + m_backend.log(std::format("[Launch] {}: {}: {}", m_policy.game, screen, what)); + } + + StoryBackend& m_backend; + const StoryLaunchPolicy& m_policy; + StoryLaunchRequest m_request; + std::map> m_presses; + size_t m_tile_moves = 0; + size_t m_settled = 0; + // The game was closed from HOME, or showed its title: what comes up + // next is a save loading. + bool m_loading = false; + // A on the game's tile, or the title: until the overworld, a screen + // the policy doesn't know is the game booting or loading. + bool m_launched = false; + // A was pressed on the game's tile, and HOME has shown for + // `m_home_waited` since. + bool m_launch_pressed = false; + Milliseconds m_home_waited = Milliseconds(0); + bool m_backup_sent = false; + // A title press with no black fade since. + bool m_title_pressed = false; + // Looks left on which the title is not read (title_load_looks). + size_t m_title_held_looks = 0; +}; + + +} // namespace + + +std::function switch_home_tile_named(Language language, std::string name){ + return [language, name = std::move(name)](const ScreenObservation& look){ + return look.frame && look.frame->frame && selected_home_tile_is(language, *look.frame->frame, name); + }; +} + + +template +Outcome launch_story_game(StoryBackend& backend, const StoryLaunchPolicy& policy, StoryLaunchRequest request){ + if (std::optional problem = launch_problem(policy, request)){ + backend.log(std::format("[Launch] {}", problem->detail)); + return std::move(*problem); + } + LaunchDriver driver(backend, policy, request); + for (size_t looks = 0; looks < policy.max_looks; looks++){ + backend.scope().throw_if_cancelled(); + if (std::optional end = driver.step()){ + if (!end->succeeded()){ + backend.log(std::format("[Launch] {}", end->detail)); + } + return std::move(*end); + } + } + const Outcome failed = launch_failed(std::format("{}: no overworld after {} looks", policy.game, policy.max_looks)); + backend.log(std::format("[Launch] {}", failed.detail)); + return failed; +} + +template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); +template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); + + + +} // namespace Pokemon +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h new file mode 100644 index 0000000000..df04f47a6f --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h @@ -0,0 +1,176 @@ +/* Story Launch + * + * From: https://github.com/PokemonAutomation/ + * + * A run's first event: from wherever the console is (the Switch's HOME + * menu with the game closed or suspended, the game's title, the + * overworld) to the overworld on a save. One driver for every game; the + * game's StoryLaunchPolicy says how its screens look and which press + * answers each. It runs before the first checkpoint, on its own, never + * inside a new game's language or intro steps, and it never starts a new + * game. + * + * The driver looks, does one thing, and looks again. It does not need to + * know every screen: one it doesn't know is waited out (a boot, a fade) + * or, before the game was launched, left with HOME or B. Each screen's + * presses are counted, so a screen that ignores its press fails the + * launch instead of looping, and the launch ends only once the overworld + * shows for several looks in a row. + * + */ + +#ifndef PokemonAutomation_Pokemon_StoryLaunch_H +#define PokemonAutomation_Pokemon_StoryLaunch_H + +#include +#include +#include +#include +#include +#include "Common/Cpp/Time.h" +#include "CommonFramework/Language.h" +#include "CommonTools/ScreenMachine/ScreenObservation.h" +#include "NintendoSwitch/Controllers/NintendoSwitch_ControllerButtons.h" +#include "Pokemon/AutoStory/Pokemon_StoryOutcome.h" +#include "Pokemon/AutoStory/Types/Pokemon_GridPose.h" +#include "Pokemon_StoryBackend.h" +#include "Pokemon_ZonePose.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// What a launch loads. +struct StoryLaunchRequest{ + enum class Save{ + LATEST, // the title's plain load + BACKUP, // the policy's backup_save presses on the title first + // (PLZA: Up, then B + X, the save before the latest) + }; + enum class Running{ + // A game already on the overworld is the start: it is resumed + // from HOME, not reloaded. + KEEP, + // A game already running is closed from HOME, then launched, so + // the save loads; a title on screen already counts as launched. + RESTART, + }; + Save save = Save::LATEST; + Running running = Running::RESTART; +}; + +// One press: `button` (several pressed together when or-ed), held for +// `hold`, then let go for `release`. +struct StoryLaunchPress{ + NintendoSwitch::Button button = NintendoSwitch::BUTTON_A; + Milliseconds hold = Milliseconds(80); + Milliseconds release = Milliseconds(400); +}; + +// A screen on the way that one press answers: the user select, an online +// license check, HOME's close-software dialog, the load menu's Continue, +// a recap of the story so far. +struct StoryLaunchPrompt{ + std::string name = {}; + std::function matches = {}; + StoryLaunchPress press = {}; + // Pressed in order before `press`, each time: the cursor moves to the + // choice `press` picks (the update prompt's last choice). + std::vector before = {}; + // Read only once this launch launched or closed the game: a screen + // the game also shows in play (a dialog box, a choice), where a press + // before the launch would answer the story instead. + bool after_launch = false; + // Presses it may take before the launch is stuck on it. + size_t max_presses = 6; +}; + +// How one game's screens look on the way from HOME to its overworld. +struct StoryLaunchPolicy{ + // "frlg", "bdsp", "plza", for the log. + std::string game = {}; + // On HOME: whether the cursor is on this game's tile. The launch + // presses A on HOME only then, as A launches whatever tile is + // selected. Required; on a Switch, switch_home_tile_named() with the + // name HOME shows for the game. + std::function tile_selected = {}; + // How far the tile search moves each way: Left `tile_search` times + // (the most recently played games are leftmost), then Right twice as + // many. + size_t tile_search = 6; + // The title screen, which leads to the save. Required. + std::function title = {}; + StoryLaunchPress title_press = {}; + // `title` is read only once this launch launched or closed the game: + // a loose check (any quiet screen after the boot) that a game in play + // would pass too. + bool title_after_launch = false; + // Pressed once on the title before `title_press` for Save::BACKUP. + // Empty: the game has no backup save, and a BACKUP launch fails + // before it presses anything. + std::vector backup_save = {}; + // Where `backup_save` goes: the title proper. A loose `title` passes + // the boot's logos too, where those presses do nothing and the title's + // next press loads the latest save (console B, 2026-11-14). Until it + // shows, a BACKUP launch waits on title looks without a press. Empty: + // the first title look takes them. + std::function backup_title = {}; + // A screen that would start a new game: there is no save. The launch + // fails there without a press. Optional. + std::function new_game = {}; + // The game's other screens on the way, each answered by its press. + std::vector prompts = {}; + // The player in control. Unset: the look shows PLAYER_CAN_MOVE. + std::function overworld = {}; + // Looks after a title press's black fade (FADE_BLACK) on which + // `title` is not read: the screens there are the save loading or the + // boot, waited out. A loose title check passes a load's tips screen, + // and an A on a boot logo is followed by the boot's own fade, so the + // title is read again once these looks are over. 0: always read. + size_t title_load_looks = 0; + // Looks in a row the overworld must show before the launch is done. + size_t settled_looks = 3; + // The wait between looks at a screen with nothing to press. + Milliseconds poll = Milliseconds(500); + // After A on the game's tile, how long HOME may still show (its zoom + // into the game, a check or the user select in front of it) before + // the launch takes A again: until then each look at HOME waits, as + // another A there would launch the game again. + Milliseconds launch_wait = Milliseconds(30000); + // Presses HOME, the title, an overworld to leave or a screen the + // policy doesn't know may take before the launch is stuck there. + size_t presses_per_screen = 6; + // Looks before the launch gives up: about `poll` times this of + // loading at most. + size_t max_looks = 360; +}; + +// A `tile_selected` for a Switch game: HOME's cursor is on the tile whose +// name, above the game row, contains `name` ("Pokémon Legends: Z-A"), +// read in `language`, the console's (NintendoSwitch_HomeTileReader.h). +// False on a look without a frame, as in a simulation. +std::function switch_home_tile_named(Language language, std::string name); + +// The failure of a launch that did not reach the overworld; its detail +// says where it stopped. Nothing in the story answers it: no reload, no +// recovery. +inline constexpr std::string_view STORY_LAUNCH_FAILED = "launch_failed"; + +// Drives `backend` to the overworld on the save `request` asks for, by +// `policy`; logs each press as "[Launch] : : ". +// Succeeds once the overworld shows `policy.settled_looks` looks in a +// row; fails as STORY_LAUNCH_FAILED on a new game, a missing tile, a +// screen that took too many presses, or after `policy.max_looks` looks. +template +Outcome launch_story_game(StoryBackend& backend, const StoryLaunchPolicy& policy, StoryLaunchRequest request); + +// Instantiated once, in Pokemon_StoryLaunch.cpp. +extern template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); +// And for ZonePose (Pokemon_ZonePose.h). +extern template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); + + + +} // namespace Pokemon +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp new file mode 100644 index 0000000000..92e1428b38 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp @@ -0,0 +1,381 @@ +/* Story Launch Tests + * + * From: https://github.com/PokemonAutomation/ + * + * The launch on a scripted console: each case is the screens the console + * shows, look by look (the last repeats), and the presses the launch must + * make, or where it must fail. The test game's screens are readings its + * policy reads; HOME is the shared SWITCH_HOME_MENU event and the + * overworld the shared PLAYER_CAN_MOVE. + * + */ + +#include +#include +#include +#include +#include +#include +#include "Common/Cpp/TestRunners/UnitTest.h" +#include "Pokemon_StoryFakeBackend.h" +#include "Pokemon_StoryLaunch.h" +#include "Pokemon_StoryLaunch_Tests.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + +using namespace NintendoSwitch; + + +namespace{ + + +// What the scripted console shows. +enum class Screen{ + HOME_ON_GAME, // HOME, the cursor on the game's tile + HOME_OFF_GAME, // HOME, the cursor on another tile + CLOSE_DIALOG, // HOME's "Close software?" + LICENSE_CHECK, // the online license check + BLACK, // a boot or a load + FADE, // a black fade (FADE_BLACK), as a boot or a load starts + TITLE, + NEW_GAME, // the title's menu without a save + BACKUP_CONFIRM, // "Load the backup save?" + LOAD_MENU, // Continue / New Game + UPDATE, // the update prompt: Up twice to its last choice, then A + GAME_DIALOG, // the game's dialog box, in play or on the way + LOGO, // a boot logo, which a loose title check passes + OVERWORLD, +}; + +inline constexpr std::string_view SCREEN = "screen"; +inline constexpr std::string_view TILE = "home.tile"; + +Observation look(Screen screen){ + Observation observation; + switch (screen){ + case Screen::HOME_ON_GAME: + case Screen::HOME_OFF_GAME: + observation.events = ScreenEvents{ScreenEvent::SWITCH_HOME_MENU}; + observation.readings[std::string(TILE)] = screen == Screen::HOME_ON_GAME ? 1 : 0; + return observation; + case Screen::OVERWORLD: + observation.events = ScreenEvents{ScreenEvent::PLAYER_CAN_MOVE}; + return observation; + case Screen::FADE: + observation.events = ScreenEvents{ScreenEvent::FADE_BLACK}; + return observation; + default: + observation.readings[std::string(SCREEN)] = (int)screen; + return observation; + } +} + +std::function shows(Screen screen){ + return [screen](const ScreenObservation& observation){ + const auto it = observation.readings.find(SCREEN); + return it != observation.readings.end() && it->second == (int)screen; + }; +} + +// Whether the test game has a backup save. +enum class Backup{ + PLZA, // Up, then B + X + NONE, +}; + +// How the test game finds its tile on HOME. +enum class TileCheck{ + READINGS, // the scripted "home.tile" reading + SWITCH_NAME, // switch_home_tile_named(), which reads the look's frame +}; + +// How loose the test game's title and dialog checks are. +enum class GameScreens{ + STRICT, // read whenever they show + AFTER_LAUNCH, // read only once the launch launched the game +}; + +// Which screens the test game's title check passes. +enum class TitleCheck{ + TITLE, // the title only + LOOSE, // the title and the boot's logos; the backup save only on the title +}; + +// The test game's bounds that a case may change. +struct Bounds{ + size_t title_load_looks = 0; + size_t max_looks = 12; +}; + +// The test game: A on the title, `backup` for the backup save, A on each +// prompt (Up, Up, A on the update prompt; B on the game's dialog), and +// small bounds so a failure takes few looks. +StoryLaunchPolicy test_policy(Backup backup, GameScreens game_screens, TileCheck tile_check, TitleCheck title_check, Bounds bounds){ + StoryLaunchPolicy policy; + policy.game = "test"; + policy.tile_selected = [](const ScreenObservation& observation){ + const auto it = observation.readings.find(TILE); + return it != observation.readings.end() && it->second == 1; + }; + if (tile_check == TileCheck::SWITCH_NAME){ + policy.tile_selected = switch_home_tile_named(Language::English, "Pokémon Legends: Z-A"); + } + policy.tile_search = 2; + policy.title = shows(Screen::TITLE); + if (title_check == TitleCheck::LOOSE){ + policy.title = [](const ScreenObservation& observation){ + return shows(Screen::TITLE)(observation) || shows(Screen::LOGO)(observation); + }; + policy.backup_title = shows(Screen::TITLE); + } + if (backup == Backup::PLZA){ + policy.backup_save = {{.button = BUTTON_UP}, {.button = BUTTON_B | BUTTON_X, .hold = Milliseconds(1000)}}; + } + policy.new_game = shows(Screen::NEW_GAME); + policy.prompts = { + {.name = "close software", .matches = shows(Screen::CLOSE_DIALOG)}, + {.name = "license check", .matches = shows(Screen::LICENSE_CHECK)}, + {.name = "backup confirm", .matches = shows(Screen::BACKUP_CONFIRM)}, + {.name = "load menu", .matches = shows(Screen::LOAD_MENU)}, + {.name = "update", .matches = shows(Screen::UPDATE), .before = {{.button = BUTTON_UP}, {.button = BUTTON_UP}}}, + {.name = "game dialog", .matches = shows(Screen::GAME_DIALOG), .press = {.button = BUTTON_B}, + .after_launch = game_screens == GameScreens::AFTER_LAUNCH}, + }; + policy.title_after_launch = game_screens == GameScreens::AFTER_LAUNCH; + policy.presses_per_screen = 3; + policy.title_load_looks = bounds.title_load_looks; + policy.launch_wait = Milliseconds(2000); + policy.max_looks = bounds.max_looks; + return policy; +} + +// `screens`, then the overworld for as many looks as it takes to settle. +std::vector then_settled(std::vector screens){ + screens.insert(screens.end(), {Screen::OVERWORLD, Screen::OVERWORLD, Screen::OVERWORLD}); + return screens; +} + +using Save = StoryLaunchRequest::Save; +using Running = StoryLaunchRequest::Running; + +// One launch. +struct LaunchCase{ + struct Input{ + std::vector screens; + StoryLaunchRequest request = {}; + Backup backup = Backup::PLZA; + GameScreens game_screens = GameScreens::STRICT; + TileCheck tile_check = TileCheck::READINGS; + TitleCheck title_check = TitleCheck::TITLE; + Bounds bounds = {}; + }; + struct Expectation{ + // Empty: the launch succeeds; else a part of its failure's detail. + std::string_view failure = {}; + // The inputs in order, by space: a button ("A", "HOME", "B+X") + // or "wait". + std::string_view inputs = {}; + }; + std::string_view name; + Input input; + Expectation expectation; +}; + +const std::vector LAUNCH_CASES = { + {.name = "game closed on HOME", + .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE, Screen::BLACK})}, + .expectation = {.inputs = "X A wait A wait wait wait"}}, + {.name = "game open on its title", + .input = {.screens = then_settled({Screen::TITLE, Screen::BLACK})}, + .expectation = {.inputs = "A wait wait wait"}}, + {.name = "game on the overworld kept", + .input = {.screens = then_settled({}), .request = {.running = Running::KEEP}}, + .expectation = {.inputs = "wait wait"}}, + // RELOAD_AT_START off (Pokemon_StoryRunOptions.h) on PLZA's loose + // title check: a game already on the overworld, as console B's at + // the Pokemon Center counter on 2026-11-14, is started from with no press. + {.name = "game on the overworld kept with a loose title check", + .input = {.screens = then_settled({}), .request = {.running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH}, + .expectation = {.inputs = "wait wait"}}, + {.name = "kept game resumed from HOME with a loose title check", + .input = {.screens = then_settled({Screen::HOME_ON_GAME}), .request = {.running = Running::KEEP}, + .game_screens = GameScreens::AFTER_LAUNCH}, + .expectation = {.inputs = "A wait wait"}}, + {.name = "game on the overworld restarted", + .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::HOME_ON_GAME, + Screen::BLACK, Screen::TITLE})}, + .expectation = {.inputs = "HOME X A A wait A wait wait"}}, + {.name = "backup save from the overworld", + .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::TITLE, + Screen::BACKUP_CONFIRM, Screen::BLACK}), + .request = {.save = Save::BACKUP, .running = Running::KEEP}}, + .expectation = {.inputs = "HOME X A Up B+X A A wait wait wait"}}, + // Console B, 2026-11-14: after the close, a screen before HOME passed + // PLZA's loose title check; the backup's buttons went there and the + // real title took only A, so the latest save loaded. + {.name = "backup save waits for the title after the game's launch", + .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::TITLE, + Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE, Screen::BACKUP_CONFIRM, Screen::BLACK}), + .request = {.save = Save::BACKUP, .running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH}, + .expectation = {.inputs = "HOME X A wait A wait Up B+X A A wait wait wait"}}, + // Console B, 2026-11-14: the backup's buttons went to a boot logo that + // passed the loose title check; the title took only A. + {.name = "backup save waits past the boot's logos for the title", + .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::HOME_ON_GAME, + Screen::LOGO, Screen::LOGO, Screen::TITLE, Screen::BACKUP_CONFIRM, Screen::BLACK}), + .request = {.save = Save::BACKUP, .running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH, + .title_check = TitleCheck::LOOSE}, + .expectation = {.inputs = "HOME X A A wait wait Up B+X A A wait wait wait"}}, + {.name = "backup save the game does not have", + .input = {.screens = then_settled({}), .request = {.save = Save::BACKUP}, .backup = Backup::NONE}, + .expectation = {.failure = "no backup save", .inputs = ""}}, + {.name = "license check back to HOME", + .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::LICENSE_CHECK, Screen::HOME_ON_GAME, + Screen::BLACK, Screen::TITLE, Screen::LOAD_MENU})}, + .expectation = {.inputs = "X A A wait wait A A wait wait"}}, + // Console B, 2026-11-14 02:41 (FRLG): HOME showed for about 1.5 s + // after the A on the tile, and each look there pressed A again. + {.name = "HOME after the launch press waits", + .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, + Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE})}, + .expectation = {.inputs = "X A wait wait wait wait A wait wait"}}, + {.name = "HOME past the launch wait takes A again", + .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, + Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::TITLE})}, + .expectation = {.inputs = "X A wait wait wait wait A A wait wait"}}, + {.name = "cursor on another tile", + .input = {.screens = then_settled({Screen::HOME_OFF_GAME, Screen::HOME_OFF_GAME, Screen::HOME_ON_GAME}), + .request = {.running = Running::KEEP}}, + .expectation = {.inputs = "Left Left A wait wait"}}, + {.name = "game not on HOME", + .input = {.screens = {Screen::HOME_OFF_GAME}}, + .expectation = {.failure = "tile is not on HOME", .inputs = "Left Left Right Right Right Right"}}, + {.name = "Switch tile check never launches without a frame", + .input = {.screens = {Screen::HOME_ON_GAME}, .tile_check = TileCheck::SWITCH_NAME}, + .expectation = {.failure = "tile is not on HOME", .inputs = "Left Left Right Right Right Right"}}, + {.name = "title ignores A", + .input = {.screens = {Screen::TITLE}}, + .expectation = {.failure = "stuck on title", .inputs = "A A A"}}, + {.name = "no save never starts a new game", + .input = {.screens = {Screen::NEW_GAME}}, + .expectation = {.failure = "new game", .inputs = ""}}, + {.name = "black screen after launch times out", + .input = {.screens = {Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::BLACK}}, + .expectation = {.failure = "no overworld after 12 looks", .inputs = "X A wait wait wait wait wait wait wait wait wait wait"}}, + {.name = "kept game off the overworld takes B", + .input = {.screens = then_settled({Screen::LOAD_MENU, Screen::BLACK}), .request = {.running = Running::KEEP}}, + .expectation = {.inputs = "A B wait wait"}}, + {.name = "update prompt takes its lead-in presses", + .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::UPDATE, Screen::BLACK, Screen::TITLE})}, + .expectation = {.inputs = "X A Up Up A wait A wait wait"}}, + {.name = "strict title in front is pressed", + .input = {.screens = then_settled({Screen::GAME_DIALOG, Screen::TITLE, Screen::BLACK})}, + .expectation = {.inputs = "B A wait wait wait"}}, + {.name = "loose title in front is left with HOME", + .input = {.screens = then_settled({Screen::GAME_DIALOG, Screen::TITLE, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, + Screen::BLACK, Screen::GAME_DIALOG, Screen::TITLE}), + .game_screens = GameScreens::AFTER_LAUNCH}, + .expectation = {.inputs = "HOME HOME X A wait B A wait wait"}}, + // Console B, PLZA, 2026-11-14 13:09: A twice on a boot logo the loose + // title check passes, the boot's black, the title (A works), the + // load's black, then its tips screen, which the title check passes + // too. Each fade after a title press holds the title check off for + // 6 looks: the boot's title waits 3 looks, the tips screen gets no A. + {.name = "title not read on the screens after its fade", + .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::FADE, + Screen::TITLE, Screen::TITLE, + Screen::FADE, Screen::FADE, Screen::FADE, Screen::FADE, + Screen::TITLE, Screen::TITLE, Screen::TITLE, Screen::TITLE, + Screen::FADE, Screen::FADE, + Screen::TITLE, Screen::TITLE, Screen::TITLE, Screen::TITLE}), + .game_screens = GameScreens::AFTER_LAUNCH, .bounds = {.title_load_looks = 6, .max_looks = 30}}, + .expectation = {.inputs = "X A wait A A wait wait wait wait wait wait wait A wait wait wait wait wait wait wait wait"}}, + {.name = "title read again once its fade's looks are over", + .input = {.screens = {Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::TITLE, Screen::FADE, Screen::TITLE}, + .game_screens = GameScreens::AFTER_LAUNCH, .bounds = {.title_load_looks = 2}}, + .expectation = {.failure = "stuck on title", .inputs = "X A A wait wait wait A A"}}, +}; + +// The fake backend's record of `input` ("A" -> "press A"). +std::string recorded(std::string_view input){ + if (input == "wait"){ + return "wait 500ms"; + } + static const std::map BUTTONS = { + {"A", BUTTON_A}, {"B", BUTTON_B}, {"X", BUTTON_X}, {"HOME", BUTTON_HOME}, + {"Up", BUTTON_UP}, {"Left", BUTTON_LEFT}, {"Right", BUTTON_RIGHT}, {"B+X", BUTTON_B | BUTTON_X}, + }; + const auto it = BUTTONS.find(input); + return it == BUTTONS.end() ? std::format("unknown input {}", input) : std::format("press {}", button_to_string(it->second)); +} + +// `inputs` (by space) as the fake backend records them. +std::vector expected_inputs(std::string_view inputs){ + std::vector expected; + while (!inputs.empty()){ + const size_t space = inputs.find(' '); + expected.push_back(recorded(inputs.substr(0, space))); + inputs = space == std::string_view::npos ? std::string_view() : inputs.substr(space + 1); + } + return expected; +} + +std::string describe_inputs(const std::vector& inputs){ + std::string text; + for (const std::string& input : inputs){ + text += text.empty() ? input : std::format(", {}", input); + } + return std::format("[{}]", text); +} + +std::string check_launch(const LaunchCase& test, CancellableScope& scope){ + std::vector> looks; + for (Screen screen : test.input.screens){ + looks.push_back(look(screen)); + } + FakeStoryBackend backend({.looks = std::move(looks)}, scope); + const Outcome outcome = launch_story_game(backend, test_policy(test.input.backup, test.input.game_screens, test.input.tile_check, test.input.title_check, test.input.bounds), test.input.request); + if (test.expectation.failure.empty() && !outcome.succeeded()){ + return std::format("expected success, got {}", to_string(outcome)); + } + if (!test.expectation.failure.empty()){ + if (outcome.failure != STORY_LAUNCH_FAILED || outcome.detail.find(test.expectation.failure) == std::string::npos){ + return std::format("expected a launch failure with \"{}\", got {}", test.expectation.failure, to_string(outcome)); + } + } + const std::vector expected = expected_inputs(test.expectation.inputs); + if (backend.inputs() != expected){ + return std::format("expected inputs {}, got {}", describe_inputs(expected), describe_inputs(backend.inputs())); + } + return ""; +} + +class StoryLaunchTest : public UnitTest{ +public: + explicit StoryLaunchTest(LaunchCase test) + : UnitTest(std::format("Pokemon::StoryLaunch - {}", test.name)) + , m_case(std::move(test)) + {} + virtual UnitTestResult run(Logger&, CancellableScope& scope) const override{ + const std::string error = check_launch(m_case, scope); + return error.empty() ? UnitTestResult(true) : UnitTestResult(error); + } +private: + LaunchCase m_case; +}; + + +} // namespace + + +void add_tests_StoryLaunch(UnitTestDatabase& database){ + for (const LaunchCase& test : LAUNCH_CASES){ + database.add(test); + } +} + + + +} // namespace Pokemon +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h new file mode 100644 index 0000000000..efba4cc847 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h @@ -0,0 +1,23 @@ +/* Story Launch Tests + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_Pokemon_StoryLaunch_Tests_H +#define PokemonAutomation_Pokemon_StoryLaunch_Tests_H + +#include "Common/Cpp/TestRunners/UnitTestDatabase.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// Registers unit tests for the launch from HOME to the overworld on a scripted console. +void add_tests_StoryLaunch(UnitTestDatabase& database); + + + +} // namespace Pokemon +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h index 522e1cb049..692399895f 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_AutoStory_Tests.h @@ -21,6 +21,7 @@ #include "Engine/Pokemon_StoryEnginePolicy_Tests.h" #include "Engine/Pokemon_StoryEngineRuns_Tests.h" #include "Engine/Pokemon_StoryEngineSaveRetry_Tests.h" +#include "Engine/Pokemon_StoryLaunch_Tests.h" #include "Pokemon/Options/Pokemon_StoryRangeOptions_Tests.h" #include "Pokemon/Options/Pokemon_StoryRunOptions_Tests.h" #include "Pokemon_SceneJudges_Tests.h" @@ -57,6 +58,7 @@ inline void add_tests_AutoStory(UnitTestDatabase& database){ add_tests_StoryFiles(database); add_tests_StoryRangeOptions(database); add_tests_StoryRunOptions(database); + add_tests_StoryLaunch(database); } diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp new file mode 100644 index 0000000000..3dcb5a4d94 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp @@ -0,0 +1,53 @@ +/* AutoStory Switch Launch Prompts + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include +#include "NintendoSwitch/NintendoSwitch_Settings.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "NintendoSwitch/Inference/NintendoSwitch_CloseGameDetector.h" +#include "NintendoSwitch/Inference/NintendoSwitch_StartGameUserSelectDetector.h" +#include "NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h" +#include "Pokemon_StorySwitchPrompts.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + +using namespace std::chrono_literals; +using namespace NintendoSwitch; + + +namespace{ + +// Whether `detector` fires on the look's frame; false without one. +template +std::function frame_shows(std::shared_ptr detector){ + return [detector = std::move(detector)](const ScreenObservation& look){ + return look.frame && look.frame->frame && detector->detect(*look.frame->frame); + }; +} + +} // namespace + + +std::vector switch_launch_prompts(ConsoleHandle& console){ + const StoryLaunchPress scroll_up{.button = BUTTON_UP, .hold = 40ms, .release = 40ms}; + return { + {.name = "close software", .matches = frame_shows(std::make_shared(console)), + .press = {.button = BUTTON_A, .hold = 160ms, .release = ConsoleSettings::instance().CLOSE_GAME_DELAY}}, + {.name = "user select", .matches = frame_shows(std::make_shared(console)), + .press = {.button = BUTTON_A, .hold = 160ms}}, + {.name = "update prompt", .matches = frame_shows(std::make_shared(console)), + .press = {.button = BUTTON_A, .hold = 160ms}, .before = {scroll_up, scroll_up}}, + }; +} + + + +} // namespace Pokemon +} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h new file mode 100644 index 0000000000..5bfa8dba26 --- /dev/null +++ b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h @@ -0,0 +1,33 @@ +/* AutoStory Switch Launch Prompts + * + * From: https://github.com/PokemonAutomation/ + * + * The Switch's own screens between HOME and a game, each answered by one + * press: HOME's "Close software?", the user select and the update prompt. + * They are the same in every game, so each game's StoryLaunchPolicy + * (Engine/Pokemon_StoryLaunch.h) starts its prompts with these. + * + */ + +#ifndef PokemonAutomation_Pokemon_StorySwitchPrompts_H +#define PokemonAutomation_Pokemon_StorySwitchPrompts_H + +#include +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h" + +namespace PokemonAutomation{ +namespace Pokemon{ + + +// On `console`'s frames: "Close software?" takes A, then the console's +// close delay (Switch settings); the user select takes A on the user +// highlighted; the update prompt takes Up twice, to "Start Software", then +// A. A look without a frame (a simulation) shows none of them. +std::vector switch_launch_prompts(NintendoSwitch::ConsoleHandle& console); + + + +} // namespace Pokemon +} // namespace PokemonAutomation +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 8887df0042..52e3972117 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1507,6 +1507,10 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/AutoStory/Engine/Pokemon_StoryFakeBackend.cpp Source/Pokemon/AutoStory/Engine/Pokemon_StoryFakeBackend.h Source/Pokemon/AutoStory/Engine/Pokemon_StoryGame.h + Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp + Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h + Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp + Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h Source/Pokemon/AutoStory/Engine/Pokemon_StoryPoseConcept.cpp Source/Pokemon/AutoStory/Engine/Pokemon_StoryPoseConcept.h Source/Pokemon/AutoStory/Engine/Pokemon_StoryStepRunner.cpp @@ -1553,6 +1557,8 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor.h Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.h + Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp + Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h Source/Pokemon/AutoStory/Pokemon_TestExpect.h Source/Pokemon/AutoStory/Pokemon_TilePose.cpp Source/Pokemon/AutoStory/Pokemon_TilePose.h From 8c54ec8be2b164664fdc2dbf36b092463989d504 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 01:05:41 -0800 Subject: [PATCH 2/3] AutoStory launch: comments describe the screens, not our console runs The launch driver and its tests keep each screen behavior they guard and drop the console, game and timestamps of the runs that showed it. --- .../AutoStory/Engine/Pokemon_StoryLaunch.cpp | 2 +- .../AutoStory/Engine/Pokemon_StoryLaunch.h | 2 +- .../Engine/Pokemon_StoryLaunch_Tests.cpp | 20 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp index e72453540a..7c6cc9c81e 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp @@ -46,7 +46,7 @@ struct LaunchReadable{ // No title press's fade holds the title check off, and a title read // only after the launch (title_after_launch) waits for the A on the // game's tile: right after the close, before HOME, a screen passes - // PLZA's loose title check (console B, 2026-11-14). + // a loose title check. bool title = true; }; diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h index df04f47a6f..3d7a7c8efb 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h @@ -111,7 +111,7 @@ struct StoryLaunchPolicy{ std::vector backup_save = {}; // Where `backup_save` goes: the title proper. A loose `title` passes // the boot's logos too, where those presses do nothing and the title's - // next press loads the latest save (console B, 2026-11-14). Until it + // next press loads the latest save. Until it // shows, a BACKUP launch waits on title looks without a press. Empty: // the first title look takes them. std::function backup_title = {}; diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp index 92e1428b38..32f2bf7a10 100644 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp +++ b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp @@ -193,8 +193,8 @@ const std::vector LAUNCH_CASES = { .input = {.screens = then_settled({}), .request = {.running = Running::KEEP}}, .expectation = {.inputs = "wait wait"}}, // RELOAD_AT_START off (Pokemon_StoryRunOptions.h) on PLZA's loose - // title check: a game already on the overworld, as console B's at - // the Pokemon Center counter on 2026-11-14, is started from with no press. + // title check: a game already on the overworld (at a Pokemon Center + // counter, say) is started from with no press. {.name = "game on the overworld kept with a loose title check", .input = {.screens = then_settled({}), .request = {.running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH}, .expectation = {.inputs = "wait wait"}}, @@ -211,16 +211,16 @@ const std::vector LAUNCH_CASES = { Screen::BACKUP_CONFIRM, Screen::BLACK}), .request = {.save = Save::BACKUP, .running = Running::KEEP}}, .expectation = {.inputs = "HOME X A Up B+X A A wait wait wait"}}, - // Console B, 2026-11-14: after the close, a screen before HOME passed - // PLZA's loose title check; the backup's buttons went there and the - // real title took only A, so the latest save loaded. + // After the close, a screen before HOME passes a loose title check; + // the backup's buttons must not go there, or the real title takes only + // A and the latest save loads. {.name = "backup save waits for the title after the game's launch", .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::TITLE, Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE, Screen::BACKUP_CONFIRM, Screen::BLACK}), .request = {.save = Save::BACKUP, .running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH}, .expectation = {.inputs = "HOME X A wait A wait Up B+X A A wait wait wait"}}, - // Console B, 2026-11-14: the backup's buttons went to a boot logo that - // passed the loose title check; the title took only A. + // The backup's buttons must not go to a boot logo that passes a loose + // title check, or the title takes only A. {.name = "backup save waits past the boot's logos for the title", .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::HOME_ON_GAME, Screen::LOGO, Screen::LOGO, Screen::TITLE, Screen::BACKUP_CONFIRM, Screen::BLACK}), @@ -234,8 +234,8 @@ const std::vector LAUNCH_CASES = { .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::LICENSE_CHECK, Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE, Screen::LOAD_MENU})}, .expectation = {.inputs = "X A A wait wait A A wait wait"}}, - // Console B, 2026-11-14 02:41 (FRLG): HOME showed for about 1.5 s - // after the A on the tile, and each look there pressed A again. + // HOME can show for about 1.5 s after the A on the tile; a look there + // must not press A again. {.name = "HOME after the launch press waits", .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE})}, @@ -277,7 +277,7 @@ const std::vector LAUNCH_CASES = { Screen::BLACK, Screen::GAME_DIALOG, Screen::TITLE}), .game_screens = GameScreens::AFTER_LAUNCH}, .expectation = {.inputs = "HOME HOME X A wait B A wait wait"}}, - // Console B, PLZA, 2026-11-14 13:09: A twice on a boot logo the loose + // A twice on a boot logo a loose // title check passes, the boot's black, the title (A works), the // load's black, then its tips screen, which the title check passes // too. Each fade after a title press holds the title check off for From 1914489a8d66dfbb1cc2f376f5071b00c6554f63 Mon Sep 17 00:00:00 2001 From: dayfine Date: Sun, 15 Nov 2026 12:26:56 -0800 Subject: [PATCH 3/3] Drop the shared story launch and Switch prompts: PLZA reloads with reset_game_from_home() --- .../AutoStory/Engine/Pokemon_StoryLaunch.cpp | 313 -------------- .../AutoStory/Engine/Pokemon_StoryLaunch.h | 176 -------- .../Engine/Pokemon_StoryLaunch_Tests.cpp | 381 ------------------ .../Engine/Pokemon_StoryLaunch_Tests.h | 23 -- .../AutoStory/Pokemon_StorySwitchPrompts.cpp | 53 --- .../AutoStory/Pokemon_StorySwitchPrompts.h | 33 -- SerialPrograms/cmake/SourceFiles.cmake | 6 - 7 files changed, 985 deletions(-) delete mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp delete mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h delete mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp delete mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h delete mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp delete mode 100644 SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp deleted file mode 100644 index 7c6cc9c81e..0000000000 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/* Story Launch - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include "NintendoSwitch/Inference/NintendoSwitch_HomeTileReader.h" -#include "Pokemon_StoryLaunch.h" - -namespace PokemonAutomation{ -namespace Pokemon{ - -using namespace NintendoSwitch; - - -namespace{ - - -// What a look shows, as far as a launch cares. -enum class LaunchScreen{ - HOME, - NEW_GAME, - PROMPT, - TITLE, - OVERWORLD, - OTHER, -}; - -struct LaunchLook{ - LaunchScreen screen = LaunchScreen::OTHER; - // The prompt on screen, for PROMPT. - const StoryLaunchPrompt* prompt = nullptr; -}; - -// Which of the policy's loose checks a look may pass. -struct LaunchReadable{ - // The launch launched or closed the game: the checks read only after. - bool launched = false; - // No title press's fade holds the title check off, and a title read - // only after the launch (title_after_launch) waits for the A on the - // game's tile: right after the close, before HOME, a screen passes - // a loose title check. - bool title = true; -}; - -// `look` as `policy` reads it. HOME first: a game's detectors may read -// HOME's plain screen as a quiet overworld. -LaunchLook read_launch_look(const StoryLaunchPolicy& policy, const ScreenObservation& look, LaunchReadable readable){ - const bool launched = readable.launched; - if (look.events.has(ScreenEvent::SWITCH_HOME_MENU)){ - return {.screen = LaunchScreen::HOME}; - } - if (policy.new_game && policy.new_game(look)){ - return {.screen = LaunchScreen::NEW_GAME}; - } - for (const StoryLaunchPrompt& prompt : policy.prompts){ - if ((launched || !prompt.after_launch) && prompt.matches && prompt.matches(look)){ - return {.screen = LaunchScreen::PROMPT, .prompt = &prompt}; - } - } - if (readable.title && (launched || !policy.title_after_launch) && policy.title(look)){ - return {.screen = LaunchScreen::TITLE}; - } - const bool overworld = policy.overworld ? policy.overworld(look) : look.events.has(ScreenEvent::PLAYER_CAN_MOVE); - return {.screen = overworld ? LaunchScreen::OVERWORLD : LaunchScreen::OTHER}; -} - -Outcome launch_failed(std::string detail){ - return outcome_failed(std::string(STORY_LAUNCH_FAILED), std::move(detail)); -} - -// Why `policy` cannot launch `request`, before any press; nothing when it -// can. -std::optional launch_problem(const StoryLaunchPolicy& policy, StoryLaunchRequest request){ - if (!policy.tile_selected || !policy.title){ - return launch_failed(std::format("{}: the launch policy has no tile or title check", policy.game)); - } - if (request.save == StoryLaunchRequest::Save::BACKUP && policy.backup_save.empty()){ - return launch_failed(std::format("{}: the game has no backup save", policy.game)); - } - return std::nullopt; -} - - -// One launch: a look, one thing done about it, until the overworld has -// settled or a screen took too many presses. -template -class LaunchDriver{ -public: - LaunchDriver(StoryBackend& backend, const StoryLaunchPolicy& policy, StoryLaunchRequest request) - : m_backend(backend) - , m_policy(policy) - , m_request(request) - {} - - // One look and its answer; the launch's end when this look ended it. - std::optional step(){ - const Observation observation = m_backend.observe(); - const LaunchLook look = read_launch_look(m_policy, observation, {.launched = m_launched || m_loading, .title = m_title_held_looks == 0 && (m_launched || !m_policy.title_after_launch)}); - count_title_hold(observation); - if (look.screen != LaunchScreen::OVERWORLD){ - m_settled = 0; - } - switch (look.screen){ - case LaunchScreen::HOME: - return on_home(observation); - case LaunchScreen::NEW_GAME: - return launch_failed(std::format("{}: the game shows a new game: no save to load, and a launch never starts one", m_policy.game)); - case LaunchScreen::PROMPT: - return on_prompt(*look.prompt); - case LaunchScreen::TITLE: - return on_title(observation); - case LaunchScreen::OVERWORLD: - return on_overworld(); - case LaunchScreen::OTHER: - break; - } - return on_other(); - } - -private: - // Whether an overworld up now is not yet the save asked for. - bool needs_load() const{ - return !m_loading && (m_request.running == StoryLaunchRequest::Running::RESTART || m_request.save == StoryLaunchRequest::Save::BACKUP); - } - - // The cursor to the game's tile, then the game closed if it must - // load again, then A on the tile. - std::optional on_home(const ScreenObservation& observation){ - if (m_launch_pressed && m_home_waited < m_policy.launch_wait){ - if (m_home_waited == Milliseconds(0)){ - log("home", "waiting for the game to start"); - } - m_home_waited += m_policy.poll; - m_backend.wait(m_policy.poll); - return std::nullopt; - } - if (!m_policy.tile_selected(observation)){ - return move_to_tile(); - } - if (needs_load()){ - m_loading = true; - return press("home", {.button = BUTTON_X}, m_policy.presses_per_screen, "close the game"); - } - m_launched = true; - m_launch_pressed = true; - m_home_waited = Milliseconds(0); - return press("home", {.button = BUTTON_A}, m_policy.presses_per_screen, "launch the game"); - } - - std::optional move_to_tile(){ - const size_t left = m_policy.tile_search; - if (m_tile_moves >= 3 * left){ - return launch_failed(std::format("{}: the game's tile is not on HOME: {} tiles searched", m_policy.game, m_tile_moves)); - } - const Button button = m_tile_moves < left ? BUTTON_LEFT : BUTTON_RIGHT; - m_tile_moves++; - log("home", std::format("not on the game's tile: {}", button_to_string(button))); - m_backend.press(button, Milliseconds(80), Milliseconds(400)); - return std::nullopt; - } - - // The prompt's lead-in presses, then its press. - std::optional on_prompt(const StoryLaunchPrompt& prompt){ - if (m_presses[prompt.name] < prompt.max_presses){ - for (const StoryLaunchPress& each : prompt.before){ - m_backend.press(each.button, each.hold, each.release); - } - } - return press(prompt.name, prompt.press, prompt.max_presses); - } - - std::optional on_title(const ScreenObservation& observation){ - m_loading = true; - m_launched = true; - const bool backup = m_request.save == StoryLaunchRequest::Save::BACKUP && !m_backup_sent; - if (backup && m_policy.backup_title && !m_policy.backup_title(observation)){ - m_backend.wait(m_policy.poll); - return std::nullopt; - } - if (backup){ - m_backup_sent = true; - log("title", "the backup save"); - for (const StoryLaunchPress& each : m_policy.backup_save){ - m_backend.press(each.button, each.hold, each.release); - } - } - m_title_pressed = true; - return press("title", m_policy.title_press, m_policy.presses_per_screen); - } - - // A black fade after a title press starts the title's hold; each - // other look shortens it. - void count_title_hold(const ScreenObservation& observation){ - if (m_title_pressed && observation.events.has(ScreenEvent::FADE_BLACK)){ - m_title_pressed = false; - m_title_held_looks = m_policy.title_load_looks; - }else if (m_title_held_looks > 0){ - m_title_held_looks--; - } - } - - std::optional on_overworld(){ - if (needs_load()){ - return press("overworld", {.button = BUTTON_HOME}, m_policy.presses_per_screen, "HOME, to load the save"); - } - if (++m_settled >= m_policy.settled_looks){ - log("overworld", std::format("settled for {} looks", m_settled)); - return outcome_ok(); - } - m_backend.wait(m_policy.poll); - return std::nullopt; - } - - // A screen the policy doesn't know: the game's boot or a load once - // launched; before that the game was in front already, left with HOME - // to load the save, or B toward its overworld. - std::optional on_other(){ - if (m_launched || m_loading){ - m_backend.wait(m_policy.poll); - return std::nullopt; - } - if (needs_load()){ - return press("unknown screen", {.button = BUTTON_HOME}, m_policy.presses_per_screen, "HOME, to load the save"); - } - return press("unknown screen", {.button = BUTTON_B}, m_policy.presses_per_screen, "B, toward the overworld"); - } - - // `what` on `screen`, unless `screen` already took `max` presses. - std::optional press(std::string_view screen, const StoryLaunchPress& what, size_t max, std::string_view why = {}){ - size_t& count = m_presses[std::string(screen)]; - if (count >= max){ - return launch_failed(std::format("{}: stuck on {}: {} presses changed nothing", m_policy.game, screen, count)); - } - count++; - log(screen, why.empty() ? button_to_string(what.button) : std::string(why)); - m_backend.press(what.button, what.hold, what.release); - return std::nullopt; - } - - void log(std::string_view screen, std::string_view what){ - m_backend.log(std::format("[Launch] {}: {}: {}", m_policy.game, screen, what)); - } - - StoryBackend& m_backend; - const StoryLaunchPolicy& m_policy; - StoryLaunchRequest m_request; - std::map> m_presses; - size_t m_tile_moves = 0; - size_t m_settled = 0; - // The game was closed from HOME, or showed its title: what comes up - // next is a save loading. - bool m_loading = false; - // A on the game's tile, or the title: until the overworld, a screen - // the policy doesn't know is the game booting or loading. - bool m_launched = false; - // A was pressed on the game's tile, and HOME has shown for - // `m_home_waited` since. - bool m_launch_pressed = false; - Milliseconds m_home_waited = Milliseconds(0); - bool m_backup_sent = false; - // A title press with no black fade since. - bool m_title_pressed = false; - // Looks left on which the title is not read (title_load_looks). - size_t m_title_held_looks = 0; -}; - - -} // namespace - - -std::function switch_home_tile_named(Language language, std::string name){ - return [language, name = std::move(name)](const ScreenObservation& look){ - return look.frame && look.frame->frame && selected_home_tile_is(language, *look.frame->frame, name); - }; -} - - -template -Outcome launch_story_game(StoryBackend& backend, const StoryLaunchPolicy& policy, StoryLaunchRequest request){ - if (std::optional problem = launch_problem(policy, request)){ - backend.log(std::format("[Launch] {}", problem->detail)); - return std::move(*problem); - } - LaunchDriver driver(backend, policy, request); - for (size_t looks = 0; looks < policy.max_looks; looks++){ - backend.scope().throw_if_cancelled(); - if (std::optional end = driver.step()){ - if (!end->succeeded()){ - backend.log(std::format("[Launch] {}", end->detail)); - } - return std::move(*end); - } - } - const Outcome failed = launch_failed(std::format("{}: no overworld after {} looks", policy.game, policy.max_looks)); - backend.log(std::format("[Launch] {}", failed.detail)); - return failed; -} - -template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); -template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); - - - -} // namespace Pokemon -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h deleted file mode 100644 index 3d7a7c8efb..0000000000 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h +++ /dev/null @@ -1,176 +0,0 @@ -/* Story Launch - * - * From: https://github.com/PokemonAutomation/ - * - * A run's first event: from wherever the console is (the Switch's HOME - * menu with the game closed or suspended, the game's title, the - * overworld) to the overworld on a save. One driver for every game; the - * game's StoryLaunchPolicy says how its screens look and which press - * answers each. It runs before the first checkpoint, on its own, never - * inside a new game's language or intro steps, and it never starts a new - * game. - * - * The driver looks, does one thing, and looks again. It does not need to - * know every screen: one it doesn't know is waited out (a boot, a fade) - * or, before the game was launched, left with HOME or B. Each screen's - * presses are counted, so a screen that ignores its press fails the - * launch instead of looping, and the launch ends only once the overworld - * shows for several looks in a row. - * - */ - -#ifndef PokemonAutomation_Pokemon_StoryLaunch_H -#define PokemonAutomation_Pokemon_StoryLaunch_H - -#include -#include -#include -#include -#include -#include "Common/Cpp/Time.h" -#include "CommonFramework/Language.h" -#include "CommonTools/ScreenMachine/ScreenObservation.h" -#include "NintendoSwitch/Controllers/NintendoSwitch_ControllerButtons.h" -#include "Pokemon/AutoStory/Pokemon_StoryOutcome.h" -#include "Pokemon/AutoStory/Types/Pokemon_GridPose.h" -#include "Pokemon_StoryBackend.h" -#include "Pokemon_ZonePose.h" - -namespace PokemonAutomation{ -namespace Pokemon{ - - -// What a launch loads. -struct StoryLaunchRequest{ - enum class Save{ - LATEST, // the title's plain load - BACKUP, // the policy's backup_save presses on the title first - // (PLZA: Up, then B + X, the save before the latest) - }; - enum class Running{ - // A game already on the overworld is the start: it is resumed - // from HOME, not reloaded. - KEEP, - // A game already running is closed from HOME, then launched, so - // the save loads; a title on screen already counts as launched. - RESTART, - }; - Save save = Save::LATEST; - Running running = Running::RESTART; -}; - -// One press: `button` (several pressed together when or-ed), held for -// `hold`, then let go for `release`. -struct StoryLaunchPress{ - NintendoSwitch::Button button = NintendoSwitch::BUTTON_A; - Milliseconds hold = Milliseconds(80); - Milliseconds release = Milliseconds(400); -}; - -// A screen on the way that one press answers: the user select, an online -// license check, HOME's close-software dialog, the load menu's Continue, -// a recap of the story so far. -struct StoryLaunchPrompt{ - std::string name = {}; - std::function matches = {}; - StoryLaunchPress press = {}; - // Pressed in order before `press`, each time: the cursor moves to the - // choice `press` picks (the update prompt's last choice). - std::vector before = {}; - // Read only once this launch launched or closed the game: a screen - // the game also shows in play (a dialog box, a choice), where a press - // before the launch would answer the story instead. - bool after_launch = false; - // Presses it may take before the launch is stuck on it. - size_t max_presses = 6; -}; - -// How one game's screens look on the way from HOME to its overworld. -struct StoryLaunchPolicy{ - // "frlg", "bdsp", "plza", for the log. - std::string game = {}; - // On HOME: whether the cursor is on this game's tile. The launch - // presses A on HOME only then, as A launches whatever tile is - // selected. Required; on a Switch, switch_home_tile_named() with the - // name HOME shows for the game. - std::function tile_selected = {}; - // How far the tile search moves each way: Left `tile_search` times - // (the most recently played games are leftmost), then Right twice as - // many. - size_t tile_search = 6; - // The title screen, which leads to the save. Required. - std::function title = {}; - StoryLaunchPress title_press = {}; - // `title` is read only once this launch launched or closed the game: - // a loose check (any quiet screen after the boot) that a game in play - // would pass too. - bool title_after_launch = false; - // Pressed once on the title before `title_press` for Save::BACKUP. - // Empty: the game has no backup save, and a BACKUP launch fails - // before it presses anything. - std::vector backup_save = {}; - // Where `backup_save` goes: the title proper. A loose `title` passes - // the boot's logos too, where those presses do nothing and the title's - // next press loads the latest save. Until it - // shows, a BACKUP launch waits on title looks without a press. Empty: - // the first title look takes them. - std::function backup_title = {}; - // A screen that would start a new game: there is no save. The launch - // fails there without a press. Optional. - std::function new_game = {}; - // The game's other screens on the way, each answered by its press. - std::vector prompts = {}; - // The player in control. Unset: the look shows PLAYER_CAN_MOVE. - std::function overworld = {}; - // Looks after a title press's black fade (FADE_BLACK) on which - // `title` is not read: the screens there are the save loading or the - // boot, waited out. A loose title check passes a load's tips screen, - // and an A on a boot logo is followed by the boot's own fade, so the - // title is read again once these looks are over. 0: always read. - size_t title_load_looks = 0; - // Looks in a row the overworld must show before the launch is done. - size_t settled_looks = 3; - // The wait between looks at a screen with nothing to press. - Milliseconds poll = Milliseconds(500); - // After A on the game's tile, how long HOME may still show (its zoom - // into the game, a check or the user select in front of it) before - // the launch takes A again: until then each look at HOME waits, as - // another A there would launch the game again. - Milliseconds launch_wait = Milliseconds(30000); - // Presses HOME, the title, an overworld to leave or a screen the - // policy doesn't know may take before the launch is stuck there. - size_t presses_per_screen = 6; - // Looks before the launch gives up: about `poll` times this of - // loading at most. - size_t max_looks = 360; -}; - -// A `tile_selected` for a Switch game: HOME's cursor is on the tile whose -// name, above the game row, contains `name` ("Pokémon Legends: Z-A"), -// read in `language`, the console's (NintendoSwitch_HomeTileReader.h). -// False on a look without a frame, as in a simulation. -std::function switch_home_tile_named(Language language, std::string name); - -// The failure of a launch that did not reach the overworld; its detail -// says where it stopped. Nothing in the story answers it: no reload, no -// recovery. -inline constexpr std::string_view STORY_LAUNCH_FAILED = "launch_failed"; - -// Drives `backend` to the overworld on the save `request` asks for, by -// `policy`; logs each press as "[Launch] : : ". -// Succeeds once the overworld shows `policy.settled_looks` looks in a -// row; fails as STORY_LAUNCH_FAILED on a new game, a missing tile, a -// screen that took too many presses, or after `policy.max_looks` looks. -template -Outcome launch_story_game(StoryBackend& backend, const StoryLaunchPolicy& policy, StoryLaunchRequest request); - -// Instantiated once, in Pokemon_StoryLaunch.cpp. -extern template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); -// And for ZonePose (Pokemon_ZonePose.h). -extern template Outcome launch_story_game(StoryBackend&, const StoryLaunchPolicy&, StoryLaunchRequest); - - - -} // namespace Pokemon -} // namespace PokemonAutomation -#endif diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp deleted file mode 100644 index 32f2bf7a10..0000000000 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp +++ /dev/null @@ -1,381 +0,0 @@ -/* Story Launch Tests - * - * From: https://github.com/PokemonAutomation/ - * - * The launch on a scripted console: each case is the screens the console - * shows, look by look (the last repeats), and the presses the launch must - * make, or where it must fail. The test game's screens are readings its - * policy reads; HOME is the shared SWITCH_HOME_MENU event and the - * overworld the shared PLAYER_CAN_MOVE. - * - */ - -#include -#include -#include -#include -#include -#include -#include "Common/Cpp/TestRunners/UnitTest.h" -#include "Pokemon_StoryFakeBackend.h" -#include "Pokemon_StoryLaunch.h" -#include "Pokemon_StoryLaunch_Tests.h" - -namespace PokemonAutomation{ -namespace Pokemon{ - -using namespace NintendoSwitch; - - -namespace{ - - -// What the scripted console shows. -enum class Screen{ - HOME_ON_GAME, // HOME, the cursor on the game's tile - HOME_OFF_GAME, // HOME, the cursor on another tile - CLOSE_DIALOG, // HOME's "Close software?" - LICENSE_CHECK, // the online license check - BLACK, // a boot or a load - FADE, // a black fade (FADE_BLACK), as a boot or a load starts - TITLE, - NEW_GAME, // the title's menu without a save - BACKUP_CONFIRM, // "Load the backup save?" - LOAD_MENU, // Continue / New Game - UPDATE, // the update prompt: Up twice to its last choice, then A - GAME_DIALOG, // the game's dialog box, in play or on the way - LOGO, // a boot logo, which a loose title check passes - OVERWORLD, -}; - -inline constexpr std::string_view SCREEN = "screen"; -inline constexpr std::string_view TILE = "home.tile"; - -Observation look(Screen screen){ - Observation observation; - switch (screen){ - case Screen::HOME_ON_GAME: - case Screen::HOME_OFF_GAME: - observation.events = ScreenEvents{ScreenEvent::SWITCH_HOME_MENU}; - observation.readings[std::string(TILE)] = screen == Screen::HOME_ON_GAME ? 1 : 0; - return observation; - case Screen::OVERWORLD: - observation.events = ScreenEvents{ScreenEvent::PLAYER_CAN_MOVE}; - return observation; - case Screen::FADE: - observation.events = ScreenEvents{ScreenEvent::FADE_BLACK}; - return observation; - default: - observation.readings[std::string(SCREEN)] = (int)screen; - return observation; - } -} - -std::function shows(Screen screen){ - return [screen](const ScreenObservation& observation){ - const auto it = observation.readings.find(SCREEN); - return it != observation.readings.end() && it->second == (int)screen; - }; -} - -// Whether the test game has a backup save. -enum class Backup{ - PLZA, // Up, then B + X - NONE, -}; - -// How the test game finds its tile on HOME. -enum class TileCheck{ - READINGS, // the scripted "home.tile" reading - SWITCH_NAME, // switch_home_tile_named(), which reads the look's frame -}; - -// How loose the test game's title and dialog checks are. -enum class GameScreens{ - STRICT, // read whenever they show - AFTER_LAUNCH, // read only once the launch launched the game -}; - -// Which screens the test game's title check passes. -enum class TitleCheck{ - TITLE, // the title only - LOOSE, // the title and the boot's logos; the backup save only on the title -}; - -// The test game's bounds that a case may change. -struct Bounds{ - size_t title_load_looks = 0; - size_t max_looks = 12; -}; - -// The test game: A on the title, `backup` for the backup save, A on each -// prompt (Up, Up, A on the update prompt; B on the game's dialog), and -// small bounds so a failure takes few looks. -StoryLaunchPolicy test_policy(Backup backup, GameScreens game_screens, TileCheck tile_check, TitleCheck title_check, Bounds bounds){ - StoryLaunchPolicy policy; - policy.game = "test"; - policy.tile_selected = [](const ScreenObservation& observation){ - const auto it = observation.readings.find(TILE); - return it != observation.readings.end() && it->second == 1; - }; - if (tile_check == TileCheck::SWITCH_NAME){ - policy.tile_selected = switch_home_tile_named(Language::English, "Pokémon Legends: Z-A"); - } - policy.tile_search = 2; - policy.title = shows(Screen::TITLE); - if (title_check == TitleCheck::LOOSE){ - policy.title = [](const ScreenObservation& observation){ - return shows(Screen::TITLE)(observation) || shows(Screen::LOGO)(observation); - }; - policy.backup_title = shows(Screen::TITLE); - } - if (backup == Backup::PLZA){ - policy.backup_save = {{.button = BUTTON_UP}, {.button = BUTTON_B | BUTTON_X, .hold = Milliseconds(1000)}}; - } - policy.new_game = shows(Screen::NEW_GAME); - policy.prompts = { - {.name = "close software", .matches = shows(Screen::CLOSE_DIALOG)}, - {.name = "license check", .matches = shows(Screen::LICENSE_CHECK)}, - {.name = "backup confirm", .matches = shows(Screen::BACKUP_CONFIRM)}, - {.name = "load menu", .matches = shows(Screen::LOAD_MENU)}, - {.name = "update", .matches = shows(Screen::UPDATE), .before = {{.button = BUTTON_UP}, {.button = BUTTON_UP}}}, - {.name = "game dialog", .matches = shows(Screen::GAME_DIALOG), .press = {.button = BUTTON_B}, - .after_launch = game_screens == GameScreens::AFTER_LAUNCH}, - }; - policy.title_after_launch = game_screens == GameScreens::AFTER_LAUNCH; - policy.presses_per_screen = 3; - policy.title_load_looks = bounds.title_load_looks; - policy.launch_wait = Milliseconds(2000); - policy.max_looks = bounds.max_looks; - return policy; -} - -// `screens`, then the overworld for as many looks as it takes to settle. -std::vector then_settled(std::vector screens){ - screens.insert(screens.end(), {Screen::OVERWORLD, Screen::OVERWORLD, Screen::OVERWORLD}); - return screens; -} - -using Save = StoryLaunchRequest::Save; -using Running = StoryLaunchRequest::Running; - -// One launch. -struct LaunchCase{ - struct Input{ - std::vector screens; - StoryLaunchRequest request = {}; - Backup backup = Backup::PLZA; - GameScreens game_screens = GameScreens::STRICT; - TileCheck tile_check = TileCheck::READINGS; - TitleCheck title_check = TitleCheck::TITLE; - Bounds bounds = {}; - }; - struct Expectation{ - // Empty: the launch succeeds; else a part of its failure's detail. - std::string_view failure = {}; - // The inputs in order, by space: a button ("A", "HOME", "B+X") - // or "wait". - std::string_view inputs = {}; - }; - std::string_view name; - Input input; - Expectation expectation; -}; - -const std::vector LAUNCH_CASES = { - {.name = "game closed on HOME", - .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE, Screen::BLACK})}, - .expectation = {.inputs = "X A wait A wait wait wait"}}, - {.name = "game open on its title", - .input = {.screens = then_settled({Screen::TITLE, Screen::BLACK})}, - .expectation = {.inputs = "A wait wait wait"}}, - {.name = "game on the overworld kept", - .input = {.screens = then_settled({}), .request = {.running = Running::KEEP}}, - .expectation = {.inputs = "wait wait"}}, - // RELOAD_AT_START off (Pokemon_StoryRunOptions.h) on PLZA's loose - // title check: a game already on the overworld (at a Pokemon Center - // counter, say) is started from with no press. - {.name = "game on the overworld kept with a loose title check", - .input = {.screens = then_settled({}), .request = {.running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH}, - .expectation = {.inputs = "wait wait"}}, - {.name = "kept game resumed from HOME with a loose title check", - .input = {.screens = then_settled({Screen::HOME_ON_GAME}), .request = {.running = Running::KEEP}, - .game_screens = GameScreens::AFTER_LAUNCH}, - .expectation = {.inputs = "A wait wait"}}, - {.name = "game on the overworld restarted", - .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::HOME_ON_GAME, - Screen::BLACK, Screen::TITLE})}, - .expectation = {.inputs = "HOME X A A wait A wait wait"}}, - {.name = "backup save from the overworld", - .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::TITLE, - Screen::BACKUP_CONFIRM, Screen::BLACK}), - .request = {.save = Save::BACKUP, .running = Running::KEEP}}, - .expectation = {.inputs = "HOME X A Up B+X A A wait wait wait"}}, - // After the close, a screen before HOME passes a loose title check; - // the backup's buttons must not go there, or the real title takes only - // A and the latest save loads. - {.name = "backup save waits for the title after the game's launch", - .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::TITLE, - Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE, Screen::BACKUP_CONFIRM, Screen::BLACK}), - .request = {.save = Save::BACKUP, .running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH}, - .expectation = {.inputs = "HOME X A wait A wait Up B+X A A wait wait wait"}}, - // The backup's buttons must not go to a boot logo that passes a loose - // title check, or the title takes only A. - {.name = "backup save waits past the boot's logos for the title", - .input = {.screens = then_settled({Screen::OVERWORLD, Screen::HOME_ON_GAME, Screen::CLOSE_DIALOG, Screen::HOME_ON_GAME, - Screen::LOGO, Screen::LOGO, Screen::TITLE, Screen::BACKUP_CONFIRM, Screen::BLACK}), - .request = {.save = Save::BACKUP, .running = Running::KEEP}, .game_screens = GameScreens::AFTER_LAUNCH, - .title_check = TitleCheck::LOOSE}, - .expectation = {.inputs = "HOME X A A wait wait Up B+X A A wait wait wait"}}, - {.name = "backup save the game does not have", - .input = {.screens = then_settled({}), .request = {.save = Save::BACKUP}, .backup = Backup::NONE}, - .expectation = {.failure = "no backup save", .inputs = ""}}, - {.name = "license check back to HOME", - .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::LICENSE_CHECK, Screen::HOME_ON_GAME, - Screen::BLACK, Screen::TITLE, Screen::LOAD_MENU})}, - .expectation = {.inputs = "X A A wait wait A A wait wait"}}, - // HOME can show for about 1.5 s after the A on the tile; a look there - // must not press A again. - {.name = "HOME after the launch press waits", - .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, - Screen::HOME_ON_GAME, Screen::BLACK, Screen::TITLE})}, - .expectation = {.inputs = "X A wait wait wait wait A wait wait"}}, - {.name = "HOME past the launch wait takes A again", - .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, - Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::TITLE})}, - .expectation = {.inputs = "X A wait wait wait wait A A wait wait"}}, - {.name = "cursor on another tile", - .input = {.screens = then_settled({Screen::HOME_OFF_GAME, Screen::HOME_OFF_GAME, Screen::HOME_ON_GAME}), - .request = {.running = Running::KEEP}}, - .expectation = {.inputs = "Left Left A wait wait"}}, - {.name = "game not on HOME", - .input = {.screens = {Screen::HOME_OFF_GAME}}, - .expectation = {.failure = "tile is not on HOME", .inputs = "Left Left Right Right Right Right"}}, - {.name = "Switch tile check never launches without a frame", - .input = {.screens = {Screen::HOME_ON_GAME}, .tile_check = TileCheck::SWITCH_NAME}, - .expectation = {.failure = "tile is not on HOME", .inputs = "Left Left Right Right Right Right"}}, - {.name = "title ignores A", - .input = {.screens = {Screen::TITLE}}, - .expectation = {.failure = "stuck on title", .inputs = "A A A"}}, - {.name = "no save never starts a new game", - .input = {.screens = {Screen::NEW_GAME}}, - .expectation = {.failure = "new game", .inputs = ""}}, - {.name = "black screen after launch times out", - .input = {.screens = {Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::BLACK}}, - .expectation = {.failure = "no overworld after 12 looks", .inputs = "X A wait wait wait wait wait wait wait wait wait wait"}}, - {.name = "kept game off the overworld takes B", - .input = {.screens = then_settled({Screen::LOAD_MENU, Screen::BLACK}), .request = {.running = Running::KEEP}}, - .expectation = {.inputs = "A B wait wait"}}, - {.name = "update prompt takes its lead-in presses", - .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::UPDATE, Screen::BLACK, Screen::TITLE})}, - .expectation = {.inputs = "X A Up Up A wait A wait wait"}}, - {.name = "strict title in front is pressed", - .input = {.screens = then_settled({Screen::GAME_DIALOG, Screen::TITLE, Screen::BLACK})}, - .expectation = {.inputs = "B A wait wait wait"}}, - {.name = "loose title in front is left with HOME", - .input = {.screens = then_settled({Screen::GAME_DIALOG, Screen::TITLE, Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, - Screen::BLACK, Screen::GAME_DIALOG, Screen::TITLE}), - .game_screens = GameScreens::AFTER_LAUNCH}, - .expectation = {.inputs = "HOME HOME X A wait B A wait wait"}}, - // A twice on a boot logo a loose - // title check passes, the boot's black, the title (A works), the - // load's black, then its tips screen, which the title check passes - // too. Each fade after a title press holds the title check off for - // 6 looks: the boot's title waits 3 looks, the tips screen gets no A. - {.name = "title not read on the screens after its fade", - .input = {.screens = then_settled({Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::FADE, - Screen::TITLE, Screen::TITLE, - Screen::FADE, Screen::FADE, Screen::FADE, Screen::FADE, - Screen::TITLE, Screen::TITLE, Screen::TITLE, Screen::TITLE, - Screen::FADE, Screen::FADE, - Screen::TITLE, Screen::TITLE, Screen::TITLE, Screen::TITLE}), - .game_screens = GameScreens::AFTER_LAUNCH, .bounds = {.title_load_looks = 6, .max_looks = 30}}, - .expectation = {.inputs = "X A wait A A wait wait wait wait wait wait wait A wait wait wait wait wait wait wait wait"}}, - {.name = "title read again once its fade's looks are over", - .input = {.screens = {Screen::HOME_ON_GAME, Screen::HOME_ON_GAME, Screen::TITLE, Screen::FADE, Screen::TITLE}, - .game_screens = GameScreens::AFTER_LAUNCH, .bounds = {.title_load_looks = 2}}, - .expectation = {.failure = "stuck on title", .inputs = "X A A wait wait wait A A"}}, -}; - -// The fake backend's record of `input` ("A" -> "press A"). -std::string recorded(std::string_view input){ - if (input == "wait"){ - return "wait 500ms"; - } - static const std::map BUTTONS = { - {"A", BUTTON_A}, {"B", BUTTON_B}, {"X", BUTTON_X}, {"HOME", BUTTON_HOME}, - {"Up", BUTTON_UP}, {"Left", BUTTON_LEFT}, {"Right", BUTTON_RIGHT}, {"B+X", BUTTON_B | BUTTON_X}, - }; - const auto it = BUTTONS.find(input); - return it == BUTTONS.end() ? std::format("unknown input {}", input) : std::format("press {}", button_to_string(it->second)); -} - -// `inputs` (by space) as the fake backend records them. -std::vector expected_inputs(std::string_view inputs){ - std::vector expected; - while (!inputs.empty()){ - const size_t space = inputs.find(' '); - expected.push_back(recorded(inputs.substr(0, space))); - inputs = space == std::string_view::npos ? std::string_view() : inputs.substr(space + 1); - } - return expected; -} - -std::string describe_inputs(const std::vector& inputs){ - std::string text; - for (const std::string& input : inputs){ - text += text.empty() ? input : std::format(", {}", input); - } - return std::format("[{}]", text); -} - -std::string check_launch(const LaunchCase& test, CancellableScope& scope){ - std::vector> looks; - for (Screen screen : test.input.screens){ - looks.push_back(look(screen)); - } - FakeStoryBackend backend({.looks = std::move(looks)}, scope); - const Outcome outcome = launch_story_game(backend, test_policy(test.input.backup, test.input.game_screens, test.input.tile_check, test.input.title_check, test.input.bounds), test.input.request); - if (test.expectation.failure.empty() && !outcome.succeeded()){ - return std::format("expected success, got {}", to_string(outcome)); - } - if (!test.expectation.failure.empty()){ - if (outcome.failure != STORY_LAUNCH_FAILED || outcome.detail.find(test.expectation.failure) == std::string::npos){ - return std::format("expected a launch failure with \"{}\", got {}", test.expectation.failure, to_string(outcome)); - } - } - const std::vector expected = expected_inputs(test.expectation.inputs); - if (backend.inputs() != expected){ - return std::format("expected inputs {}, got {}", describe_inputs(expected), describe_inputs(backend.inputs())); - } - return ""; -} - -class StoryLaunchTest : public UnitTest{ -public: - explicit StoryLaunchTest(LaunchCase test) - : UnitTest(std::format("Pokemon::StoryLaunch - {}", test.name)) - , m_case(std::move(test)) - {} - virtual UnitTestResult run(Logger&, CancellableScope& scope) const override{ - const std::string error = check_launch(m_case, scope); - return error.empty() ? UnitTestResult(true) : UnitTestResult(error); - } -private: - LaunchCase m_case; -}; - - -} // namespace - - -void add_tests_StoryLaunch(UnitTestDatabase& database){ - for (const LaunchCase& test : LAUNCH_CASES){ - database.add(test); - } -} - - - -} // namespace Pokemon -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h b/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h deleted file mode 100644 index efba4cc847..0000000000 --- a/SerialPrograms/Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Story Launch Tests - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#ifndef PokemonAutomation_Pokemon_StoryLaunch_Tests_H -#define PokemonAutomation_Pokemon_StoryLaunch_Tests_H - -#include "Common/Cpp/TestRunners/UnitTestDatabase.h" - -namespace PokemonAutomation{ -namespace Pokemon{ - - -// Registers unit tests for the launch from HOME to the overworld on a scripted console. -void add_tests_StoryLaunch(UnitTestDatabase& database); - - - -} // namespace Pokemon -} // namespace PokemonAutomation -#endif diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp deleted file mode 100644 index 3dcb5a4d94..0000000000 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* AutoStory Switch Launch Prompts - * - * From: https://github.com/PokemonAutomation/ - * - */ - -#include -#include -#include -#include -#include "NintendoSwitch/NintendoSwitch_Settings.h" -#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "NintendoSwitch/Inference/NintendoSwitch_CloseGameDetector.h" -#include "NintendoSwitch/Inference/NintendoSwitch_StartGameUserSelectDetector.h" -#include "NintendoSwitch/Inference/NintendoSwitch_UpdatePopupDetector.h" -#include "Pokemon_StorySwitchPrompts.h" - -namespace PokemonAutomation{ -namespace Pokemon{ - -using namespace std::chrono_literals; -using namespace NintendoSwitch; - - -namespace{ - -// Whether `detector` fires on the look's frame; false without one. -template -std::function frame_shows(std::shared_ptr detector){ - return [detector = std::move(detector)](const ScreenObservation& look){ - return look.frame && look.frame->frame && detector->detect(*look.frame->frame); - }; -} - -} // namespace - - -std::vector switch_launch_prompts(ConsoleHandle& console){ - const StoryLaunchPress scroll_up{.button = BUTTON_UP, .hold = 40ms, .release = 40ms}; - return { - {.name = "close software", .matches = frame_shows(std::make_shared(console)), - .press = {.button = BUTTON_A, .hold = 160ms, .release = ConsoleSettings::instance().CLOSE_GAME_DELAY}}, - {.name = "user select", .matches = frame_shows(std::make_shared(console)), - .press = {.button = BUTTON_A, .hold = 160ms}}, - {.name = "update prompt", .matches = frame_shows(std::make_shared(console)), - .press = {.button = BUTTON_A, .hold = 160ms}, .before = {scroll_up, scroll_up}}, - }; -} - - - -} // namespace Pokemon -} // namespace PokemonAutomation diff --git a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h b/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h deleted file mode 100644 index 5bfa8dba26..0000000000 --- a/SerialPrograms/Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h +++ /dev/null @@ -1,33 +0,0 @@ -/* AutoStory Switch Launch Prompts - * - * From: https://github.com/PokemonAutomation/ - * - * The Switch's own screens between HOME and a game, each answered by one - * press: HOME's "Close software?", the user select and the update prompt. - * They are the same in every game, so each game's StoryLaunchPolicy - * (Engine/Pokemon_StoryLaunch.h) starts its prompts with these. - * - */ - -#ifndef PokemonAutomation_Pokemon_StorySwitchPrompts_H -#define PokemonAutomation_Pokemon_StorySwitchPrompts_H - -#include -#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" -#include "Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h" - -namespace PokemonAutomation{ -namespace Pokemon{ - - -// On `console`'s frames: "Close software?" takes A, then the console's -// close delay (Switch settings); the user select takes A on the user -// highlighted; the update prompt takes Up twice, to "Start Software", then -// A. A look without a frame (a simulation) shows none of them. -std::vector switch_launch_prompts(NintendoSwitch::ConsoleHandle& console); - - - -} // namespace Pokemon -} // namespace PokemonAutomation -#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index 4bd6762699..f1e4071700 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1506,10 +1506,6 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/AutoStory/Engine/Pokemon_StoryFakeBackend.cpp Source/Pokemon/AutoStory/Engine/Pokemon_StoryFakeBackend.h Source/Pokemon/AutoStory/Engine/Pokemon_StoryGame.h - Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.cpp - Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch.h - Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.cpp - Source/Pokemon/AutoStory/Engine/Pokemon_StoryLaunch_Tests.h Source/Pokemon/AutoStory/Engine/Pokemon_StoryPoseConcept.cpp Source/Pokemon/AutoStory/Engine/Pokemon_StoryPoseConcept.h Source/Pokemon/AutoStory/Engine/Pokemon_StoryStepRunner.cpp @@ -1556,8 +1552,6 @@ file(GLOB LIBRARY_SOURCES Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor.h Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.cpp Source/Pokemon/AutoStory/Pokemon_StoryStepExecutor_Tests.h - Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.cpp - Source/Pokemon/AutoStory/Pokemon_StorySwitchPrompts.h Source/Pokemon/AutoStory/Pokemon_TestExpect.h Source/Pokemon/AutoStory/Pokemon_TilePose.cpp Source/Pokemon/AutoStory/Pokemon_TilePose.h