From a48d5419566483598435f3e34733bbfc23e26a60 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 27 Oct 2026 23:52:44 -0700 Subject: [PATCH] BBQ: near the Auto Battle target, stop when the quest leaves the board (C10) The heard kill count runs about one short of the game's: a kill whose sound is missed still counts in game. In R3b, 9 kills were heard after pass 4 but the game had completed the quest, so pass 5 and its heal (~100 s) were wasted. After a pass that ends within 2 kills of the target, read the quest panel at Central Plaza (the reader the post-quest check uses, ~5 s) before healing. If the quest is gone, stop. Far from the target nothing changes. Behavior change: a board read after passes that end near the target; an attempt can end before the heard kills reach the target. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Programs/Farming/PokemonSV_BBQTests.cpp | 70 +++++++++++++++++++ .../Farming/PokemonSV_BlueberryQuests.cpp | 24 ++++++- .../Farming/PokemonSV_BlueberryQuests.h | 8 +++ 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index 196e65e8e3..c506ec8843 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -100,6 +100,7 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ static constexpr int CLEAR_TAIL_SECONDS = 6; // Skipped when the clear stops at `stop_at_kills`. static constexpr int RETURN_SECONDS = 28; // Fly back to Central Plaza. static constexpr int HEAL_SECONDS = 28; // Walk to the nurse and heal (14 s), then re-fly (14 s). + static constexpr int BOARD_SECONDS = 5; // Open the quest panel, read it, close it. // Kills heard in each clear, in turn. Running past the end throws, which // also stops a loop that would never end. @@ -109,6 +110,8 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ // Kills heard on each flight back, in turn: the lead finishing a kill // after the clear ends. Past the end, none. std::vector kills_per_return; + // Whether each board read finds the quest, in turn. Past the end, it does. + std::vector quest_on_board_per_read; std::vector steps; int seconds = 0; @@ -144,6 +147,13 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ } m_returns++; } + virtual bool quest_on_board() override{ + steps.push_back("board"); + seconds += BOARD_SECONDS; + const bool on_board = m_reads >= quest_on_board_per_read.size() || quest_on_board_per_read[m_reads]; + m_reads++; + return on_board; + } virtual void heal() override{ steps.push_back("heal"); seconds += HEAL_SECONDS; @@ -153,6 +163,7 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ uint64_t m_kills = 0; size_t m_clears = 0; size_t m_returns = 0; + size_t m_reads = 0; }; // One pass as it shows in the expected steps. @@ -170,6 +181,7 @@ std::string auto_battle_result_to_string(BBQAutoBattleResult result){ case BBQAutoBattleResult::TargetReached: return "TargetReached"; case BBQAutoBattleResult::NoKills: return "NoKills"; case BBQAutoBattleResult::TimeLimit: return "TimeLimit"; + case BBQAutoBattleResult::QuestDone: return "QuestDone"; } return "?"; } @@ -181,6 +193,8 @@ struct BBQAutoBattleScenario{ std::vector kills_per_clear; std::vector> hp_per_clear = {}; // Unknown when not given. std::vector kills_per_return = {}; // None when not given. + uint64_t check_board_within_kills = 0; // Off unless a scenario tests it. + std::vector quest_on_board_per_read = {}; // On the board when not given. int heal_below_hp_percent = 50; BBQAutoBattleResult expected_result = BBQAutoBattleResult::TargetReached; std::string expected_steps; @@ -200,12 +214,14 @@ class Test_BBQAutoBattle : public UnitTest{ actions.kills_per_clear = m_scenario.kills_per_clear; actions.hp_per_clear = m_scenario.hp_per_clear; actions.kills_per_return = m_scenario.kills_per_return; + actions.quest_on_board_per_read = m_scenario.quest_on_board_per_read; RecordingLogger logger; BBQAutoBattlePolicy policy; policy.kill_target = m_scenario.kill_target; policy.time_limit = std::chrono::minutes(m_scenario.time_limit_minutes); policy.heal_below_hp_percent = (uint8_t)m_scenario.heal_below_hp_percent; + policy.check_board_within_kills = m_scenario.check_board_within_kills; BBQAutoBattleResult result; try{ result = run_auto_battle(logger, actions, policy); @@ -441,6 +457,60 @@ static void add_tests_BBQAutoBattle(UnitTestDatabase& database){ "Auto Battle: kills heard on the way back reached the target, 10/10. Stop without healing.", }, }, + { + // R3b: 9 kills heard, but the game had completed the quest. The board read + // replaces the 5th pass and its heal. + .name = "near the target, a board without the quest ends it", + .kills_per_clear = {3, 3, 3}, + .check_board_within_kills = 2, + .quest_on_board_per_read = {false}, + .expected_result = BBQAutoBattleResult::QuestDone, + .expected_steps = passes(2) + " " + LAST_PASS + " board", + .expected_seconds = 3 * PASS_SECONDS - ScriptedAutoBattle::HEAL_SECONDS + ScriptedAutoBattle::BOARD_SECONDS, + .expected_log = { + "Auto Battle pass 1: 3 kills, 3/10 in total, HP ?, 46 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle pass 2: 3 kills, 6/10 in total, HP ?, 148 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle pass 3: 3 kills, 9/10 in total, HP ?, 250 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle: the quest is no longer on the board at 9/10 kills heard. Stop: the game completed it.", + }, + }, + { + // Each pass near the target reads the board until the quest is gone. + .name = "near the target, a board with the quest goes again", + .kills_per_clear = {4, 4, 1, 1}, + .check_board_within_kills = 2, + .quest_on_board_per_read = {true, false}, + .expected_result = BBQAutoBattleResult::QuestDone, + .expected_steps = PASS + " " + LAST_PASS + " board heal " + LAST_PASS + " board", + .expected_seconds = 3 * PASS_SECONDS - ScriptedAutoBattle::HEAL_SECONDS + 2 * ScriptedAutoBattle::BOARD_SECONDS, + .expected_log = { + "Auto Battle pass 1: 4 kills, 4/10 in total, HP ?, 46 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle pass 2: 4 kills, 8/10 in total, HP ?, 148 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle: the quest is still on the board at 8/10 kills heard. Go again.", + "Auto Battle pass 3: 1 kills, 9/10 in total, HP ?, 255 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle: the quest is no longer on the board at 9/10 kills heard. Stop: the game completed it.", + }, + }, + { + // Far from the target the board is never read, and reaching the target + // needs no read. + .name = "far from the target, no board read", + .kills_per_clear = {5, 5}, + .check_board_within_kills = 2, + .quest_on_board_per_read = {false}, + .expected_steps = PASS + " " + LAST_PASS, + .expected_seconds = 2 * PASS_SECONDS - LAST_PASS_SAVED_SECONDS, + }, + { + // High HP skips the heal but not the read. + .name = "near the target with high HP, read the board without healing", + .kill_target = 30, + .kills_per_clear = {10, 10, 9, 1}, + .hp_per_clear = {0.9, 0.9, 0.9, 0.9}, + .check_board_within_kills = 2, + .expected_steps = passes(2, LAST_PASS) + " " + LAST_PASS + " board " + LAST_PASS, + .expected_seconds = 4 * (PASS_SECONDS - ScriptedAutoBattle::HEAL_SECONDS) - ScriptedAutoBattle::CLEAR_TAIL_SECONDS + ScriptedAutoBattle::BOARD_SECONDS, + }, }; for (const BBQAutoBattleScenario& scenario : scenarios){ database.add(scenario); diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index f23f8e1d88..45e10cf76f 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -1321,6 +1321,17 @@ BBQAutoBattleResult run_auto_battle( ); return BBQAutoBattleResult::TargetReached; } + //The heard count can fall short of the game's: a kill whose sound was missed still counts + //in game. Near the target, read the board before going again. The read (~5 s) costs much + //less than a pass and its heal. + if (actions.kills() + policy.check_board_within_kills >= policy.kill_target){ + const std::string count_text = std::to_string(actions.kills()) + "/" + std::to_string(policy.kill_target); + if (!actions.quest_on_board()){ + logger.log("Auto Battle: the quest is no longer on the board at " + count_text + " kills heard. Stop: the game completed it."); + return BBQAutoBattleResult::QuestDone; + } + logger.log("Auto Battle: the quest is still on the board at " + count_text + " kills heard. Go again."); + } //Skipping the heal also skips its re-fly: return_to_plaza() already lands on the Central //Plaza fly point, which is where the flight to Chargestone starts from. if (heal){ @@ -1339,10 +1350,13 @@ class ConsoleBBQAutoBattleActions : public BBQAutoBattleActions{ VideoStream& stream, ProControllerContext& context, LetsGoEncounterBotStats& stats, LetsGoEncounterBotTracker& tracker, - LetsGoHpWatcher& hp_watcher + LetsGoHpWatcher& hp_watcher, + const BBQOption& options, + BBQuests quest ) : m_env(env), m_stream(stream), m_context(context) , m_stats(stats), m_tracker(tracker), m_hp_watcher(hp_watcher) + , m_options(options), m_quest(quest) {} virtual uint64_t kills() const override{ @@ -1389,6 +1403,10 @@ class ConsoleBBQAutoBattleActions : public BBQAutoBattleActions{ virtual void return_to_plaza() override{ PokemonSV::return_to_plaza(m_env.program_info(), m_stream, m_context); } + virtual bool quest_on_board() override{ + const std::vector quests = read_quests(m_env.program_info(), m_stream, m_context, m_options); + return std::find(quests.begin(), quests.end(), m_quest) != quests.end(); + } virtual void heal() override{ OverworldWatcher done_healing(m_stream.logger(), COLOR_BLUE); pbf_move_left_joystick(m_context, {0, +1}, 800ms, 160ms); @@ -1418,6 +1436,8 @@ class ConsoleBBQAutoBattleActions : public BBQAutoBattleActions{ LetsGoEncounterBotStats& m_stats; LetsGoEncounterBotTracker& m_tracker; LetsGoHpWatcher& m_hp_watcher; + const BBQOption& m_options; + BBQuests m_quest; }; } @@ -1453,7 +1473,7 @@ void quest_auto_battle( } policy.heal_below_hp_percent = BBQ_OPTIONS.AUTO_BATTLE_HEAL_PERCENT; - ConsoleBBQAutoBattleActions actions(env, stream, context, stats, tracker, sensors.lets_go_hp); + ConsoleBBQAutoBattleActions actions(env, stream, context, stats, tracker, sensors.lets_go_hp, BBQ_OPTIONS, current_quest); run_auto_battle(stream.logger(), actions, policy); } diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h index 94e73c6d1a..daca511d04 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.h @@ -185,6 +185,10 @@ class BBQAutoBattleActions{ //Fly back to Central Plaza. Leaving the cave respawns its Pokemon. virtual void return_to_plaza() = 0; + //At Central Plaza, read the quest panel. Returns whether this quest is still on it: the game + //removes a quest once it is completed. + virtual bool quest_on_board() = 0; + //Walk to the nurse and heal, then fly to the Central Plaza fly point again: the flight to //Chargestone moves the map cursor from there. virtual void heal() = 0; @@ -198,6 +202,9 @@ struct BBQAutoBattlePolicy{ std::chrono::minutes time_limit = std::chrono::minutes(35); //Between passes, heal only if the lead's HP is below this percentage or unknown. uint8_t heal_below_hp_percent = 50; + //After a pass that ends this close to the target, read the board before going again, and + //stop if the quest is gone. 0 never reads it. + uint64_t check_board_within_kills = 2; }; //Why run_auto_battle() returned. @@ -205,6 +212,7 @@ enum class BBQAutoBattleResult{ TargetReached, NoKills, //max_empty_passes passes in a row had no kill. TimeLimit, + QuestDone, //The quest left the board before the heard kills reached the target. }; //Clear Chargestone Cavern, one pass at a time, until the kills reach the target, and return why