From 778fe05f6e011c50f357ae030eea1ae42473109b Mon Sep 17 00:00:00 2001 From: dayfine Date: Thu, 22 Oct 2026 14:17:14 -0700 Subject: [PATCH] BBQ Farmer: chain no-trip quests without round actions between Make TM and Travel 500 m start at the Central Plaza fly point and fly back to it. After one completes, the panel read that checked it is reused: - for the next quest of the round when that is also a no-trip quest, and - to plan the next round when it was the last quest, skipping the round actions (date fix) unless a save is due or the quest goal is reached. do_quest() now hands back the panel read that checked the last attempt. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../VideoGames/PokemonSV/PokemonSV_Tests.cpp | 84 ++++++++++++++++--- .../Farming/PokemonSV_BBQSoloFarmer.cpp | 40 ++++++++- .../Farming/PokemonSV_BBQSoloFarmer.h | 13 ++- .../Farming/PokemonSV_BlueberryQuests.cpp | 6 +- .../Farming/PokemonSV_BlueberryQuests.h | 4 +- 5 files changed, 127 insertions(+), 20 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp index 11c07336c3..b9f9dbbfb7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/PokemonSV_Tests.cpp @@ -598,7 +598,7 @@ class SimulatedBBQGameActions : public BBQGameActions{ } return {std::move(doable), std::nullopt}; } - virtual bool do_quest(BBQuests quest, uint8_t&) override{ + virtual bool do_quest(BBQuests quest, uint8_t&, std::vector& panel_after) override{ events.push_back("do"); attempted_quests.push_back(quest); const bool success = !never_completes.contains(quest) @@ -611,6 +611,7 @@ class SimulatedBBQGameActions : public BBQGameActions{ } } } + panel_after = panel; return success; } virtual std::optional> reroll_quest(BBQuests quest) override{ @@ -815,13 +816,13 @@ void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .reuse_rerolled_panel = true, .expected_completed = 3, .expected_attempted = {BBQuests::catch_fighting, BBQuests::travel_500, BBQuests::make_tm, BBQuests::photo_savanna}, - .expected_reads = 3, - .expected = "read process do reroll end process process do completed read do completed read do completed end", + .expected_reads = 2, + .expected = "read process do reroll end process process do completed do completed read do completed end", }, { // As above, but neither reroll's read is reusable. Only the // first dispatch skips a read: 2 reads before the next attempt - // instead of 3. + // instead of 3. make-tm starts from travel-500's read. .name = "failed reroll then table reroll without reusable reads", .num_quests = 1, .panel = {BBQuests::catch_fighting, BBQuests::make_tm, BBQuests::photo_savanna}, @@ -831,8 +832,8 @@ void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .table_rerolls = {BBQuests::pickup_10}, .expected_completed = 3, .expected_attempted = {BBQuests::catch_fighting, BBQuests::travel_500, BBQuests::make_tm, BBQuests::photo_savanna}, - .expected_reads = 5, - .expected = "read process do reroll end read process read process do completed read do completed read do completed end", + .expected_reads = 4, + .expected = "read process do reroll end read process read process do completed do completed read do completed end", }, { // The save resets the game, so the reroll's read is not reused. @@ -939,8 +940,9 @@ void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ }, { // sneak-up fails, then leaves the panel along with make-tm. Round 2 - // reads a full panel without it, and its replacement for - // photo-canyon brings it back. Round 3 attempts it again. + // plans round 2 from a full panel without it (make-tm's read, no + // round actions), and its replacement for photo-canyon brings it + // back. Round 3 attempts it again. .name = "failed quest that leaves a full panel is attempted again", .num_quests = 5, .panel = {BBQuests::sneak_up, BBQuests::make_tm, BBQuests::pickup_10, BBQuests::catch_flying}, @@ -949,8 +951,8 @@ void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .new_quests = {BBQuests::auto_10, BBQuests::photo_canyon, BBQuests::sneak_up}, .expected_completed = 5, .expected = - "read process do read do completed end " - "read process do completed read do completed end " + "read process do read do completed " + "process do completed read do completed end " "read process do completed read do completed end", }, { @@ -964,8 +966,8 @@ void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .new_quests = {BBQuests::auto_10, BBQuests::photo_canyon, BBQuests::sneak_up}, .expected_completed = 4, .expected = - "read process do read do completed end " - "read process do completed read do completed end " + "read process do read do completed " + "process do completed read do completed end " "read process do completed end", }, { @@ -986,6 +988,64 @@ void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected_completed = 0, .expected = "read process do", }, + { + // make-tm ends round 1 back at Central Plaza: its read plans + // round 2 with no round actions between it and travel-500. + .name = "no-trip quests chain with no round actions between", + .num_quests = 5, + .panel = {BBQuests::auto_10, BBQuests::sneak_up, BBQuests::make_tm}, + .new_quests = {BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .expected_completed = 6, + .expected_attempted = { + BBQuests::auto_10, BBQuests::sneak_up, BBQuests::make_tm, + BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, + }, + .expected_reads = 5, + .expected = + "read process do completed read do completed read do completed " + "process do completed read do completed read do completed end", + }, + { + // make-tm, travel-500 and photo-canyon on one board: only + // travel-500 starts from make-tm's read. The trip quest reads + // the panel and ends the round as usual. + .name = "no-trip then trip quest keeps the trip's usual steps", + .num_quests = 3, + .panel = {BBQuests::make_tm, BBQuests::travel_500, BBQuests::photo_canyon}, + .new_quests = {BBQuests::photo_coastal, BBQuests::photo_polar, BBQuests::photo_savanna}, + .expected_completed = 3, + .expected_reads = 2, + .expected = "read process do completed do completed read do completed end", + }, + { + .name = "failed no-trip quest ends the round as usual", + .num_quests = 3, + .panel = {BBQuests::auto_10, BBQuests::sneak_up, BBQuests::make_tm}, + .outcomes = {true, true, false}, + .new_quests = {BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .expected_completed = 4, + .expected = + "read process do completed read do completed read do end " + "read process do completed read do completed end", + }, + { + .name = "no-trip quest does not chain past a save", + .num_quests = 6, + .save_num_quests = 3, + .panel = {BBQuests::auto_10, BBQuests::sneak_up, BBQuests::make_tm}, + .new_quests = {BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .expected_completed = 6, + .expected = + "read process do completed read do completed read do completed end(save) " + "read process do completed read do completed read do completed end(save)", + }, + { + .name = "no-trip quest that reaches the goal ends the round", + .num_quests = 3, + .panel = {BBQuests::auto_10, BBQuests::sneak_up, BBQuests::make_tm}, + .expected_completed = 3, + .expected = "read process do completed read do completed read do completed end", + }, }; for (const BBQRoundsScenario& scenario : scenarios){ database.add(scenario); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp index 45faa1c628..2eeed27353 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp @@ -91,6 +91,17 @@ void forget_quests_gone_from_panel(std::set& failed_quests, const std: }); } +} + +// Quests done at Central Plaza with no flight out: they start at its fly +// point and fly back to it, so the player is where the round actions and the +// next quest expect. Every other route flies to another plaza or area. +bool bbq_quest_is_no_trip(BBQuests quest){ + return quest == BBQuests::make_tm || quest == BBQuests::travel_500; +} + +namespace{ + // Whether a round that took the completed count from previous_completed // to completed crossed a nonzero multiple of the save interval. bool bbq_save_due(uint64_t previous_completed, uint64_t completed, uint64_t interval){ @@ -164,23 +175,37 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga const uint64_t completed_before_round = num_completed_quests; bool replan_after_reroll = false; std::optional> rerolled_panel; + //The panel read that checked a completed no-trip quest. Nothing runs + //between it and the next dispatch or plan, so a no-trip quest next or + //the next plan starts from it instead of reading again. + std::optional> no_trip_panel; for (auto current_quest : quests_to_do){ //Check if quest was already completed (ex. 500 meters completed while navigating to take a photo) if (dispatch_panel){ logger.log("Reusing verified quest panel for first dispatch."); quest_list = std::move(*dispatch_panel); dispatch_panel.reset(); + }else if (no_trip_panel && bbq_quest_is_no_trip(current_quest)){ + logger.log("Reusing quest panel read after a no-trip quest for dispatch."); + quest_list = std::move(*no_trip_panel); + no_trip_panel.reset(); + forget_quests_gone_from_panel(failed_quests, quest_list); }else{ + no_trip_panel.reset(); logger.log("Reading quest panel before dispatch."); quest_list = read_panel(); } if (std::find(quest_list.begin(), quest_list.end(), current_quest) != quest_list.end()){ logger.log("Current quest exists on list. Doing quest."); - bool questSuccess = game.do_quest(current_quest, eggs_hatched); + std::vector panel_after; + bool questSuccess = game.do_quest(current_quest, eggs_hatched, panel_after); if (questSuccess){ logger.log("Quest completed successfully."); game.quest_completed(); num_completed_quests++; + if (bbq_quest_is_no_trip(current_quest)){ + no_trip_panel = std::move(panel_after); + } }else{ logger.log("Quest did not complete successfully."); switch (options.OUT_OF_RETRIES){ @@ -217,6 +242,15 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga uint64_t temp_save_num_option = options.SAVE_NUM_QUESTS; // A round can cross a milestone without ending at an exact multiple. const bool save = bbq_save_due(completed_before_round, num_completed_quests, temp_save_num_option); + + //A no-trip quest ended the round at Central Plaza, and fixing the date + //does not change the quests, so plan the next quests from its read + //at once. Round actions still run before a save or the last stop. + if (no_trip_panel && !save && num_completed_quests < options.NUM_QUESTS){ + logger.log("Chaining after a no-trip quest. Skipping round actions."); + observed_panel = std::move(no_trip_panel); + continue; + } game.end_round(save); //The reroll was the last game action of the round. Fixing the date @@ -251,8 +285,8 @@ class BBQSoloFarmerGameActions : public BBQGameActions{ ) override{ return PokemonSV::process_quest_list(m_env.program_info(), m_env.console, m_context, m_options, quests, eggs_hatched); } - virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched) override{ - return process_and_do_quest(m_env, m_env.console, m_context, m_options, quest, eggs_hatched); + virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched, std::vector& panel_after) override{ + return process_and_do_quest(m_env, m_env.console, m_context, m_options, quest, eggs_hatched, &panel_after); } virtual std::optional> reroll_quest(BBQuests quest) override{ std::vector quests = PokemonSV::read_quests(m_env.program_info(), m_env.console, m_context, m_options); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h index c7e9c1fbeb..07902e50e9 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h @@ -43,8 +43,9 @@ class BBQGameActions{ // Attempt one quest that is on the panel, after process_quest_list() // chose it. Returns true if it is no longer on the panel afterwards. - // Increments `eggs_hatched` when the quest hatches eggs. - virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched) = 0; + // Increments `eggs_hatched` when the quest hatches eggs. Sets + // `panel_after` to the quest panel read that checked the last attempt. + virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched, std::vector& panel_after) = 0; // Reroll a quest that failed all its attempts, if it is still on the // panel. Spends BP. Returns the panel read to verify the reroll when @@ -61,10 +62,16 @@ class BBQGameActions{ virtual void end_round(bool save) = 0; }; +// Whether a quest is done at Central Plaza with no flight out. +bool bbq_quest_is_no_trip(BBQuests quest); + // Run rounds of quests until NUM_QUESTS have been completed, or until // eggs run out when OUT_OF_EGGS is Stop, or until every doable quest on the // panel is one that already failed all its attempts, or until a quest fails -// all its attempts when OUT_OF_RETRIES is Stop. +// all its attempts when OUT_OF_RETRIES is Stop. No-trip quests (see +// bbq_quest_is_no_trip()) are chained: the panel read that checked one is +// reused for a no-trip quest next or for the next plan, without the round +// actions between. void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& game); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 92bc9a990f..152d352525 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -580,7 +580,8 @@ bool process_and_do_quest( ConsoleHandle& console, ProControllerContext& context, BBQOption& BBQ_OPTIONS, BBQuests current_quest, - uint8_t& eggs_hatched + uint8_t& eggs_hatched, + std::vector* panel_after ){ bool quest_completed = false; int quest_attempts = 0; @@ -687,6 +688,9 @@ bool process_and_do_quest( //Validate quest was completed by checking list console.log("Reading quest panel after attempt."); std::vector quest_list = read_quests(env.program_info(), console, context, BBQ_OPTIONS); + if (panel_after){ + *panel_after = quest_list; + } if (std::find(quest_list.begin(), quest_list.end(), current_quest) != quest_list.end()){ console.log("Current quest exists on list. Quest did not complete."); quest_attempts++; diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h index eec8eb1034..53144fc6a8 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h @@ -162,12 +162,14 @@ BBQuestBatch process_quest_list( ); //Take the current quest and calls the function to do it, then checks the quest was successful. Returns true if so. +//If panel_after is given, it receives the quest panel read that checked the last attempt. bool process_and_do_quest( ProgramEnvironment& env, ConsoleHandle& console, ProControllerContext& context, BBQOption& BBQ_OPTIONS, BBQuests current_quest, - uint8_t& eggs_hatched + uint8_t& eggs_hatched, + std::vector* panel_after = nullptr ); //Iterate through TMs until a craftable one is found. Make the TM and return to position.