From d0dbc8387c9835e2427a3675250bc25d6210bb69 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 19:50:52 -0800 Subject: [PATCH 1/9] PokemonLZA: AutoStory: Main Mission 01 (01.01-01.03) The checkpoints from the station platform to Andi's battle: the arrival scenes, chasing Pancham, the starter and the first story battle. Adds the code only they use: the starter choice and its approach_starter walk, and the story_battle_start and story_battle steps; and the tests that play their steps on the scripted backend. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../AutoStory/PokemonLZA_AutoStory.cpp | 15 +- .../Programs/AutoStory/PokemonLZA_AutoStory.h | 1 + .../AutoStory/PokemonLZA_AutoStoryBackend.h | 8 + .../PokemonLZA_AutoStoryEngine_Tests.cpp | 257 +++++++++++++++++- .../AutoStory/PokemonLZA_AutoStoryGame.cpp | 49 +++- .../AutoStory/PokemonLZA_AutoStoryGame.h | 18 +- ...PokemonLZA_AutoStorySceneMachine_Tests.cpp | 31 +++ .../PokemonLZA_AutoStoryStepValidator.cpp | 35 ++- .../PokemonLZA_AutoStoryStepValidator.h | 10 +- .../PokemonLZA_AutoStoryStoryFiles.h | 6 +- .../AutoStory/PokemonLZA_AutoStoryTable.h | 3 +- .../PokemonLZA_AutoStoryTable_Tests.cpp | 160 +++++++++++ .../AutoStory/StoryData/plza-01.01.plan.json | 45 +++ .../AutoStory/StoryData/plza-01.02.plan.json | 50 ++++ .../AutoStory/StoryData/plza-01.03.plan.json | 52 ++++ 15 files changed, 716 insertions(+), 24 deletions(-) create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json create mode 100644 SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp index 74c72bd708..d454e164f1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.cpp @@ -37,7 +37,7 @@ AutoStory_Descriptor::AutoStory_Descriptor() "PokemonLZA:AutoStory", std::format("{} LZA", STRING_POKEMON), "Auto Story", "Programs/PokemonLZA/AutoStory.html", - "Play the main story of Pokemon Legends: Z-A. Prototype: plays a new game to the station platform, as recorded on a console.", + "Play the main story of Pokemon Legends: Z-A. Prototype: Main Mission 01 as recorded on a console; plays from a new game to the starter and Andi.", PanelQualityStanding::DEVELOPER, ProgramControllerClass::StandardController_NoRestrictions, FeedbackType::REQUIRED, @@ -69,6 +69,16 @@ const StringSelectDatabase& checkpoint_database(){ AutoStory::AutoStory() : RUN(checkpoint_database(), Gen8ToGen9Languages_Database()) + , STARTER( + "Starter Pokemon:", + { + {StarterChoice::CHIKORITA, "chikorita", "Chikorita"}, + {StarterChoice::TEPIG, "tepig", "Tepig"}, + {StarterChoice::TOTODILE, "totodile", "Totodile"}, + }, + LockMode::LOCK_WHILE_RUNNING, + StarterChoice::CHIKORITA + ) , GO_HOME_WHEN_DONE(false) , NOTIFICATIONS({ &NOTIFICATION_PROGRAM_FINISH, @@ -77,6 +87,7 @@ AutoStory::AutoStory() }) { PA_ADD_OPTION(RUN); + PA_ADD_OPTION(STARTER); PA_ADD_OPTION(BATTLE_AI); PA_ADD_OPTION(GO_HOME_WHEN_DONE); PA_ADD_OPTION(NOTIFICATIONS); @@ -135,7 +146,7 @@ void AutoStory::program(SingleSwitchProgramEnvironment& env, ProControllerContex StoryEnv story{.env = env, .context = context, .language = RUN.language(), .battle_ai = BATTLE_AI}; PlzaConsoleBackend backend(story); - const StoryGame game = make_plza_story_game(story, story_data.autosaves); + const StoryGame game = make_plza_story_game(story, STARTER, story_data.autosaves); StoryEngine engine(game, backend); RunState state; load_start_save(env.console, game, backend, rows, first); diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h index c7096ffad5..e91de192c1 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStory.h @@ -51,6 +51,7 @@ class AutoStory : public SingleSwitchProgramInstance{ private: // The start and end checkpoints, attempts, checks and language. Pokemon::StoryRunOptions RUN; + EnumDropdownOption STARTER; BattleAIOption BATTLE_AI; GoHomeWhenDoneOption GO_HOME_WHEN_DONE; diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h index 9e06505618..9334457891 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h @@ -41,6 +41,14 @@ namespace NintendoSwitch{ namespace PokemonLZA{ +// The starters Mission 1 offers. The player picks one by walking up to it +// and talking to it. +enum class StarterChoice{ + CHIKORITA, + TEPIG, + TOTODILE, +}; + // The console a run plays on, for the actions only a console can do // (menus, OCR, the battle AI). struct StoryEnv{ diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp index e340f962be..b402d14998 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp @@ -2,7 +2,7 @@ * * From: https://github.com/PokemonAutomation/ * - * 01.00's scene steps, the walks' compass turns, and every checkpoint, through the shared + * 01.00-01.01's scene steps and walks, and every checkpoint, through the shared * story engine on its scripted backend (FakeStoryBackend). * */ @@ -82,7 +82,7 @@ StoryCheckpoint step_of(std::string_view id, std::string_view name){ // `checkpoint` on PLZA's engine over `backend`. Pokemon::StoryEngineReport run_plza(FakeBackend& backend, const StoryCheckpoint& checkpoint){ - const Pokemon::StoryGame game = make_offline_plza_story_game(); + const Pokemon::StoryGame game = make_plza_story_game(StarterChoice::CHIKORITA); Pokemon::StoryEngine engine(game, backend); Pokemon::RunState state; return engine.run_checkpoint(checkpoint, Pokemon::SavePoint::RUN_END, state); @@ -138,6 +138,74 @@ UnitTestResult test_opening_waits_for_platform(CancellableScope& scope){ return expect_inputs(backend, std::vector(6, "wait 300ms")); } +// 01.01's start check: one look at the platform is not enough, and with +// no platform it fails within its 10 s, pressing nothing. +UnitTestResult test_start_check_needs_platform(CancellableScope& scope){ + FakeBackend backend = fake_plza({ + with_reading(look_at(0ms), PLATFORM_READING), + look_at(500ms), + }, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "on_platform")); + if (report.run.completed || report.run.failure.failure != "platform_not_seen"){ + return std::format("Expected platform_not_seen, got {}", to_string(report.run.failure)); + } + for (const std::string& input : backend.inputs()){ + if (input != "wait 300ms"){ + return std::format("Expected only waits, got {}", input); + } + } + return true; +} + +// A walk starts only on free control: platform_to_plaza on a text box +// waits for it, then fails with no input but its waits. +UnitTestResult test_walk_needs_free_control(CancellableScope& scope){ + FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::TEXT_BOX})}, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza")); + if (report.run.completed || report.run.failure.failure != "walk_not_free"){ + return std::format("Expected walk_not_free, got {}", to_string(report.run.failure)); + } + for (const std::string& input : backend.inputs()){ + if (input != "wait 250ms"){ + return std::format("Expected only waits, got {}", input); + } + } + return true; +} + +// platform_to_plaza: the first leg, the turn (L, the stick tapped at 90 +// degrees) and L again, then the last leg held in slices until the white +// fade. +UnitTestResult test_walk_ends_on_white_fade(CancellableScope& scope){ + FakeBackend backend = fake_plza({ + look_at(0ms), look_at(150ms), + look_at(12000ms), look_at(12250ms), look_at(12500ms, {EngineEvent::FADE_WHITE}), + }, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the walk to end on the white fade: {}", to_string(report.run.failure)); + } + return expect_inputs(backend, { + "wait 250ms", "hold north 4500ms walk", "press L", "stick 90deg 150ms walk, release 100ms", "press L", + "hold north 250ms walk", "hold north 250ms walk", "hold north 250ms walk", + }); +} + +// platform_to_plaza with no white fade fails once the last leg's 10 s are +// held: 40 slices. +UnitTestResult test_walk_fails_at_bound(CancellableScope& scope){ + FakeBackend backend = fake_plza({look_at(0ms)}, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza")); + if (report.run.completed || report.run.failure.failure != "walk_no_end"){ + return std::format("Expected walk_no_end, got {}", to_string(report.run.failure)); + } + const size_t slices = (size_t)std::count(backend.inputs().begin(), backend.inputs().end(), "hold north 250ms walk"); + if (slices != 40){ + return std::format("Expected 40 slices of 250 ms, held {}.", slices); + } + return true; +} + // A look at `at` facing `heading`, as the minimap reads it. Observation facing(Milliseconds at, int heading){ Observation look = look_at(at); @@ -166,6 +234,180 @@ UnitTestResult test_face_heading(CancellableScope& scope){ return expect_inputs(blind, {}); } +// Pancham cornered (text_to_choice): B through the text, done at the +// choice without pressing it. +UnitTestResult test_text_to_choice(CancellableScope& scope){ + const Observation choice = look_at(2000ms, {EngineEvent::TEXT_BOX, EngineEvent::CHOICE_BOX}); + FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::TEXT_BOX}), choice}, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "pancham_cornered")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the scene to end at the choice: {}", to_string(report.run.failure)); + } + return expect_inputs(backend, {"press B"}); +} + +// 01.01's arrival scenes (mash_to_move_hints): A at the text and at the +// choice (its top row), one blind A in a 20 s text-free flyover, done +// once the controls hint has shown a second. +UnitTestResult test_arrival_ends_on_controls_hint(CancellableScope& scope){ + FakeBackend backend = fake_plza({ + look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(1000ms), + look_at(21000ms), + look_at(22000ms, {EngineEvent::TEXT_BOX, EngineEvent::CHOICE_BOX}), + look_at(23000ms), + with_reading(look_at(24000ms), CONTROLS_HINT_READING), + with_reading(look_at(24500ms), CONTROLS_HINT_READING), + with_reading(look_at(25100ms), CONTROLS_HINT_READING), + }, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the scenes to end on the controls hint: {}", to_string(report.run.failure)); + } + const auto presses = std::count_if(backend.inputs().begin(), backend.inputs().end(), [](const std::string& input){ + return input.starts_with("press"); + }); + const auto a_presses = std::count(backend.inputs().begin(), backend.inputs().end(), "press A"); + if (presses != 3 || a_presses != 3){ + return std::format("Expected A at the text, once in the flyover and at the choice, got [{}].", joined(backend.inputs())); + } + return true; +} + +// 01.01's ad (run 2, 2026-11-10 13:28): subtitles with no box. A at each +// advance chevron, a blind A once nothing has shown for 5 s, none once +// the controls hint shows; done when it has shown a second. +// 01.02's battle area (console B, 2026-11-10 14:53): A at the text, a +// fade, then free control with only the "A: Talk" prompt, no controls +// hint. The prompt held a second ends the step; no press at it. +UnitTestResult test_battle_area_ends_on_interact_prompt(CancellableScope& scope){ + FakeBackend backend = fake_plza({ + look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(1000ms, {EngineEvent::FADE_BLACK}), + look_at(3000ms), + look_at(3250ms, {EngineEvent::INTERACT_PROMPT}), + look_at(3750ms, {EngineEvent::INTERACT_PROMPT}), + look_at(4300ms, {EngineEvent::INTERACT_PROMPT}), + }, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "battle_area")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the battle area to end on the interact prompt: {}", to_string(report.run.failure)); + } + std::vector presses; + std::copy_if(backend.inputs().begin(), backend.inputs().end(), std::back_inserter(presses), [](const std::string& input){ + return input.starts_with("press"); + }); + if (presses != std::vector{"press A"}){ + return std::format("Expected one A at the text, got [{}].", joined(backend.inputs())); + } + return true; +} + +UnitTestResult test_arrival_presses_through_the_ad(CancellableScope& scope){ + FakeBackend backend = fake_plza({ + look_at(0ms), + with_reading(look_at(1000ms), ADVANCE_ARROW_READING), + with_reading(look_at(2000ms), ADVANCE_ARROW_READING), + look_at(2500ms), + look_at(6000ms), + look_at(7100ms), + with_reading(look_at(8000ms), CONTROLS_HINT_READING), + with_reading(look_at(8500ms), CONTROLS_HINT_READING), + with_reading(look_at(9100ms), CONTROLS_HINT_READING), + }, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the ad to end on the controls hint: {}", to_string(report.run.failure)); + } + std::vector presses; + std::copy_if(backend.inputs().begin(), backend.inputs().end(), std::back_inserter(presses), [](const std::string& input){ + return input.starts_with("press"); + }); + if (presses != std::vector{"press A", "press A", "press A"}){ + return std::format("Expected A at the two chevrons and one blind A, got [{}].", joined(backend.inputs())); + } + return true; +} + +// 01.01's arrival (run 3, 2026-11-10 13:49): A at the last box, then the +// "MAIN MISSION 01" banner on two looks ends the step, which returns +// once the banner has gone, with no press at it. A banner still up after +// 10 s (01.03's "MAIN MISSION 02", console B 2026-11-10) gets A 3 times, +// then the step returns all the same. +UnitTestResult test_arrival_ends_on_mission_banner(CancellableScope& scope){ + for (const bool goes : {true, false}){ + std::vector> looks{ + look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(500ms), + with_reading(look_at(1000ms), MISSION_BANNER_READING), + with_reading(look_at(1250ms), MISSION_BANNER_READING), + with_reading(look_at(1500ms), MISSION_BANNER_READING), + }; + if (goes){ + looks.push_back(look_at(4000ms)); + } + FakeBackend backend = fake_plza(std::move(looks), scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the scenes to end on the mission banner: {}", to_string(report.run.failure)); + } + const auto presses = std::count_if(backend.inputs().begin(), backend.inputs().end(), [](const std::string& input){ + return input.starts_with("press"); + }); + const auto expected = goes ? 1 : 4; + if (presses != expected){ + return std::format("Expected {} A presses, got [{}].", expected, joined(backend.inputs())); + } + } + return true; +} + +// 01.03's after_andi (console B, 2026-11-10): A at the box, A at each +// look at the "MAIN MISSION 01 COMPLETE" card, then "MAIN MISSION 02" on +// two looks ends the step. A banner that goes by itself gets no press; one +// that stays past 10 s gets A 3 times. +UnitTestResult test_after_andi_presses_complete_card(CancellableScope& scope){ + for (const bool goes : {true, false}){ + std::vector> looks{ + look_at(0ms, {EngineEvent::TEXT_BOX}), + with_reading(look_at(500ms), MISSION_COMPLETE_READING), + with_reading(look_at(1000ms), MISSION_COMPLETE_READING), + look_at(1500ms), + with_reading(look_at(2000ms), MISSION_BANNER_READING), + with_reading(look_at(2250ms), MISSION_BANNER_READING), + }; + if (goes){ + looks.push_back(look_at(2500ms)); + } + FakeBackend backend = fake_plza(std::move(looks), scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.03", "after_andi")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected after_andi to end on the mission banner: {}", to_string(report.run.failure)); + } + const auto presses = std::count_if(backend.inputs().begin(), backend.inputs().end(), [](const std::string& input){ + return input.starts_with("press"); + }); + const auto expected = goes ? 3 : 6; + if (presses != expected){ + return std::format("Expected {} A presses (the box, the card twice, the banner if it stays), got [{}].", + expected, joined(backend.inputs())); + } + } + return true; +} + +// 01.01's arrival scenes: a minute with nothing busy and no controls hint +// (a text-free cutscene, or control the detectors miss) fails the step +// instead of taking it for control. +UnitTestResult test_arrival_quiet_fails(CancellableScope& scope){ + FakeBackend backend = fake_plza({look_at(0ms), look_at(30000ms), look_at(61000ms)}, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "arrival_scenes")); + if (report.verdict == Pokemon::CheckpointVerdict::PASSED || report.run.failure.failure != "scene_quiet"){ + return std::format("Expected a quiet minute to fail as scene_quiet, got {}", to_string(report.run.failure)); + } + return true; +} + // What PLZA refuses: console actions fail as console_only off a console, // and tile walks and unknown actions fail the lint. UnitTestResult test_refused_steps(CancellableScope& scope){ @@ -285,7 +527,18 @@ class Test_AutoStoryEngine : public UnitTest{ const EngineTestCase ENGINE_TEST_CASES[] = { {.input = {"01.00 opening: no presses, done on two looks at the platform after the autosave", test_opening_waits_for_platform}, .expectation = {}}, + {.input = {"01.01 start check: fails without the platform", test_start_check_needs_platform}, .expectation = {}}, + {.input = {"01.01 text_to_choice: B through the text, done at the choice", test_text_to_choice}, .expectation = {}}, + {.input = {"01.01 arrival_scenes: A through text and choice, done on the controls hint", test_arrival_ends_on_controls_hint}, .expectation = {}}, + {.input = {"01.01 arrival_scenes: A through the ad's boxless subtitles", test_arrival_presses_through_the_ad}, .expectation = {}}, + {.input = {"01.01 arrival_scenes: done on the mission banner once it has gone, A if it stays", test_arrival_ends_on_mission_banner}, .expectation = {}}, + {.input = {"01.03 after_andi: A at the mission complete card, then the banner, A if it stays", test_after_andi_presses_complete_card}, .expectation = {}}, + {.input = {"01.01 arrival_scenes: a quiet minute without the hint fails", test_arrival_quiet_fails}, .expectation = {}}, + {.input = {"01.02 battle_area: done on the \"A: Talk\" prompt", test_battle_area_ends_on_interact_prompt}, .expectation = {}}, {.input = {"face_heading: turns by the minimap's heading", test_face_heading}, .expectation = {}}, + {.input = {"01.01 platform_to_plaza: no walk without free control", test_walk_needs_free_control}, .expectation = {}}, + {.input = {"01.01 platform_to_plaza: ends on the white fade", test_walk_ends_on_white_fade}, .expectation = {}}, + {.input = {"01.01 platform_to_plaza: fails at its bound", test_walk_fails_at_bound}, .expectation = {}}, {.input = {"refused: console actions off a console, tile walks, unknown actions", test_refused_steps}, .expectation = {}}, {.input = {"every checkpoint runs in step order, testing never saves", test_every_checkpoint_runs}, .expectation = {}}, }; diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp index 8bedc6b145..3f47bd9151 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp @@ -73,6 +73,12 @@ const std::map>& console_game_actions(){ {"type_player_name", [](StoryEnv& env){ type_player_name(env.env.console, env.context, env.player_name); }}, {"choose_0", [](StoryEnv& env){ choose_dialog_option(env.env.console, env.context, 0); }}, {"choose_1", [](StoryEnv& env){ choose_dialog_option(env.env.console, env.context, 1); }}, + {"story_battle_start", [](StoryEnv& env){ + mash_scene(env.env.console, env.context, SceneMashGoal::BATTLE, BUTTON_A, 90s); + }}, + {"story_battle", [](StoryEnv& env){ + fight_battle_in_progress(env.env, env.env.console, env.context, env.battle_ai, 120s); + }}, }; return actions; } @@ -119,6 +125,15 @@ StoryActionSpec walk_spec(){ }); } +// "approach_starter": the walk to each starter, by the starter's key. +StoryActionSpec approach_starter_spec(){ + std::vector args; + for (StarterChoice starter : STARTER_CHOICES){ + args.push_back(legs_arg(std::string(starter_key(starter)), false, "the walk to this starter, as a walk's legs")); + } + return game_spec("approach_starter", std::move(args)); +} + // Builds the handlers. The console actions hold the console; without one @@ -126,8 +141,9 @@ StoryActionSpec walk_spec(){ // refuses them before their handler. class PlzaHandlers{ public: - explicit PlzaHandlers(StoryEnv* env) + PlzaHandlers(StoryEnv* env, StarterChoice starter) : m_env(env) + , m_starter(starter) { if (m_env != nullptr){ m_heading = heading_reader(*m_env); @@ -167,6 +183,22 @@ class PlzaHandlers{ }; } + // "approach_starter": the walk to the run's starter, from the arg of + // its name. A starter with no walk is not implemented. + Handler approach_starter() const{ + return [heading = m_heading, starter = m_starter]( + Pokemon::StoryBackend& backend, const StoryActionCall& call, Pokemon::RunState& state + ){ + const std::string_view key = starter_key(starter); + if (!call.args.contains(key)){ + return not_implemented("approach_starter", std::format( + "the walk to {}: only Chikorita's was recorded (console B, 2026-11-08).", key + ))(backend, call, state); + } + return walk_legs(backend, call.step.name, story_walk_move(call.args, key), call.args, heading); + }; + } + static Handler not_implemented(std::string name, std::string todo){ return [name = std::move(name), todo = std::move(todo)]( Pokemon::StoryBackend& backend, const StoryActionCall&, Pokemon::RunState& @@ -229,6 +261,7 @@ class PlzaHandlers{ } StoryEnv* m_env; + StarterChoice m_starter; // The compass for the walks; none without a console, where a look // carries its own heading. PlzaReader m_heading; @@ -314,6 +347,7 @@ using HandlerOf = Handler (*)(const PlzaHandlers& handlers); const std::map>& story_game_actions(){ static const std::map> actions{ {"walk", [](const PlzaHandlers& handlers){ return handlers.walk(); }}, + {"approach_starter", [](const PlzaHandlers& handlers){ return handlers.approach_starter(); }}, {"mash_to_move_hints", [](const PlzaHandlers&){ return PlzaHandlers::move_hints(); }}, {"text_to_choice", [](const PlzaHandlers&){ return PlzaHandlers::text_to_choice(); }}, {"wait_for_platform", [](const PlzaHandlers&){ return platform_handler(PlatformWait::PLATFORM_ONLY); }}, @@ -390,8 +424,8 @@ const Pokemon::StoryActionRegistry& spec_registry(){ } // PLZA's actions over `env` (none: no console), with no save or reload. -Pokemon::StoryGame plza_game_actions(StoryEnv* env){ - const PlzaHandlers handlers(env); +Pokemon::StoryGame plza_game_actions(StoryEnv* env, StarterChoice starter){ + const PlzaHandlers handlers(env, starter); Pokemon::StoryGame game; game.id = "plza"; for (StoryActionSpec& spec : plza_story_action_specs()){ @@ -432,6 +466,7 @@ std::vector plza_story_action_specs(){ specs.push_back(console_only(game_spec(name))); } specs.push_back(walk_spec()); + specs.push_back(approach_starter_spec()); for (const auto& [name, todo] : story_actions_not_implemented()){ specs.push_back(game_spec(name)); } @@ -471,9 +506,9 @@ StoryMove story_walk_move(const StoryActionArgs& args, std::string_view legs){ } Pokemon::StoryGame make_plza_story_game( - StoryEnv& env, std::set> autosave_rows + StoryEnv& env, StarterChoice starter, std::set> autosave_rows ){ - Pokemon::StoryGame game = plza_game_actions(&env); + Pokemon::StoryGame game = plza_game_actions(&env, starter); // Slow, and it throws without the minimap: never after a checkpoint. game.readers.push_back({ .name = std::string(Pokemon::STORY_HEADING), .supplies = {std::string(Pokemon::STORY_HEADING)}, @@ -501,8 +536,8 @@ Pokemon::StoryGame make_plza_story_game( return game; } -Pokemon::StoryGame make_offline_plza_story_game(){ - return plza_game_actions(nullptr); +Pokemon::StoryGame make_plza_story_game(StarterChoice starter){ + return plza_game_actions(nullptr, starter); } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h index 1e002aef02..db68334d4c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h @@ -51,14 +51,19 @@ const std::map>& story_actions_not_impleme // reads them; "end", "fade_white" or "fade_black"; "heading"), // walked once the screen shows free control // (check_can_walk()), until its end fade if it has one -// (walk_until()); the platform waits "wait_for_platform" and +// (walk_until()); "approach_starter" (args "chikorita", +// "tepig", "totodile", each a walk's legs: the run's starter's +// is walked as "walk" would, a starter with none is not +// implemented); the platform waits "wait_for_platform" and // "opening_to_platform"; the scene machines // "mash_to_move_hints" (args min_length_ms, quiet_ms) and // "text_to_choice" (run_scene_machine()); a console step, one // call through the game's own screens with no args: the new // game's "new_game_language", "pick_look", "type_player_name"; // "choose_0" / "choose_1" (that row of the choices on screen); -// or an action of story_actions_not_implemented() +// "story_battle_start" (A to the battle), "story_battle" +// (attack until a dialog shows); or an action of +// story_actions_not_implemented() // // Every action that works through the game's own screens is console_only. // BATTLE is the built-in "fight" (the backend's battle), SAVE the @@ -76,25 +81,26 @@ const std::vector& plza_story_specs(); // (plza_step_arg_errors(), PokemonLZA_AutoStoryStepValidator.h). std::vector plza_story_lint(const Pokemon::StoryCheckpoint& checkpoint); -// The walk of `args`: the legs of its arg `legs` ("legs" for a walk), each [turn in degrees clockwise +// The walk of `args`: the legs of its arg `legs` ("legs" for a walk, the +// starter's key for approach_starter), each [turn in degrees clockwise // (negative: left), walk ms], and its "heading", if any. The args must // have passed plza_story_lint(). StoryMove story_walk_move(const Pokemon::StoryActionArgs& args, std::string_view legs); // PLZA as a StoryGame on the console `env`, which must outlive it. -// The walks read the +// `starter` is the one approach_starter walks to; the walks read the // compass with heading_reader(). The save waits out the game's autosave at // the end of the checkpoints of `autosave_rows` (the run's // StoryData::autosaves) and saves through the menu after the others; the // reload resets the game from HOME. Pokemon::StoryGame make_plza_story_game( - StoryEnv& env, std::set> autosave_rows + StoryEnv& env, StarterChoice starter, std::set> autosave_rows ); // The same with no console, for tests and simulations: the console_only // actions fail as "console_only", the walks read the heading the looks // carry, and there is no save or reload. -Pokemon::StoryGame make_offline_plza_story_game(); +Pokemon::StoryGame make_plza_story_game(StarterChoice starter); diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp index 22f2a5cef0..58acefc711 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStorySceneMachine_Tests.cpp @@ -321,6 +321,33 @@ UnitTestResult test_to_battle(Logger&){ }); } +// platform_to_plaza is the walk that ends on an event (the white fade), +// and every walk that ends on one holds a last leg that walks. +UnitTestResult test_move_ends(Logger&){ + std::vector ending; + for (const Pokemon::StoryCheckpoint& row : story_checkpoints()){ + for (const Pokemon::StoryStep& step : row.steps){ + const auto end = step.args.find("end"); + if (step.action != "walk" || end == step.args.end()){ + continue; + } + ending.push_back(step.name); + const StoryMove move = story_walk_move(step.args, "legs"); + if (move.legs.empty() || move.legs.back().walk <= 0ms){ + return std::format("{}: its last leg has no walk to hold until the event.", step.name); + } + const std::string& fade = std::get(end->second); + if (fade != "fade_white" && fade != "fade_black"){ + return std::format("{}: ends on {}, not a fade.", step.name, fade); + } + } + } + if (ending != std::vector{"platform_to_plaza"}){ + return std::format("Expected only platform_to_plaza to end on an event, {} do.", ending.size()); + } + return true; +} + struct SceneMachineInput{ std::string name; @@ -405,6 +432,10 @@ const SceneMachineCase SCENE_MACHINE_CASES[] = { .input = {"what each state presses", test_state_actions}, .expectation = {}, }, + { + .input = {"walks that end on a fade", test_move_ends}, + .expectation = {}, + }, }; void add_tests_AutoStorySceneMachine(UnitTestDatabase& database){ diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp index f476c912cb..0236f5abcd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp @@ -49,9 +49,39 @@ void add_legs_errors(std::string_view step, std::string_view key, const IntegerR } } +// What is wrong with an "approach_starter" step's walks: it needs one. +std::vector starter_walk_errors(const Pokemon::StoryStep& step){ + std::vector errors; + bool any = false; + for (StarterChoice starter : STARTER_CHOICES){ + const auto legs = step.args.find(starter_key(starter)); + if (legs != step.args.end()){ + any = true; + add_legs_errors(step.name, legs->first, std::get(legs->second), errors); + } + } + if (!any){ + errors.push_back(std::format("{}: no walk to any starter", step.name)); + } + return errors; +} + } // namespace +// approach_starter's arg for each starter: the walk to it. +std::string_view starter_key(StarterChoice starter){ + switch (starter){ + case StarterChoice::CHIKORITA: + return "chikorita"; + case StarterChoice::TEPIG: + return "tepig"; + case StarterChoice::TOTODILE: + return "totodile"; + } + return ""; +} + // A walk's "end" arg as the event it ends on: a fade. std::optional walk_end_event(std::string_view end){ if (end == "fade_white"){ @@ -63,13 +93,16 @@ std::optional walk_end_event(std::string_view end){ return std::nullopt; } -// What is wrong with the args of a "walk" step; +// What is wrong with the args of a "walk" or "approach_starter" step; // nothing for any other step. std::vector plza_step_arg_errors(const Pokemon::StoryStep& step){ std::vector errors; if (step.kind != StoryStepKind::GAME){ return errors; } + if (step.action == "approach_starter"){ + return starter_walk_errors(step); + } if (step.action != "walk"){ return errors; } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h index 66013a5ec7..91f120d424 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h @@ -4,7 +4,7 @@ * * PLZA's checks of a story step's args beyond their types, which the * engine's lint (StoryActionRegistry::lint) checks: a walk's legs, its end - * fade and heading. + * fade, wait and heading, and approach_starter's walks. * */ @@ -24,11 +24,17 @@ namespace NintendoSwitch{ namespace PokemonLZA{ +// The starters, in the order approach_starter's args list them. +inline constexpr StarterChoice STARTER_CHOICES[] = {StarterChoice::CHIKORITA, StarterChoice::TEPIG, StarterChoice::TOTODILE}; + +// approach_starter's arg for `starter`: the walk to it ("chikorita"). +std::string_view starter_key(StarterChoice starter); + // A walk's "end" arg as the event it ends on: "fade_white" or // "fade_black"; nothing for any other name. std::optional walk_end_event(std::string_view end); -// What is wrong with the args of a "walk" step: +// What is wrong with the args of a "walk" or "approach_starter" step: // each leg a [turn, ms] pair, turning -180 to 180 degrees and walking 0 ms // or more, some leg walking; an end a fade, after a leg that walks; a // heading 0 to 359. Nothing for any other step. diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h index 9b03fe90bc..308ea9e64b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStoryFiles.h @@ -42,9 +42,9 @@ StoryData load_story_data(std::span dev_files); const StoryData& builtin_story_data(); // The built-in story (load_story_data() with no dev files), read once: -// what the tests, the lint and the program's dropdowns use: 01.00, a new -// game to the station platform, which starts on the title screen without -// a save. +// what the tests, the lint and the program's dropdowns use: 01.xx Main +// Mission 01 (new game, Pancham, the starter). Only 01.00, a new game, +// starts without a save; it starts on the title screen. const std::vector& story_checkpoints(); // The built-in rows that end on one of the game's autosaves. Each ends diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h index 4b0ff85830..244690b7d4 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable.h @@ -11,7 +11,8 @@ * legs: a relative turn and a walk time each (PokemonLZA_AutoStoryGame.h). * * Recorded 2026-11-08/09 on console B, played step by step from a new - * game. Every walk was measured walking, not dashing. Steps the game + * game through Main Mission 01. Every walk was measured walking, not + * dashing. Steps the game * has no code for yet are GAME steps of story_actions_not_implemented(). * * This is the story as data, with no IO: the checkpoint files it is read diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp index 7dd89b2ed6..f25bc3294e 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp @@ -53,6 +53,60 @@ UnitTestResult test_story_table_lints(Logger&){ return true; } +// The step `name` of checkpoint `id` in `checkpoints`; null if none. +const StoryStep* find_step(const std::vector& checkpoints, std::string_view id, std::string_view name){ + for (const StoryCheckpoint& row : checkpoints){ + for (const StoryStep& step : row.steps){ + if (row.id == id && step.name == name){ + return &step; + } + } + } + return nullptr; +} + +// `move`'s legs as [turn, ms] pairs, for messages and comparisons. +std::vector> leg_pairs(const StoryMove& move){ + std::vector> pairs; + for (const StoryWalkLeg& leg : move.legs){ + pairs.emplace_back((int)leg.turn, leg.walk.count()); + } + return pairs; +} + +// Every walk reads as a move with legs (its args passed the lint), and +// platform_to_plaza reads as recorded, ending on the white fade. +UnitTestResult test_story_walks_read(Logger&){ + size_t walks = 0; + for (const StoryCheckpoint& row : story_checkpoints()){ + for (const StoryStep& step : row.steps){ + if (step.kind != StoryStepKind::GAME || step.action != "walk"){ + continue; + } + walks++; + if (story_walk_move(step.args, "legs").legs.empty()){ + return std::format("{} {}: no legs.", row.id, step.name); + } + } + } + if (walks != 2){ + return std::format("Expected the 2 recorded walks, found {}.", walks); + } + const StoryStep* plaza = find_step(story_checkpoints(), "01.01", "platform_to_plaza"); + if (plaza == nullptr){ + return "Expected 01.01 platform_to_plaza."; + } + const std::vector> expected{{0, 4500}, {90, 10000}}; + if (leg_pairs(story_walk_move(plaza->args, "legs")) != expected){ + return "Expected platform_to_plaza's legs [[0, 4500], [90, 10000]]."; + } + const auto end = plaza->args.find("end"); + if (end == plaza->args.end() || std::get(end->second) != "fade_white"){ + return "Expected platform_to_plaza to end on the white fade."; + } + return true; +} + // Each action that is not implemented says what it waits for, is no move's // name, and is in a step. UnitTestResult test_not_implemented_actions(Logger&){ @@ -140,6 +194,100 @@ UnitTestResult test_scene_mash_rule(Logger&){ return true; } +// Chikorita's walk is recorded in 01.03's approach_starter, and only hers. +UnitTestResult test_starter_moves(Logger&){ + const StoryStep* approach = find_step(story_checkpoints(), "01.03", "approach_starter"); + if (approach == nullptr || approach->action != "approach_starter"){ + return "Expected 01.03 approach_starter."; + } + if (approach->args.contains("tepig") || approach->args.contains("totodile")){ + return "Expected only Chikorita's walk."; + } + if (!approach->args.contains("chikorita")){ + return "Expected the walk to Chikorita."; + } + const std::vector> expected{{-70, 750}}; + if (leg_pairs(story_walk_move(approach->args, "chikorita")) != expected){ + return "Expected Chikorita's walk [[-70, 750]]."; + } + return true; +} + +// The built-in text of checkpoint file `name` ("plza-01.02.plan"). +std::string builtin_text(std::string_view name){ + for (const auto& [file, text] : autostory_checkpoint_json()){ + if (file == name){ + return text; + } + } + return ""; +} + +// `text` with its first `from` replaced by `to`. +std::string replaced(std::string text, std::string_view from, std::string_view to){ + const size_t at = text.find(from); + if (at != std::string::npos){ + text.replace(at, from.size(), to); + } + return text; +} + +// The ParseException message of load_story_data() on the one dev file +// `text`; empty if it loads. +std::string dev_load_error(std::string_view name, std::string text){ + const StoryDevFile dev{.name = std::string(name), .path = std::format("/dev/{}", name), .text = std::move(text)}; + try{ + load_story_data(std::span(&dev, 1)); + }catch (ParseException& e){ + return e.message(); + } + return ""; +} + +// A dev file replaces the built-in checkpoint of its name and no other, +// and is named; a bad one (not JSON, a leg of 3 numbers, a negative walk, +// an unknown file, another id) fails naming its path. +UnitTestResult test_dev_override(Logger&){ + const std::string chase = builtin_text("plza-01.02.plan"); + const std::string_view legs = "[[-15, 4000], [-75, 3500]"; + if (chase.find(legs) == std::string::npos){ + return "Expected chase_pancham's legs in plza-01.02.plan.json."; + } + const StoryDevFile dev{ + .name = "plza-01.02.plan.json", .path = "/dev/plza-01.02.plan.json", + .text = replaced(chase, legs, "[[-15, 4200], [-75, 3500]"), + }; + const StoryData data = load_story_data(std::span(&dev, 1)); + if (data.dev_files.size() != 1 || data.dev_files[0].first != dev.name || data.dev_files[0].second != dev.path){ + return "Expected the dev file to be named with its path."; + } + if (data.checkpoints.size() != story_checkpoints().size() || data.autosaves != story_autosave_rows()){ + return "Expected the same rows and autosaves as the built-in story."; + } + const StoryStep* tuned = find_step(data.checkpoints, "01.02", "chase_pancham"); + if (tuned == nullptr || leg_pairs(story_walk_move(tuned->args, "legs")).front() != std::pair(-15, 4200)){ + return "Expected the dev file's first leg, [-15, 4200]."; + } + const StoryStep* plaza = find_step(data.checkpoints, "01.01", "platform_to_plaza"); + if (plaza == nullptr || leg_pairs(story_walk_move(plaza->args, "legs")).front() != std::pair(0, 4500)){ + return "Expected 01.01 to stay built-in."; + } + const std::pair bad[] = { + {"plza-01.02.plan.json", "{ not json"}, + {"plza-01.02.plan.json", replaced(chase, legs, "[[-15, 4000, 1], [-75, 3500]")}, + {"plza-01.02.plan.json", replaced(chase, legs, "[[-15, -4000], [-75, 3500]")}, + {"plza-09.99.plan.json", chase}, + {"plza-01.02.plan.json", replaced(chase, "\"01.02\"", "\"01.09\"")}, + }; + for (const auto& [name, text] : bad){ + const std::string error = dev_load_error(name, text); + if (error.find(std::format("/dev/{}", name)) == std::string::npos){ + return std::format("Expected {} to fail naming its path, got \"{}\".", name, error); + } + } + return true; +} + struct AutoStoryTableInput{ std::string name; @@ -180,10 +328,22 @@ const AutoStoryTableCase AUTO_STORY_TABLE_CASES[] = { .input = {"Story table: rows lint against PLZA's engine actions", test_story_table_lints}, .expectation = {}, }, + { + .input = {"Story table: every walk reads its legs", test_story_walks_read}, + .expectation = {}, + }, { .input = {"Story table: actions not implemented say what they wait for", test_not_implemented_actions}, .expectation = {}, }, + { + .input = {"Starters: the walk to Chikorita is recorded", test_starter_moves}, + .expectation = {}, + }, + { + .input = {"Dev checkpoints: replace the built-in file of their name, fail naming the file", test_dev_override}, + .expectation = {}, + }, { .input = {"Story table: the autosave rows, and 01.03 saves through the menu", test_autosave_rows}, .expectation = {}, diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json new file mode 100644 index 0000000000..a7068ab670 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json @@ -0,0 +1,45 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "01.01", + "title": "The platform to Main Mission 01", + "start": { + "map": "LumioseCity" + }, + "events": [ + { + "id": "on_platform", + "kind": "game_action", + "why": "start check: on the station platform with free control, as 01.00 ends", + "action": "wait_for_platform", + "args": { + "timeout_ms": 10000 + } + }, + { + "id": "platform_to_plaza", + "kind": "game_action", + "why": "steps 6-7: down the platform, then right until the white fade. Measured 2026-11-08 on console B, walk not run. Holds the last leg until the white fade into the arrival scenes; 6000 ms was the recorded walk, which overshot into it.", + "action": "walk", + "args": { + "legs": [[0, 4500], [90, 10000]], + "end": "fade_white" + } + }, + { + "id": "arrival_scenes", + "kind": "game_action", + "why": "steps 8-10: the white title card (~15 s), the text-free city flyover (~20 s), the starters and the girl, \"You're a tourist?\" (top choice), the ad, Pancham steals the bag; ends on the \"MAIN MISSION 01: get the bag back\" banner (once it has gone), or on the controls hint (free control)", + "action": "mash_to_move_hints" + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game" + } + }, + "execution": { + "save": "autosave" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json new file mode 100644 index 0000000000..99422172ed --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json @@ -0,0 +1,50 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "01.02", + "title": "Main Mission 01: chase Pancham to the battle area", + "start": { + "map": "LumioseCity" + }, + "events": [ + { + "id": "chase_pancham", + "kind": "game_action", + "why": "step 11: after Pancham, through the archway, around the starters into the scene. NEEDS TUNING. Measured 2026-11-08 on console B, walk not run. The sidestep around the starters had no time recorded: 1000 ms is a placeholder.", + "action": "walk", + "args": { + "legs": [[-15, 4000], [-75, 3500], [90, 9000], [-90, 0], [90, 1000], [-90, 4000]] + } + }, + { + "id": "pancham_cornered", + "kind": "game_action", + "why": "step 12: the scene up to its choice", + "action": "text_to_choice" + }, + { + "id": "battle_with_pokemon", + "kind": "game_action", + "why": "step 12: choose \"Battle with Pokemon!\" (second choice)", + "action": "choose_1" + }, + { + "id": "battle_area", + "kind": "game_action", + "why": "step 12: the scene until free control in the battle area; autosave", + "action": "mash_to_move_hints", + "args": { + "min_length_ms": 20000 + } + } + ], + "metadata": { + "phase": "testing", + "source": "console B recording, 2026-11-08/09: played step by step from a new game; split from 01.01 at the MAIN MISSION 01 autosave (2026-11-10)" + } + }, + "execution": { + "save": "autosave" + } +} diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json new file mode 100644 index 0000000000..71252a5e38 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json @@ -0,0 +1,52 @@ +{ + "format": "pokesim-authored-checkpoint/1", + "game": "plza", + "checkpoint": { + "id": "01.03", + "title": "Main Mission 01: the starter and Andi", + "start": { + "map": "LumioseCity" + }, + "events": [ + { + "id": "approach_starter", + "kind": "game_action", + "why": "step 13: walk up to the starter (only Chikorita's walk was recorded). Ends at the \"A Talk Chikorita\" prompt. Measured 2026-11-08 on console B and checked by hand from the autosave, walk not run as a story step. Only Chikorita's walk is recorded.", + "action": "approach_starter", + "args": { + "chikorita": [[-70, 750]] + } + }, + { + "id": "talk_to_starter", + "kind": "talk", + "why": "step 13: A at \"A Talk Chikorita\"" + }, + { + "id": "andi_battle_start", + "kind": "game_action", + "why": "steps 14-15: choose it, the pre-battle talk, \"Go! Chikorita!\", the battling tutorial", + "action": "story_battle_start" + }, + { + "id": "andi_battle", + "kind": "game_action", + "why": "step 16: beat Andi's Pancham (Lv 6), until Andi's speech", + "action": "story_battle" + }, + { + "id": "after_andi", + "kind": "game_action", + "why": "step 17: fist bump, night in the Battle Zone, the Main Mission 02 banner and its autosave; the MAIN MISSION 01 COMPLETE card waits for A (console B, 2026-11-10)", + "action": "mash_to_move_hints" + } + ], + "metadata": { + "phase": "verification", + "source": "console B recording, 2026-11-08/09: played step by step from a new game; split from 01.01 at the MAIN MISSION 01 autosave (2026-11-10); split from 01.02 at the battle area autosave (2026-11-10)" + } + }, + "execution": { + "save": "menu" + } +} From 7df8593d781065e44e4453c9207164f5e4878807 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 21:39:37 -0800 Subject: [PATCH 2/9] PokemonLZA: AutoStory: story battles press A until the first attack Moved down from plza/story-engine: fight_battle_in_progress() presses A on a dialog or a failed lock-on until its first attack lands, so the trainer's lines and tutorial cards before Taunie's battle (03.02) do not end the battle step. The char_pointer tag on StoryActionNotImplemented goes with it: code health counts it as attached to nothing once the line it covers is no longer new in the diff. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonLZA_AutoStoryActions.cpp | 12 ++++++++++-- .../AutoStory/Actions/PokemonLZA_AutoStoryActions.h | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp index 9590d82a58..65b02c2225 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.cpp @@ -86,10 +86,12 @@ void fight_battle_in_progress( BlueDialogDetector blue_dialog; TealDialogDetector teal_dialog; const WallClock deadline = current_time() + timeout; + bool attacked = false; while (true){ context.wait_for_all_requests(); const VideoSnapshot screen = console.video().snapshot(); - if (white_dialog.detect(screen) || blue_dialog.detect(screen) || teal_dialog.detect(screen)){ + const bool dialog = white_dialog.detect(screen) || blue_dialog.detect(screen) || teal_dialog.detect(screen); + if (dialog && attacked){ return; } if (current_time() > deadline){ @@ -99,7 +101,13 @@ void fight_battle_in_progress( console ); } - battle_state.attempt_one_attack(env, console, context); + if (dialog || !battle_state.attempt_one_attack(env, console, context)){ + if (!attacked){ + pbf_press_button(context, BUTTON_A, 160ms, 400ms); + } + continue; + } + attacked = true; } } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h index 19de9d6798..9e1272accf 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryActions.h @@ -36,7 +36,6 @@ class StoryActionNotImplemented : public OperationFailedException{ public: explicit StoryActionNotImplemented(std::string message); - // code-health: allow char_pointer -- the exception base class's name() returns const char* virtual const char* name() const override{ return "StoryActionNotImplemented"; } @@ -52,9 +51,12 @@ void fight_battle( BattleAIOption& battle_ai ); -// In a battle that is already on screen: attacks with TrainerBattleState -// until a dialog box shows (the speech after a win or a loss). For story -// battles, which show no Run prompt for fight_battle() to start on. +// A story battle, from the talk before it: attacks with TrainerBattleState +// until a dialog box shows (the speech after a win or a loss). Until the +// first attack lands, a dialog box or a failed lock-on gets A instead: the +// trainer's lines, the challenge cutscene's subtitle (no text box) and +// tutorial cards (Taunie's battle in 03.02, console B 2026-11-10). For +// story battles, which show no Run prompt for fight_battle() to start on. // Throws OperationFailedException after `timeout`. void fight_battle_in_progress( ProgramEnvironment& env, ConsoleHandle& console, ProControllerContext& context, From 35a5ab0cd4b7ca787a03e4902c7f3fff646f022a Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 10 Nov 2026 22:11:29 -0800 Subject: [PATCH 3/9] PokemonLZA: AutoStory: 01.xx starts are places, starter walks are TIMED_LEGS Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp | 2 +- .../Programs/AutoStory/StoryData/plza-01.01.plan.json | 2 +- .../Programs/AutoStory/StoryData/plza-01.02.plan.json | 2 +- .../Programs/AutoStory/StoryData/plza-01.03.plan.json | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp index c853ef799a..b476583a94 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp @@ -53,7 +53,7 @@ std::vector starter_walk_errors(const Pokemon::StoryStep& step){ const auto legs = step.args.find(starter_key(starter)); if (legs != step.args.end()){ any = true; - add_legs_errors(step.name, legs->first, std::get(legs->second), errors); + add_legs_errors(step.name, legs->first, std::get(legs->second), errors); } } if (!any){ diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json index a7068ab670..92358ddafb 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.01.plan.json @@ -5,7 +5,7 @@ "id": "01.01", "title": "The platform to Main Mission 01", "start": { - "map": "LumioseCity" + "place": "LumioseCity" }, "events": [ { diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json index 99422172ed..ba7f82720c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json @@ -5,7 +5,7 @@ "id": "01.02", "title": "Main Mission 01: chase Pancham to the battle area", "start": { - "map": "LumioseCity" + "place": "LumioseCity" }, "events": [ { diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json index 71252a5e38..36bd3ff2ab 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.03.plan.json @@ -5,7 +5,7 @@ "id": "01.03", "title": "Main Mission 01: the starter and Andi", "start": { - "map": "LumioseCity" + "place": "LumioseCity" }, "events": [ { From bc9d8277d82e3968429ee416254bde1bb577da24 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 08:07:57 -0800 Subject: [PATCH 4/9] PokemonLZA AutoStory: test that 01.02's chase walks the same path after 01.01's scenes (red) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonLZA_AutoStoryEngine_Tests.cpp | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp index 7872f8765a..9f21a424a7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp @@ -8,6 +8,8 @@ */ #include +#include +#include #include #include #include @@ -234,6 +236,77 @@ UnitTestResult test_face_heading(CancellableScope& scope){ return expect_inputs(blind, {}); } +// A forward hold of a walk: the way it went, clockwise from north, and +// for how long. +struct WalkedLeg{ + int heading; + int64_t ms; + + bool operator==(const WalkedLeg&) const = default; +}; + +std::string walked_text(const std::vector& path){ + std::string text; + for (const WalkedLeg& leg : path){ + text += std::format("{}[{} deg, {} ms]", text.empty() ? "" : ", ", leg.heading, leg.ms); + } + return text; +} + +int normalized_heading(double degrees){ + return (((int)std::lround(degrees) % 360) + 360) % 360; +} + +// Where a walk's inputs take the player who starts facing `player` with +// the camera looking `camera` (clockwise from north): L puts the camera +// behind the player, a stick tap turns the player that far from where the +// camera looks, and a forward hold walks where the camera looks. Other +// inputs move nobody. +std::vector walked_path(const std::vector& inputs, double player, double camera){ + constexpr std::string_view STICK = "stick "; + constexpr std::string_view HOLD = "hold north "; + std::vector path; + for (const std::string& input : inputs){ + if (input == "press L"){ + camera = player; + }else if (input.starts_with(STICK)){ + player = camera + std::stod(input.substr(STICK.size())); + }else if (input.starts_with(HOLD)){ + player = camera; + path.push_back({.heading = normalized_heading(camera), .ms = std::stoll(input.substr(HOLD.size()))}); + } + } + return path; +} + +// 01.02's chase walks the same way from its save and after 01.01's +// arrival scenes. A save load puts the camera behind the player; the +// scenes end with the camera looking the same way but the player turned +// to the right, to the boy (console B, 2026-11-13: the chained run set +// off the wrong way). The walk's first turn is taken from the camera, so +// the player's facing at the start does not rotate the walk. From the +// save it walks as recorded. +UnitTestResult test_chase_starts_from_camera(CancellableScope& scope){ + FakeBackend backend = fake_plza({look_at(0ms)}, scope); + const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "chase_pancham")); + if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ + return std::format("Expected the chase to walk: {}", to_string(report.run.failure)); + } + const std::vector from_save = walked_path(backend.inputs(), 0, 0); + const std::vector recorded = {{345, 4000}, {270, 3500}, {0, 9000}, {0, 1000}, {270, 4000}}; + if (from_save != recorded){ + return std::format("From the save, expected [{}], walked [{}].", walked_text(recorded), walked_text(from_save)); + } + const std::vector after_scenes = walked_path(backend.inputs(), 90, 0); + if (after_scenes != from_save){ + return std::format( + "After the scenes, expected the save's path [{}], walked [{}].", + walked_text(from_save), walked_text(after_scenes) + ); + } + return true; +} + // Pancham cornered (text_to_choice): B through the text, done at the // choice without pressing it. UnitTestResult test_text_to_choice(CancellableScope& scope){ @@ -536,6 +609,7 @@ const EngineTestCase ENGINE_TEST_CASES[] = { {.input = {"01.01 arrival_scenes: a quiet minute without the hint fails", test_arrival_quiet_fails}, .expectation = {}}, {.input = {"01.02 battle_area: done on the \"A: Talk\" prompt", test_battle_area_ends_on_interact_prompt}, .expectation = {}}, {.input = {"face_heading: turns by the minimap's heading", test_face_heading}, .expectation = {}}, + {.input = {"01.02 chase_pancham: the same path from the save and after 01.01's scenes", test_chase_starts_from_camera}, .expectation = {}}, {.input = {"01.01 platform_to_plaza: no walk without free control", test_walk_needs_free_control}, .expectation = {}}, {.input = {"01.01 platform_to_plaza: ends on the white fade", test_walk_ends_on_white_fade}, .expectation = {}}, {.input = {"01.01 platform_to_plaza: fails at its bound", test_walk_fails_at_bound}, .expectation = {}}, From 4432c5b5ba5e7ee7ed89a05b302f0205428e301d Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 08:11:43 -0800 Subject: [PATCH 5/9] PokemonLZA AutoStory: 01.02's chase turns first from the camera, not the player Run after 01.01, the chase set off the wrong way (console B, 2026-11-13): 01.01's scenes end with the camera looking the same way as after the save load, but the player turned right to the boy, and the chase's L-then-tap turn is relative to the player. Main Mission 01 has no minimap, so no compass heading can be read. A walk's new "first_turn": "camera" arg taps its first turn without the L before it; from the save, where the camera is behind the player, the inputs walk the same path as before. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonLZA_AutoStoryMoves.cpp | 9 +++++++-- .../Actions/PokemonLZA_AutoStoryMoves.h | 20 +++++++++++++++++-- .../AutoStory/PokemonLZA_AutoStoryBackend.cpp | 4 ++++ .../AutoStory/PokemonLZA_AutoStoryBackend.h | 5 +++++ .../AutoStory/PokemonLZA_AutoStoryGame.cpp | 8 ++++++++ .../AutoStory/PokemonLZA_AutoStoryGame.h | 3 ++- .../PokemonLZA_AutoStoryStepValidator.cpp | 17 ++++++++++++++++ .../PokemonLZA_AutoStoryStepValidator.h | 8 +++++++- .../AutoStory/StoryData/plza-01.02.plan.json | 5 +++-- 9 files changed, 71 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp index 5e4ab653b9..7631696b35 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp @@ -58,10 +58,15 @@ Pokemon::Outcome run_story_move(PlzaBackend& backend, const StoryMove& move, con return faced; } } - for (const StoryWalkLeg& leg : move.legs){ + for (size_t i = 0; i < move.legs.size(); i++){ + const StoryWalkLeg& leg = move.legs[i]; if (leg.turn != 0){ + if (i == 0 && move.first_turn_from == FirstTurnFrom::CAMERA){ + story_turn_from_camera(backend, leg.turn); + }else{ + story_turn(backend, leg.turn); + } // The walk goes where the camera looks: recenter it after the turn. - story_turn(backend, leg.turn); backend.press(BUTTON_L, 100ms, 150ms); } if (leg.walk > Milliseconds(0)){ diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h index ca2cc313f3..6b72aeff1d 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h @@ -38,6 +38,20 @@ struct StoryWalkLeg{ Milliseconds walk = Milliseconds(0); }; +// What a walk's first turn is measured from. +enum class FirstTurnFrom{ + // Where the player faces: L recenters the camera behind the player + // first, as before every later turn. + PLAYER, + // Where the camera looks as the walk starts: no L before the first + // turn. For a walk whose start is reached two ways that leave the + // camera looking the same way but the player facing different ways, + // where no minimap gives a heading: Main Mission 01 has none, and its + // scenes end with the player turned to whoever spoke last, while a + // save load puts the camera behind the player. + CAMERA, +}; + // A walk in the overworld. Lumiose has no tiles: a move is an optional // compass heading to face first, then legs of turns and timed walks, as // recorded on the console. @@ -45,6 +59,7 @@ struct StoryMove{ // Clockwise from north, as the minimap's arrow reads it // (get_facing_direction()). None: no compass turn first. std::optional heading = std::nullopt; + FirstTurnFrom first_turn_from = FirstTurnFrom::PLAYER; std::vector legs = {}; }; @@ -57,8 +72,9 @@ struct StoryMove{ Pokemon::Outcome face_heading(PlzaBackend& backend, const PlzaReader& reader, double heading, double tolerance); // From the overworld, walks as `move` says: faces its heading first, if it -// has one, then each leg's turn (and L to recenter the camera, since the -// walk goes where it looks) and walk. Nothing is read on the way: a leg +// has one, then each leg's turn (the first from where first_turn_from +// says) and L to recenter the camera, since the walk goes where it looks, +// and walk. Nothing is read on the way: a leg // that is cut short or blocked goes unnoticed, and a step that needs a // prompt after the walk fails there instead. `heading` reads the compass // (face_heading()). diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp index 1889706437..3d972a5839 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp @@ -167,6 +167,10 @@ void story_turn(PlzaBackend& backend, double degrees){ // 150 ms is the tap the story was recorded with (console B, 2026-11-08). // Short releases: the legs run back to back, as when played by hand. backend.press(BUTTON_L, 100ms, 150ms); + story_turn_from_camera(backend, degrees); +} + +void story_turn_from_camera(PlzaBackend& backend, double degrees){ backend.stick(degrees, 150ms, 100ms, Pokemon::StoryPace::WALK); } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h index fa414762cc..07073a97d8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h @@ -73,6 +73,11 @@ using PlzaReader = Pokemon::StoryReader; // then the stick is tapped that way for 150 ms. The tap also takes a step. void story_turn(PlzaBackend& backend, double degrees); +// Turns the player `degrees` clockwise of where the camera looks, without +// recentering it first: the stick tapped that way for 150 ms, as in +// story_turn(). +void story_turn_from_camera(PlzaBackend& backend, double degrees); + // The STORY_HEADING reading for the console: the minimap's arrow // (get_facing_direction()), clockwise from north in [0, 360). It waits up // to 40 s for the minimap and throws without it, so its StoryGameReader diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp index f71ff9e7d5..9bf3795a61 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp @@ -124,6 +124,10 @@ StoryActionSpec walk_spec(){ .key = "heading", .type = StoryArgType::INTEGER, .required = false, .fallback = std::nullopt, .why = "the compass heading to face first, clockwise from north", }, + StoryArgSpec{ + .key = "first_turn", .type = StoryArgType::WORD, .required = false, .fallback = std::nullopt, + .why = "\"camera\": the first leg turns from where the camera looks, not the player (no L first)", + }, }); } @@ -504,6 +508,10 @@ StoryMove story_walk_move(const StoryActionArgs& args, std::string_view legs){ if (heading != args.end()){ move.heading = (double)std::get(heading->second); } + const auto first_turn = args.find("first_turn"); + if (first_turn != args.end()){ + move.first_turn_from = walk_first_turn(std::get(first_turn->second)).value_or(FirstTurnFrom::PLAYER); + } for (const Pokemon::StoryTimedLeg& row : Pokemon::story_arg(args, legs)){ move.legs.push_back({.turn = (double)row.turn, .walk = Milliseconds(row.ms)}); } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h index bbfd05c96c..12a4611fcd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h @@ -48,7 +48,8 @@ const std::map>& story_actions_not_impleme // MASH "mash" B through the text until the overworld is back // MASH "a" A through it // GAME "walk" (args "legs", [[turn, ms], ...] as story_walk_move() -// reads them; "end", "fade_white" or "fade_black"; "heading"), +// reads them; "end", "fade_white" or "fade_black"; "heading"; +// "first_turn", "player" or "camera"), // walked once the screen shows free control // (check_can_walk()), until its end fade if it has one // (walk_until()); "approach_starter" (args "chikorita", diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp index d4293f605c..6ff7e83b72 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp @@ -89,6 +89,16 @@ std::optional walk_end_event(std::string_view en return std::nullopt; } +std::optional walk_first_turn(std::string_view name){ + if (name == "player"){ + return FirstTurnFrom::PLAYER; + } + if (name == "camera"){ + return FirstTurnFrom::CAMERA; + } + return std::nullopt; +} + // What is wrong with the args of a "walk" or "approach_starter" step; // nothing for any other step. std::vector plza_step_arg_errors(const Pokemon::StoryStep& step){ @@ -125,6 +135,13 @@ std::vector plza_step_arg_errors(const Pokemon::StoryStep& step){ errors.push_back(std::format("{}: heading {} deg, expected 0 to 359", step.name, degrees)); } } + const auto first_turn = step.args.find("first_turn"); + if (first_turn != step.args.end()){ + const std::string& name = std::get(first_turn->second); + if (!walk_first_turn(name)){ + errors.push_back(std::format("{}: first_turn {} is not \"player\" or \"camera\"", step.name, name)); + } + } return errors; } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h index 2206d77d8c..37e39a65c8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h @@ -17,6 +17,7 @@ #include #include "CommonTools/ScreenMachine/ScreenObservation.h" #include "Pokemon/AutoStory/Types/Pokemon_StoryStep.h" +#include "VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h" #include "PokemonLZA_AutoStoryBackend.h" namespace PokemonAutomation{ @@ -34,10 +35,15 @@ std::string_view starter_key(StarterChoice starter); // "fade_black"; nothing for any other name. std::optional walk_end_event(std::string_view end); +// A walk's "first_turn" arg as what its first turn is measured from: +// "player" or "camera"; nothing for any other name. +std::optional walk_first_turn(std::string_view name); + // What is wrong with the args of a "walk" or "approach_starter" step: // each leg a [turn, ms] pair, turning -180 to 180 degrees and walking 0 ms // or more, some leg walking; an end a fade, after a leg that walks; a -// heading 0 to 359. Nothing for any other step. +// heading 0 to 359; a first turn "player" or "camera". Nothing for any +// other step. std::vector plza_step_arg_errors(const Pokemon::StoryStep& step); diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json index ba7f82720c..5fef5ecbb2 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json @@ -11,10 +11,11 @@ { "id": "chase_pancham", "kind": "game_action", - "why": "step 11: after Pancham, through the archway, around the starters into the scene. NEEDS TUNING. Measured 2026-11-08 on console B, walk not run. The sidestep around the starters had no time recorded: 1000 ms is a placeholder.", + "why": "step 11: after Pancham, through the archway, around the starters into the scene. NEEDS TUNING. Measured 2026-11-08 on console B, walk not run. The sidestep around the starters had no time recorded: 1000 ms is a placeholder. The first turn is from the camera: from the save the camera is behind the player, while 01.01's scenes end with the camera looking the same way (Prism Tower ahead) but the player turned right to the boy, so a turn from the player set off the wrong way (console B, 2026-11-13). Main Mission 01 has no minimap for a heading.", "action": "walk", "args": { - "legs": [[-15, 4000], [-75, 3500], [90, 9000], [-90, 0], [90, 1000], [-90, 4000]] + "legs": [[-15, 4000], [-75, 3500], [90, 9000], [-90, 0], [90, 1000], [-90, 4000]], + "first_turn": "camera" } }, { From 68aa1e6733f84f231c438d69e85dc99314ea16c6 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 12:11:18 -0800 Subject: [PATCH 6/9] PokemonLZA AutoStory: 01.02 reloads its save when run after 01.01 Reverts 4432c5b5b and its test bc9d8277d: from a reload, both ways into 01.02 start from the same save, so the chase's first turn is from the player again (L first), as recorded and as it passed from the save (console B, 2026-11-13 08:03; the camera turn passed from the save at 12:02 too, but went the wrong way after 01.01's scenes at 11:56). 01.02's execution says reload_when_chained: a run from 01.01 reloads 01.01's end autosave, the save 01.02 starts from, before the chase. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Actions/PokemonLZA_AutoStoryMoves.cpp | 9 +-- .../Actions/PokemonLZA_AutoStoryMoves.h | 20 +---- .../AutoStory/PokemonLZA_AutoStoryBackend.cpp | 4 - .../AutoStory/PokemonLZA_AutoStoryBackend.h | 5 -- .../PokemonLZA_AutoStoryEngine_Tests.cpp | 74 ------------------- .../AutoStory/PokemonLZA_AutoStoryGame.cpp | 8 -- .../AutoStory/PokemonLZA_AutoStoryGame.h | 3 +- .../PokemonLZA_AutoStoryStepValidator.cpp | 17 ----- .../PokemonLZA_AutoStoryStepValidator.h | 8 +- .../PokemonLZA_AutoStoryTable_Tests.cpp | 18 +++++ .../AutoStory/StoryData/plza-01.02.plan.json | 8 +- 11 files changed, 28 insertions(+), 146 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp index 7631696b35..5e4ab653b9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.cpp @@ -58,15 +58,10 @@ Pokemon::Outcome run_story_move(PlzaBackend& backend, const StoryMove& move, con return faced; } } - for (size_t i = 0; i < move.legs.size(); i++){ - const StoryWalkLeg& leg = move.legs[i]; + for (const StoryWalkLeg& leg : move.legs){ if (leg.turn != 0){ - if (i == 0 && move.first_turn_from == FirstTurnFrom::CAMERA){ - story_turn_from_camera(backend, leg.turn); - }else{ - story_turn(backend, leg.turn); - } // The walk goes where the camera looks: recenter it after the turn. + story_turn(backend, leg.turn); backend.press(BUTTON_L, 100ms, 150ms); } if (leg.walk > Milliseconds(0)){ diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h index 6b72aeff1d..ca2cc313f3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h @@ -38,20 +38,6 @@ struct StoryWalkLeg{ Milliseconds walk = Milliseconds(0); }; -// What a walk's first turn is measured from. -enum class FirstTurnFrom{ - // Where the player faces: L recenters the camera behind the player - // first, as before every later turn. - PLAYER, - // Where the camera looks as the walk starts: no L before the first - // turn. For a walk whose start is reached two ways that leave the - // camera looking the same way but the player facing different ways, - // where no minimap gives a heading: Main Mission 01 has none, and its - // scenes end with the player turned to whoever spoke last, while a - // save load puts the camera behind the player. - CAMERA, -}; - // A walk in the overworld. Lumiose has no tiles: a move is an optional // compass heading to face first, then legs of turns and timed walks, as // recorded on the console. @@ -59,7 +45,6 @@ struct StoryMove{ // Clockwise from north, as the minimap's arrow reads it // (get_facing_direction()). None: no compass turn first. std::optional heading = std::nullopt; - FirstTurnFrom first_turn_from = FirstTurnFrom::PLAYER; std::vector legs = {}; }; @@ -72,9 +57,8 @@ struct StoryMove{ Pokemon::Outcome face_heading(PlzaBackend& backend, const PlzaReader& reader, double heading, double tolerance); // From the overworld, walks as `move` says: faces its heading first, if it -// has one, then each leg's turn (the first from where first_turn_from -// says) and L to recenter the camera, since the walk goes where it looks, -// and walk. Nothing is read on the way: a leg +// has one, then each leg's turn (and L to recenter the camera, since the +// walk goes where it looks) and walk. Nothing is read on the way: a leg // that is cut short or blocked goes unnoticed, and a step that needs a // prompt after the walk fails there instead. `heading` reads the compass // (face_heading()). diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp index 3d972a5839..1889706437 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.cpp @@ -167,10 +167,6 @@ void story_turn(PlzaBackend& backend, double degrees){ // 150 ms is the tap the story was recorded with (console B, 2026-11-08). // Short releases: the legs run back to back, as when played by hand. backend.press(BUTTON_L, 100ms, 150ms); - story_turn_from_camera(backend, degrees); -} - -void story_turn_from_camera(PlzaBackend& backend, double degrees){ backend.stick(degrees, 150ms, 100ms, Pokemon::StoryPace::WALK); } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h index 07073a97d8..fa414762cc 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryBackend.h @@ -73,11 +73,6 @@ using PlzaReader = Pokemon::StoryReader; // then the stick is tapped that way for 150 ms. The tap also takes a step. void story_turn(PlzaBackend& backend, double degrees); -// Turns the player `degrees` clockwise of where the camera looks, without -// recentering it first: the stick tapped that way for 150 ms, as in -// story_turn(). -void story_turn_from_camera(PlzaBackend& backend, double degrees); - // The STORY_HEADING reading for the console: the minimap's arrow // (get_facing_direction()), clockwise from north in [0, 360). It waits up // to 40 s for the minimap and throws without it, so its StoryGameReader diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp index e046fe54d9..42665f0d13 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp @@ -8,8 +8,6 @@ */ #include -#include -#include #include #include #include @@ -266,77 +264,6 @@ UnitTestResult test_face_heading(CancellableScope& scope){ return expect_inputs(blind, {}); } -// A forward hold of a walk: the way it went, clockwise from north, and -// for how long. -struct WalkedLeg{ - int heading; - int64_t ms; - - bool operator==(const WalkedLeg&) const = default; -}; - -std::string walked_text(const std::vector& path){ - std::string text; - for (const WalkedLeg& leg : path){ - text += std::format("{}[{} deg, {} ms]", text.empty() ? "" : ", ", leg.heading, leg.ms); - } - return text; -} - -int normalized_heading(double degrees){ - return (((int)std::lround(degrees) % 360) + 360) % 360; -} - -// Where a walk's inputs take the player who starts facing `player` with -// the camera looking `camera` (clockwise from north): L puts the camera -// behind the player, a stick tap turns the player that far from where the -// camera looks, and a forward hold walks where the camera looks. Other -// inputs move nobody. -std::vector walked_path(const std::vector& inputs, double player, double camera){ - constexpr std::string_view STICK = "stick "; - constexpr std::string_view HOLD = "hold north "; - std::vector path; - for (const std::string& input : inputs){ - if (input == "press L"){ - camera = player; - }else if (input.starts_with(STICK)){ - player = camera + std::stod(input.substr(STICK.size())); - }else if (input.starts_with(HOLD)){ - player = camera; - path.push_back({.heading = normalized_heading(camera), .ms = std::stoll(input.substr(HOLD.size()))}); - } - } - return path; -} - -// 01.02's chase walks the same way from its save and after 01.01's -// arrival scenes. A save load puts the camera behind the player; the -// scenes end with the camera looking the same way but the player turned -// to the right, to the boy (console B, 2026-11-13: the chained run set -// off the wrong way). The walk's first turn is taken from the camera, so -// the player's facing at the start does not rotate the walk. From the -// save it walks as recorded. -UnitTestResult test_chase_starts_from_camera(CancellableScope& scope){ - FakeBackend backend = fake_plza({look_at(0ms)}, scope); - const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "chase_pancham")); - if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ - return std::format("Expected the chase to walk: {}", to_string(report.run.failure)); - } - const std::vector from_save = walked_path(backend.inputs(), 0, 0); - const std::vector recorded = {{345, 4000}, {270, 3500}, {0, 9000}, {0, 1000}, {270, 4000}}; - if (from_save != recorded){ - return std::format("From the save, expected [{}], walked [{}].", walked_text(recorded), walked_text(from_save)); - } - const std::vector after_scenes = walked_path(backend.inputs(), 90, 0); - if (after_scenes != from_save){ - return std::format( - "After the scenes, expected the save's path [{}], walked [{}].", - walked_text(from_save), walked_text(after_scenes) - ); - } - return true; -} - // Pancham cornered (text_to_choice): B through the text, done at the // choice without pressing it. UnitTestResult test_text_to_choice(CancellableScope& scope){ @@ -746,7 +673,6 @@ const EngineTestCase ENGINE_TEST_CASES[] = { {.input = {"01.01 arrival_scenes: a quiet minute without the hint fails", test_arrival_quiet_fails}, .expectation = {}}, {.input = {"01.02 battle_area: done on the \"A: Talk\" prompt", test_battle_area_ends_on_interact_prompt}, .expectation = {}}, {.input = {"face_heading: turns by the minimap's heading", test_face_heading}, .expectation = {}}, - {.input = {"01.02 chase_pancham: the same path from the save and after 01.01's scenes", test_chase_starts_from_camera}, .expectation = {}}, {.input = {"01.01 platform_to_plaza: no walk without free control", test_walk_needs_free_control}, .expectation = {}}, {.input = {"01.01 platform_to_plaza: ends on the white fade", test_walk_ends_on_white_fade}, .expectation = {}}, {.input = {"01.01 platform_to_plaza: fails at its bound", test_walk_fails_at_bound}, .expectation = {}}, diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp index 3e99d4fe7f..9b34904689 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.cpp @@ -128,10 +128,6 @@ StoryActionSpec walk_spec(){ .key = "heading", .type = StoryArgType::INTEGER, .required = false, .fallback = std::nullopt, .why = "the compass heading to face first, clockwise from north", }, - StoryArgSpec{ - .key = "first_turn", .type = StoryArgType::WORD, .required = false, .fallback = std::nullopt, - .why = "\"camera\": the first leg turns from where the camera looks, not the player (no L first)", - }, }); } @@ -527,10 +523,6 @@ StoryMove story_walk_move(const StoryActionArgs& args, std::string_view legs){ if (heading != args.end()){ move.heading = (double)std::get(heading->second); } - const auto first_turn = args.find("first_turn"); - if (first_turn != args.end()){ - move.first_turn_from = walk_first_turn(std::get(first_turn->second)).value_or(FirstTurnFrom::PLAYER); - } for (const Pokemon::StoryTimedLeg& row : Pokemon::story_arg(args, legs)){ move.legs.push_back({.turn = (double)row.turn, .walk = Milliseconds(row.ms)}); } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h index d62bd24910..3dd49fdfba 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryGame.h @@ -51,8 +51,7 @@ const std::map>& story_actions_not_impleme // MASH "mash" B through the text until the overworld is back // MASH "a" A through it // GAME "walk" (args "legs", [[turn, ms], ...] as story_walk_move() -// reads them; "end", "fade_white" or "fade_black"; "heading"; -// "first_turn", "player" or "camera"), +// reads them; "end", "fade_white" or "fade_black"; "heading"), // walked once the screen shows free control // (check_can_walk()), until its end fade if it has one // (walk_until()); "approach_starter" (args "chikorita", diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp index 6ff7e83b72..d4293f605c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.cpp @@ -89,16 +89,6 @@ std::optional walk_end_event(std::string_view en return std::nullopt; } -std::optional walk_first_turn(std::string_view name){ - if (name == "player"){ - return FirstTurnFrom::PLAYER; - } - if (name == "camera"){ - return FirstTurnFrom::CAMERA; - } - return std::nullopt; -} - // What is wrong with the args of a "walk" or "approach_starter" step; // nothing for any other step. std::vector plza_step_arg_errors(const Pokemon::StoryStep& step){ @@ -135,13 +125,6 @@ std::vector plza_step_arg_errors(const Pokemon::StoryStep& step){ errors.push_back(std::format("{}: heading {} deg, expected 0 to 359", step.name, degrees)); } } - const auto first_turn = step.args.find("first_turn"); - if (first_turn != step.args.end()){ - const std::string& name = std::get(first_turn->second); - if (!walk_first_turn(name)){ - errors.push_back(std::format("{}: first_turn {} is not \"player\" or \"camera\"", step.name, name)); - } - } return errors; } diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h index 37e39a65c8..2206d77d8c 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryStepValidator.h @@ -17,7 +17,6 @@ #include #include "CommonTools/ScreenMachine/ScreenObservation.h" #include "Pokemon/AutoStory/Types/Pokemon_StoryStep.h" -#include "VideoGames/PokemonLZA/Programs/AutoStory/Actions/PokemonLZA_AutoStoryMoves.h" #include "PokemonLZA_AutoStoryBackend.h" namespace PokemonAutomation{ @@ -35,15 +34,10 @@ std::string_view starter_key(StarterChoice starter); // "fade_black"; nothing for any other name. std::optional walk_end_event(std::string_view end); -// A walk's "first_turn" arg as what its first turn is measured from: -// "player" or "camera"; nothing for any other name. -std::optional walk_first_turn(std::string_view name); - // What is wrong with the args of a "walk" or "approach_starter" step: // each leg a [turn, ms] pair, turning -180 to 180 degrees and walking 0 ms // or more, some leg walking; an end a fade, after a leg that walks; a -// heading 0 to 359; a first turn "player" or "camera". Nothing for any -// other step. +// heading 0 to 359. Nothing for any other step. std::vector plza_step_arg_errors(const Pokemon::StoryStep& step); diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp index 0227c4dbe0..28f7451610 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp @@ -208,6 +208,20 @@ UnitTestResult test_reload_when_chained_field(Logger&){ return true; } +// 01.02 reloads when run after 01.01, whose autosave is 01.02's start; +// with 01.01 saving through the menu instead, 01.02's reload is refused. +UnitTestResult test_mm1_reload_when_chained(Logger&){ + const std::set> expected{"01.02"}; + if (builtin_story_data().reload_when_chained != expected){ + return "Expected 01.02, and only 01.02, to reload when chained."; + } + const std::string problem = load_problem(dev_with_execution("01.01", R"("save": "menu")")); + if (problem.find("does not end on the game's autosave") == std::string::npos){ + return std::format("01.01 saving through the menu: expected 01.02's reload refused, got \"{}\".", problem); + } + return true; +} + // A run can play every row: none names an action that is not implemented. UnitTestResult test_every_row_ready(Logger&){ const size_t ready = story_rows_ready(story_checkpoints()); @@ -471,6 +485,10 @@ const AutoStoryTableCase AUTO_STORY_TABLE_CASES[] = { .input = {"reload_when_chained: only true, only after an autosave row, never on a new game row", test_reload_when_chained_field}, .expectation = {}, }, + { + .input = {"reload_when_chained: 01.02 after 01.01's autosave", test_mm1_reload_when_chained}, + .expectation = {}, + }, { .input = {"Scene mash: what each frame presses", test_scene_mash_rule}, .expectation = {}, diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json index 5fef5ecbb2..6643298e9b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/StoryData/plza-01.02.plan.json @@ -11,11 +11,10 @@ { "id": "chase_pancham", "kind": "game_action", - "why": "step 11: after Pancham, through the archway, around the starters into the scene. NEEDS TUNING. Measured 2026-11-08 on console B, walk not run. The sidestep around the starters had no time recorded: 1000 ms is a placeholder. The first turn is from the camera: from the save the camera is behind the player, while 01.01's scenes end with the camera looking the same way (Prism Tower ahead) but the player turned right to the boy, so a turn from the player set off the wrong way (console B, 2026-11-13). Main Mission 01 has no minimap for a heading.", + "why": "step 11: after Pancham, through the archway, around the starters into the scene. NEEDS TUNING. Measured 2026-11-08 on console B, walk not run. The sidestep around the starters had no time recorded: 1000 ms is a placeholder. The first turn is from where the player faces (L first), as from the save; a run from 01.01 reloads the save first (reload_when_chained), since 01.01's scenes leave the player turned to the boy and the chase went the wrong way from there (console B, 2026-11-13).", "action": "walk", "args": { - "legs": [[-15, 4000], [-75, 3500], [90, 9000], [-90, 0], [90, 1000], [-90, 4000]], - "first_turn": "camera" + "legs": [[-15, 4000], [-75, 3500], [90, 9000], [-90, 0], [90, 1000], [-90, 4000]] } }, { @@ -46,6 +45,7 @@ } }, "execution": { - "save": "autosave" + "save": "autosave", + "reload_when_chained": true } } From 1d121fa819705160ace2f86b9e253ab138690cea Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 12:16:59 -0800 Subject: [PATCH 7/9] PokemonLZA AutoStory: the 01.02 reload test leaves later checkpoints free to reload too Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp index e1faf153db..a4169d3203 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryTable_Tests.cpp @@ -211,9 +211,8 @@ UnitTestResult test_reload_when_chained_field(Logger&){ // 01.02 reloads when run after 01.01, whose autosave is 01.02's start; // with 01.01 saving through the menu instead, 01.02's reload is refused. UnitTestResult test_mm1_reload_when_chained(Logger&){ - const std::set> expected{"01.02"}; - if (builtin_story_data().reload_when_chained != expected){ - return "Expected 01.02, and only 01.02, to reload when chained."; + if (!builtin_story_data().reload_when_chained.contains("01.02")){ + return "Expected 01.02 to reload when chained."; } const std::string problem = load_problem(dev_with_execution("01.01", R"("save": "menu")")); if (problem.find("does not end on the game's autosave") == std::string::npos){ From 811a8a87defb05e6d376d00e3757274b8c3d61ce Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 13:33:58 -0800 Subject: [PATCH 8/9] PLZA AutoStory: the leg breakpoint test builds the starter's game Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp index 2c73cb1f93..3ba9670919 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp @@ -674,7 +674,7 @@ UnitTestResult test_walk_to_prompt(CancellableScope& scope){ // step's own pause, each labelled with the leg's turn and walk. UnitTestResult test_walk_pauses_before_each_leg(CancellableScope& scope){ std::vector pauses; - Pokemon::StoryGame game = make_offline_plza_story_game(); + Pokemon::StoryGame game = make_plza_story_game(StarterChoice::CHIKORITA); game.breakpoints = Pokemon::StoryBreakpoints::LEGS; game.pause_point = [&pauses](std::string_view label){ pauses.emplace_back(label); From a562aeae15137af4b15a948a6e4627451ef64207 Mon Sep 17 00:00:00 2001 From: dayfine Date: Fri, 13 Nov 2026 16:09:14 -0800 Subject: [PATCH 9/9] Use the shared ScreenEvent names after merging autostory/engine PLZA AutoStory tests: TEXT_BOX -> DIALOG_BOX, BATTLE -> BATTLE_STARTED, CAN_MOVE -> PLAYER_CAN_MOVE, STILL -> SCREEN_STILL. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013VUubhHeYSMGSSDXZkKZss --- .../PokemonLZA_AutoStoryEngine_Tests.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp index fc912989a3..5e522590ba 100644 --- a/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonLZA/Programs/AutoStory/PokemonLZA_AutoStoryEngine_Tests.cpp @@ -160,7 +160,7 @@ UnitTestResult test_start_check_needs_platform(CancellableScope& scope){ // A walk starts only on free control: platform_to_plaza on a text box // waits for it, then fails with no input but its waits. UnitTestResult test_walk_needs_free_control(CancellableScope& scope){ - FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::TEXT_BOX})}, scope); + FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::DIALOG_BOX})}, scope); const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.01", "platform_to_plaza")); if (report.run.completed || report.run.failure.failure != "walk_not_free"){ return std::format("Expected walk_not_free, got {}", to_string(report.run.failure)); @@ -267,8 +267,8 @@ UnitTestResult test_face_heading(CancellableScope& scope){ // Pancham cornered (text_to_choice): B through the text, done at the // choice without pressing it. UnitTestResult test_text_to_choice(CancellableScope& scope){ - const Observation choice = look_at(2000ms, {EngineEvent::TEXT_BOX, EngineEvent::CHOICE_BOX}); - FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::TEXT_BOX}), choice}, scope); + const Observation choice = look_at(2000ms, {EngineEvent::DIALOG_BOX, EngineEvent::CHOICE_BOX}); + FakeBackend backend = fake_plza({look_at(0ms, {EngineEvent::DIALOG_BOX}), choice}, scope); const Pokemon::StoryEngineReport report = run_plza(backend, step_of("01.02", "pancham_cornered")); if (report.verdict != Pokemon::CheckpointVerdict::PASSED){ return std::format("Expected the scene to end at the choice: {}", to_string(report.run.failure)); @@ -281,10 +281,10 @@ UnitTestResult test_text_to_choice(CancellableScope& scope){ // once the controls hint has shown a second. UnitTestResult test_arrival_ends_on_controls_hint(CancellableScope& scope){ FakeBackend backend = fake_plza({ - look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(0ms, {EngineEvent::DIALOG_BOX}), look_at(1000ms), look_at(21000ms), - look_at(22000ms, {EngineEvent::TEXT_BOX, EngineEvent::CHOICE_BOX}), + look_at(22000ms, {EngineEvent::DIALOG_BOX, EngineEvent::CHOICE_BOX}), look_at(23000ms), with_reading(look_at(24000ms), CONTROLS_HINT_READING), with_reading(look_at(24500ms), CONTROLS_HINT_READING), @@ -312,7 +312,7 @@ UnitTestResult test_arrival_ends_on_controls_hint(CancellableScope& scope){ // hint. The prompt held a second ends the step; no press at it. UnitTestResult test_battle_area_ends_on_interact_prompt(CancellableScope& scope){ FakeBackend backend = fake_plza({ - look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(0ms, {EngineEvent::DIALOG_BOX}), look_at(1000ms, {EngineEvent::FADE_BLACK}), look_at(3000ms), look_at(3250ms, {EngineEvent::INTERACT_PROMPT}), @@ -367,7 +367,7 @@ UnitTestResult test_arrival_presses_through_the_ad(CancellableScope& scope){ UnitTestResult test_arrival_ends_on_mission_banner(CancellableScope& scope){ for (const bool goes : {true, false}){ std::vector> looks{ - look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(0ms, {EngineEvent::DIALOG_BOX}), look_at(500ms), with_reading(look_at(1000ms), MISSION_BANNER_READING), with_reading(look_at(1250ms), MISSION_BANNER_READING), @@ -399,7 +399,7 @@ UnitTestResult test_arrival_ends_on_mission_banner(CancellableScope& scope){ UnitTestResult test_after_andi_presses_complete_card(CancellableScope& scope){ for (const bool goes : {true, false}){ std::vector> looks{ - look_at(0ms, {EngineEvent::TEXT_BOX}), + look_at(0ms, {EngineEvent::DIALOG_BOX}), with_reading(look_at(500ms), MISSION_COMPLETE_READING), with_reading(look_at(1000ms), MISSION_COMPLETE_READING), look_at(1500ms),