diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp index 715dee88a7..e2ccbc114f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp @@ -170,7 +170,6 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga " quest panel reads. Check the game language and that you have BP to reroll." ); } - const bool reused_panel = observed_panel.has_value(); if (observed_panel){ logger.log("Reusing verified quest panel for scheduling."); quest_list = std::move(*observed_panel); @@ -183,7 +182,9 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga BBQuestBatch batch = game.process_quest_list(quest_list, eggs_hatched); quests_to_do = std::move(batch.to_do); observed_panel = std::move(batch.observed_panel); - if (reused_panel && !quests_to_do.empty() && !observed_panel){ + //Work is only returned when nothing changed in game, so the panel + //it was chosen from is still current for the first dispatch. + if (!quests_to_do.empty() && !observed_panel){ dispatch_panel = quest_list; } @@ -202,10 +203,11 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga quest_list.clear(); } - //Never carry an observation across quest actions or the round's date/reset work. + //Never carry an observation across quest actions or a save and reset. observed_panel.reset(); const uint64_t completed_before_round = num_completed_quests; bool replan_after_reroll = false; + std::optional> rerolled_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){ @@ -231,7 +233,7 @@ void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& ga break; case BBQOption::OutOfRetries::Reroll: logger.log("Reroll selected. Rerolling the failed quest."); - game.reroll_quest(current_quest); + rerolled_panel = game.reroll_quest(current_quest); logger.log("Reroll finished. Discarding the remaining batch before scheduling."); replan_after_reroll = true; break; @@ -258,7 +260,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. - game.end_round(bbq_save_due(completed_before_round, num_completed_quests, temp_save_num_option)); + const bool save = bbq_save_due(completed_before_round, num_completed_quests, temp_save_num_option); + game.end_round(save); + + //The reroll was the last game action of the round. Fixing the date + //does not change the quests, so its verified read can seed the next + //plan. A save resets the game, so the panel is read again after one. + if (rerolled_panel && !save){ + observed_panel = std::move(rerolled_panel); + } } } @@ -288,14 +298,14 @@ class BBQSoloFarmerGameActions : public BBQGameActions{ 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 void reroll_quest(BBQuests quest) override{ + 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); auto iter = std::find(quests.begin(), quests.end(), quest); if (iter == quests.end()){ m_env.log("Failed quest is no longer on the panel. Not rerolling."); - return; + return std::nullopt; } - reroll_quest_slot(m_env.program_info(), m_env.console, m_context, m_options, quests, iter - quests.begin()); + return reroll_quest_slot(m_env.program_info(), m_env.console, m_context, m_options, quests, iter - quests.begin()); } virtual void quest_completed() override{ m_stats.questsCompleted++; diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h index 63b396fb00..5d47dc70bd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.h @@ -8,6 +8,7 @@ #define PokemonAutomation_PokemonSV_BBQSoloFarmer_H #include +#include #include #include "Common/Cpp/Logging/AbstractLogger.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" @@ -34,6 +35,8 @@ class BBQGameActions{ // Decide which of the quests just read are worth attempting this round. // May reroll quests in game, so the returned list can be empty even when // `quests` is not; a complete post-reroll observation can seed selection. + // Only returns quests to attempt when it changed nothing in game, so + // `quests` still shows the panel. virtual BBQuestBatch process_quest_list( const std::vector& quests, uint8_t eggs_hatched ) = 0; @@ -44,8 +47,9 @@ class BBQGameActions{ virtual bool do_quest(BBQuests quest, uint8_t& eggs_hatched) = 0; // Reroll a quest that failed all its attempts, if it is still on the - // panel. Spends BP. - virtual void reroll_quest(BBQuests quest) = 0; + // panel. Spends BP. Returns the panel read to verify the reroll when + // reroll_quest() found it reusable, so scheduling can skip a read. + virtual std::optional> reroll_quest(BBQuests quest) = 0; // Progress reporting only: a quest was counted as completed. Lets stats // update after every quest instead of once per round. diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index f510f1300f..324bef3c5b 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -135,10 +135,11 @@ class NullLogger : public Logger{ // A singleplayer quest panel that behaves like the game's: 3 blue quests, // and a completed quest is replaced by a new one. process_quest_list() -// follows the two rules of the real one that the round loop depends on: -// quests in not_possible_quests are skipped, and if nothing is doable all -// quests are rerolled and nothing is returned. Red quests and the -// exclusions table are not modeled. Records the game actions taken. +// follows the rules of the real one that the round loop depends on: quests +// in not_possible_quests are skipped, quests in table_rerolls are rerolled +// in their slot as an exclusions table reroll row does, and if nothing is +// doable all quests are rerolled. After any reroll it returns nothing to do. +// Red quests are not modeled. Records the game actions taken. // With out_of_bp, rerolls do nothing, as in the game when BP runs out. // A run that reads the panel more than max_reads times is stuck: the read // throws, and the test records "stuck". @@ -161,6 +162,10 @@ class SimulatedBBQGameActions : public BBQGameActions{ BBQuests::photo_savanna, BBQuests::catch_any, BBQuests::catch_normal, BBQuests::catch_fire, BBQuests::catch_water, BBQuests::catch_grass, }; + // Quests that process_quest_list() rerolls in their slot. + std::set table_rerolls; + // Rerolls return the panel they read to verify the reroll, as + // reroll_quest() does when that read is reusable. bool reuse_rerolled_panel = false; std::vector events; @@ -177,19 +182,29 @@ class SimulatedBBQGameActions : public BBQGameActions{ const std::vector& quests, uint8_t ) override{ events.push_back("process"); + bool rerolled = false; + for (BBQuests& slot : panel){ + if (table_rerolls.contains(slot)){ + slot = next_new_quest(); + rerolled = true; + } + } std::vector doable; for (BBQuests quest : quests){ if (!not_possible_quests.contains(quest)){ doable.push_back(quest); } } - const bool rerolled = doable.empty() && !out_of_bp; - if (rerolled){ + if (!rerolled && doable.empty() && !out_of_bp){ for (BBQuests& slot : panel){ slot = next_new_quest(); } + rerolled = true; } - return {std::move(doable), rerolled && reuse_rerolled_panel && quests.size() == 4 ? std::optional(panel) : std::nullopt}; + if (rerolled){ + return {{}, reuse_rerolled_panel ? std::optional(panel) : std::nullopt}; + } + return {std::move(doable), std::nullopt}; } virtual bool do_quest(BBQuests quest, uint8_t&) override{ events.push_back("do"); @@ -206,12 +221,14 @@ class SimulatedBBQGameActions : public BBQGameActions{ } return success; } - virtual void reroll_quest(BBQuests quest) override{ + virtual std::optional> reroll_quest(BBQuests quest) override{ events.push_back("reroll"); auto iter = std::find(panel.begin(), panel.end(), quest); - if (iter != panel.end()){ - *iter = next_new_quest(); + if (iter == panel.end()){ + return std::nullopt; } + *iter = next_new_quest(); + return reuse_rerolled_panel ? std::optional(panel) : std::nullopt; } virtual void quest_completed() override{ events.push_back("completed"); @@ -267,9 +284,11 @@ struct BBQRoundsScenario{ std::vector new_quests = {}; std::vector> exclusions = {}; BBQOption::OutOfRetries out_of_retries = BBQOption::OutOfRetries::Skip; + std::set table_rerolls = {}; bool reuse_rerolled_panel = false; uint64_t expected_completed = 0; std::vector expected_attempted = {}; + std::optional expected_reads = {}; std::string expected; }; @@ -306,6 +325,7 @@ class Test_BBQFarmerRounds : public UnitTest{ if (!m_scenario.new_quests.empty()){ game.new_quests = m_scenario.new_quests; } + game.table_rerolls = m_scenario.table_rerolls; game.reuse_rerolled_panel = m_scenario.reuse_rerolled_panel; NullLogger logger; @@ -333,6 +353,11 @@ class Test_BBQFarmerRounds : public UnitTest{ return "Expected quest order: " + join_events(expected_quests) + "\nActual quest order: " + join_events(actual_quests); } + const size_t reads = (size_t)std::count(game.events.begin(), game.events.end(), "read"); + if (m_scenario.expected_reads && reads != *m_scenario.expected_reads){ + return "Expected " + std::to_string(*m_scenario.expected_reads) + + " quest panel reads, counted " + std::to_string(reads); + } const std::string actual = join_events(game.events); if (actual != m_scenario.expected){ return "Expected: " + m_scenario.expected + "\nActual: " + actual; @@ -356,7 +381,7 @@ std::vector> every_doable_blue_quest(BBQAction ac } static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ - const std::string round_of_3 = "read process read do completed read do completed read do completed"; + const std::string round_of_3 = "read process do completed read do completed read do completed"; std::string read_30_times; for (int c = 0; c < 30; c++){ read_30_times += "read process "; @@ -373,10 +398,10 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .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", + .expected = "read process do reroll end " + round_of_3 + " end", }, { - .name = "failed reroll on full board reads fresh after round actions", + .name = "failed reroll on full board reuses its verified read after round actions", .num_quests = 1, .panel = {BBQuests::catch_grass, BBQuests::photo_savanna, BBQuests::make_tm, BBQuests::wash_pokemon}, .outcomes = {false}, @@ -385,7 +410,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .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", + .expected = "read process do reroll end process do completed read do completed read do completed read do completed end", }, { .name = "replanning after failure preserves a crossed save milestone", @@ -397,7 +422,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .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)", + .expected = "read process do completed read do reroll end(save) " + round_of_3 + " end(save)", }, { .name = "reuses reroll observation for selection and first dispatch only", @@ -408,12 +433,61 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .expected = "read process process do completed read do completed read do completed read do completed end", }, { - .name = "three-slot reroll still reads the panel again", + // reroll_quest() decides whether a 3-slot read is reusable. + .name = "reusable three-slot reroll observation is not read again", .num_quests = 1, .panel = {BBQuests::pickup_10, BBQuests::catch_flying, BBQuests::UnableToDetect}, .reuse_rerolled_panel = true, .expected_completed = 3, - .expected = "read process read process read do completed read do completed read do completed end", + .expected = "read process process do completed read do completed read do completed end", + }, + { + // Seen in a live run: catch-fighting fails and is rerolled into + // pickup-10, which the exclusions table rerolls into travel-500. + // Each reroll's verified read is reused, and so is the last one + // for the first dispatch. The round loop used to read the panel + // 3 times between the failed reroll and the next attempt. + .name = "failed reroll then table reroll reuse verified reads", + .num_quests = 1, + .panel = {BBQuests::catch_fighting, BBQuests::make_tm, BBQuests::photo_savanna}, + .outcomes = {false}, + .new_quests = {BBQuests::pickup_10, BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .table_rerolls = {BBQuests::pickup_10}, + .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", + }, + { + // 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. + .name = "failed reroll then table reroll without reusable reads", + .num_quests = 1, + .panel = {BBQuests::catch_fighting, BBQuests::make_tm, BBQuests::photo_savanna}, + .outcomes = {false}, + .new_quests = {BBQuests::pickup_10, BBQuests::travel_500, BBQuests::photo_canyon, BBQuests::photo_coastal, BBQuests::photo_polar}, + .out_of_retries = BBQOption::OutOfRetries::Reroll, + .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", + }, + { + // The save resets the game, so the reroll's read is not reused. + .name = "failed reroll before a save reads the panel after it", + .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, + .reuse_rerolled_panel = true, + .expected_completed = 4, + .expected = "read process do completed read do reroll end(save) " + round_of_3 + " end(save)", }, { // The goal (4) is reached in the middle of round 2. The loop only @@ -432,7 +506,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .panel = {BBQuests::photo_swim, BBQuests::travel_500, BBQuests::make_tm}, .also_completes = {{BBQuests::photo_swim, BBQuests::travel_500}}, .expected_completed = 3, - .expected = "read process read do completed read completed read do completed end", + .expected = "read process do completed read completed read do completed end", }, { // The first attempt fails: 3 attempts, 2 completions. @@ -440,7 +514,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .num_quests = 2, .outcomes = {false}, .expected_completed = 2, - .expected = "read process read do read do completed read do completed end", + .expected = "read process do read do completed read do completed end", }, { // Nothing on the panel is doable, so process_quest_list() rerolls @@ -475,8 +549,8 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .never_completes = {BBQuests::sneak_up}, .expected_completed = 4, .expected = - "read process read do completed read do completed read do end " - "read process read do completed read do completed end", + "read process do completed read do completed read do end " + "read process do completed read do completed end", }, { .name = "stops when only failed quests are doable", @@ -484,7 +558,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .panel = {BBQuests::sneak_up, BBQuests::pickup_10, BBQuests::catch_flying}, .never_completes = {BBQuests::sneak_up}, .expected_completed = 0, - .expected = "read process read do end read process", + .expected = "read process do end read process", }, { // Rerolls change nothing, so the panel never becomes doable. @@ -513,8 +587,8 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .out_of_retries = BBQOption::OutOfRetries::Reroll, .expected_completed = 3, .expected = - "read process read do reroll end read process read do reroll end " - "read process read do reroll end " + round_of_3 + " end(save)", + "read process do reroll end read process do reroll end " + "read process do reroll end " + round_of_3 + " end(save)", }, { // sneak-up fails, then leaves the panel along with make-tm. Round 2 @@ -528,9 +602,9 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .new_quests = {BBQuests::auto_10, BBQuests::photo_canyon, BBQuests::sneak_up}, .expected_completed = 5, .expected = - "read process read do read do completed end " - "read process read do completed read do completed end " - "read process read do completed read do completed end", + "read process do read do completed end " + "read process do completed read do completed end " + "read process do completed read do completed end", }, { // As above with 3 slots. A 4th quest could have been missed by @@ -543,9 +617,9 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .new_quests = {BBQuests::auto_10, BBQuests::photo_canyon, BBQuests::sneak_up}, .expected_completed = 4, .expected = - "read process read do read do completed end " - "read process read do completed read do completed end " - "read process read do completed end", + "read process do read do completed end " + "read process do completed read do completed end " + "read process do completed end", }, { // Rerolling could never produce a doable panel, so the run @@ -571,7 +645,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .never_completes = {BBQuests::sneak_up}, .out_of_retries = BBQOption::OutOfRetries::Reroll, .expected_completed = 5, - .expected = "read process read do completed read do completed read do reroll end " + round_of_3 + " end", + .expected = "read process do completed read do completed read do reroll end " + round_of_3 + " end", }, { .name = "out of retries with stop stops at once", @@ -580,7 +654,7 @@ static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){ .never_completes = {BBQuests::sneak_up}, .out_of_retries = BBQOption::OutOfRetries::Stop, .expected_completed = 0, - .expected = "read process read do", + .expected = "read process do", }, }; for (const BBQRoundsScenario& scenario : scenarios){ @@ -898,6 +972,49 @@ static void add_tests_BBQReroll(UnitTestDatabase& database){ .expected_rerolled_slots = {2}, .expected_quests = {make_tm, travel_500, catch_any, hatch_egg}, }, + { + // The panel used for the reroll had 3 slots, so a 3-slot read is + // not a missed fourth quest. + .name = "three-slot read of a three-slot panel is reusable", + .quests = {make_tm, sneak_up, travel_500}, + .replacements = {catch_any}, + .slot = 2, + .expected = BBQRerollResult::Rerolled, + .expected_rerolled_slots = {2}, + .expected_quests = {make_tm, sneak_up, catch_any}, + .expected_observed_panel = std::vector{make_tm, sneak_up, catch_any}, + }, + { + .name = "three-slot read with an unknown slot is not reusable", + .quests = {make_tm, sneak_up, travel_500}, + .replacements = {catch_any}, + .slot = 2, + .read_override = std::vector{make_tm, UnableToDetect, catch_any}, + .expected = BBQRerollResult::Rerolled, + .expected_rerolled_slots = {2}, + .expected_quests = {make_tm, sneak_up, catch_any}, + }, + { + .name = "three-slot read with another changed quest is not reusable", + .quests = {make_tm, sneak_up, travel_500}, + .replacements = {catch_any}, + .slot = 2, + .read_override = std::vector{photo_canyon, sneak_up, catch_any}, + .expected = BBQRerollResult::Rerolled, + .expected_rerolled_slots = {2}, + .expected_quests = {make_tm, sneak_up, catch_any}, + }, + { + // The panel used for the reroll missed this fourth quest. + .name = "fourth quest not on the three-slot panel is not reusable", + .quests = {make_tm, sneak_up, travel_500}, + .replacements = {catch_any}, + .slot = 2, + .read_override = std::vector{make_tm, sneak_up, catch_any, hatch_egg}, + .expected = BBQRerollResult::Rerolled, + .expected_rerolled_slots = {2}, + .expected_quests = {make_tm, sneak_up, catch_any}, + }, { .name = "complete observation after missed reads is reusable", .quests = {make_tm, travel_500, sneak_up, hatch_egg}, @@ -917,6 +1034,7 @@ static void add_tests_BBQReroll(UnitTestDatabase& database){ .expected = BBQRerollResult::Rerolled, .expected_rerolled_slots = {2}, .expected_quests = {make_tm, sneak_up, catch_any}, + .expected_observed_panel = std::vector{make_tm, sneak_up, catch_any}, }, { // Seen on a Switch: the panel can open with the cursor where it @@ -974,6 +1092,7 @@ static void add_tests_BBQReroll(UnitTestDatabase& database){ .expected = BBQRerollResult::Rerolled, .expected_rerolled_slots = {2}, .expected_quests = {make_tm, sneak_up, catch_any}, + .expected_observed_panel = std::vector{make_tm, sneak_up, catch_any}, }, { .name = "three missed reads give up", diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 9d7576046a..59643ba2dd 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -331,9 +331,14 @@ BBQRerollResult reroll_quest( if (slot < after.size() && after[slot] != quests[slot] && after[slot] != BBQuests::UnableToDetect){ logger.log("Quest " + std::to_string(slot + 1) + " rerolled."); quests[slot] = after[slot]; - //Three slots can mean a missed fourth quest. Reuse only a complete - //read whose other slots agree with the panel used for this reroll. - if (after.size() == 4 && after == quests + //Reuse only a read whose slots are all known and, apart from the + //rerolled one, agree with the panel used for this reroll. Three + //slots can mean a missed fourth quest, so a 3-slot read is only + //reused when that panel had 3 slots too. Both reads could have + //missed the same fourth quest, as a fresh read also could. That + //quest is then left out of one plan, which costs no BP, and a + //3-slot read never proves a failed quest left the panel. + if (after.size() >= 3 && after == quests && std::find(after.begin(), after.end(), BBQuests::UnableToDetect) == after.end()){ observed_panel = std::move(after); } diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h index f86490204d..f6ab31dd3f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h @@ -121,7 +121,8 @@ enum class BBQRerollResult{ //Reroll the quest in `slot` of `quests`, the quests last read from the panel. Only pays once //the reroll menu is open next to that slot, then reads the panel again to check the quest was //replaced. On Rerolled, `quests[slot]` is updated. observed_panel is populated -//only for four known slots with no other changes, so scheduling can reuse it. +//only when every slot is known and no other slot changed, so scheduling can +//reuse it. A 3-slot read is only reused when `quests` had 3 slots. BBQRerollResult reroll_quest( Logger& logger, BBQRerollActions& actions, @@ -131,7 +132,7 @@ BBQRerollResult reroll_quest( ); //Reroll the quest in `slot` of `quests` on the console, with reroll_quest(). Stops the program -//if the reroll fails. Returns a complete observed panel when reusable. +//if the reroll fails. Returns the observed panel when reusable. std::optional> reroll_quest_slot( const ProgramInfo& info, VideoStream& stream, ProControllerContext& context,