From 09982bb45a58708ad4aaf3ec0da73ecd32554ec0 Mon Sep 17 00:00:00 2001 From: dayfine Date: Wed, 21 Oct 2026 21:01:07 -0700 Subject: [PATCH] BBQ Farmer: replan after rerolling an exhausted quest After an exhausted quest is rerolled, end the current batch and replan before continuing old queued work, so a replacement such as Travel 500m enters the next plan instead of waiting behind the old queue. Normal date and save handling still runs at the end of the shortened round. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Farming/PokemonSV_BBQSoloFarmer.cpp | 8 +++ .../Programs/Farming/PokemonSV_BBQTests.cpp | 60 +++++++++++++++++-- 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp index 46d2d349d4..715dee88a7 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp @@ -205,6 +205,7 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga //Never carry an observation across quest actions or the round's date/reset work. observed_panel.reset(); const uint64_t completed_before_round = num_completed_quests; + bool replan_after_reroll = false; 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){ @@ -231,6 +232,8 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga case BBQOption::OutOfRetries::Reroll: logger.log("Reroll selected. Rerolling the failed quest."); game.reroll_quest(current_quest); + logger.log("Reroll finished. Discarding the remaining batch before scheduling."); + replan_after_reroll = true; break; case BBQOption::OutOfRetries::Stop: logger.log("Stop selected. Stopping program.", COLOR_RED); @@ -244,6 +247,11 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga num_completed_quests++; } quest_list.clear(); + if (replan_after_reroll){ + //A replacement belongs in the next plan, before more old queued + //work. Finish normal round actions so save milestones are kept. + break; + } } //Clear out the todo list quests_to_do.clear(); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index 529627eecb..d3471c4d14 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -108,6 +108,7 @@ class SimulatedBBQGameActions : public BBQGameActions{ bool reuse_rerolled_panel = false; std::vector events; + std::vector attempted_quests; virtual std::vector read_quests() override{ events.push_back("read"); @@ -136,6 +137,7 @@ class SimulatedBBQGameActions : public BBQGameActions{ } virtual bool do_quest(BBQuests quest, uint8_t&) override{ events.push_back("do"); + attempted_quests.push_back(quest); const bool success = !never_completes.contains(quest) && (m_next_outcome < outcomes.size() ? outcomes[m_next_outcome++] : true); if (success){ @@ -211,6 +213,7 @@ struct BBQRoundsScenario{ BBQOption::OutOfRetries out_of_retries = BBQOption::OutOfRetries::Skip; bool reuse_rerolled_panel = false; uint64_t expected_completed = 0; + std::vector expected_attempted = {}; std::string expected; }; @@ -262,6 +265,18 @@ class Test_BBQFarmerRounds : public UnitTest{ return "Expected " + std::to_string(m_scenario.expected_completed) + " completed quests, counted " + std::to_string(completed); } + if (!m_scenario.expected_attempted.empty() && game.attempted_quests != m_scenario.expected_attempted){ + std::vector expected_quests; + std::vector actual_quests; + for (BBQuests quest : m_scenario.expected_attempted){ + expected_quests.push_back(std::to_string((int)quest)); + } + for (BBQuests quest : game.attempted_quests){ + actual_quests.push_back(std::to_string((int)quest)); + } + return "Expected quest order: " + join_events(expected_quests) + + "\nActual quest order: " + join_events(actual_quests); + } const std::string actual = join_events(game.events); if (actual != m_scenario.expected){ return "Expected: " + m_scenario.expected + "\nActual: " + actual; @@ -293,6 +308,41 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ std::vector> all_skipped_but_make_tm = every_doable_blue_quest(BBQAction::skip); all_skipped_but_make_tm.emplace_back(BBQuests::make_tm, BBQAction::run); const BBQRoundsScenario scenarios[] = { + { + .name = "failed reroll replans before queued photo and TM", + .num_quests = 1, + .panel = {BBQuests::catch_grass, BBQuests::photo_savanna, BBQuests::make_tm}, + .outcomes = {false}, + .new_quests = {BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .expected_completed = 3, + .expected_attempted = {BBQuests::catch_grass, BBQuests::travel_500, BBQuests::photo_savanna, BBQuests::make_tm}, + .expected = "read process read do reroll end " + round_of_3 + " end", + }, + { + .name = "failed reroll on full board reads fresh after round actions", + .num_quests = 1, + .panel = {BBQuests::catch_grass, BBQuests::photo_savanna, BBQuests::make_tm, BBQuests::wash_pokemon}, + .outcomes = {false}, + .new_quests = {BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .reuse_rerolled_panel = true, + .expected_completed = 4, + .expected_attempted = {BBQuests::catch_grass, BBQuests::travel_500, BBQuests::photo_savanna, BBQuests::make_tm, BBQuests::wash_pokemon}, + .expected = "read process read do reroll end " + round_of_3 + " read do completed end", + }, + { + .name = "replanning after failure preserves a crossed save milestone", + .num_quests = 2, + .save_num_quests = 1, + .panel = {BBQuests::make_tm, BBQuests::catch_grass, BBQuests::photo_savanna}, + .outcomes = {true, false}, + .new_quests = {BBQuests::photo_canyon, BBQuests::travel_500, BBQuests::photo_coastal, BBQuests::photo_polar}, + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .expected_completed = 4, + .expected_attempted = {BBQuests::make_tm, BBQuests::catch_grass, BBQuests::photo_canyon, BBQuests::travel_500, BBQuests::photo_savanna}, + .expected = "read process read do completed read do reroll end(save) " + round_of_3 + " end(save)", + }, { .name = "reuses reroll observation for selection and first dispatch only", .num_quests = 1, @@ -398,17 +448,17 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected = round_of_3 + " end(save) " + round_of_3 + " end(save)", }, { - // Round 1 completes nothing. It must not save, even though the - // count (0) is a multiple of the interval. - // Every quest fails and is rerolled, so round 1 completes - // nothing and doesn't save; round 2 reaches the milestone. + // Three partial rounds each fail and reroll their first quest. + // None may save while the completed count is still zero. .name = "round without completions does not save", .num_quests = 3, .save_num_quests = 2, .outcomes = {false, false, false}, .out_of_retries = BBQOption::OutOfRetries::Reroll, .expected_completed = 3, - .expected = "read process read do reroll read do reroll read do reroll end " + round_of_3 + " end(save)", + .expected = + "read process read do reroll end read process read do reroll end " + "read process read do reroll end " + round_of_3 + " end(save)", }, { // sneak-up fails, then leaves the panel along with make-tm. Round 2