From fda42de2195cc135117a749c136047b67d281867 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 27 Oct 2026 23:45:54 -0700 Subject: [PATCH] BBQ: stop an Auto Battle quest once its kills reach the target run_auto_battle() passes the kill target to clear(), so the clear ends as soon as the kills reach it, and on the pass that reaches it returns to Central Plaza without healing or re-flying. In the tests' model this saves 34 s per quest (the 6 s tail, the heal and the re-fly). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Programs/Farming/PokemonSV_BBQTests.cpp | 25 +++++++++++-------- .../Farming/PokemonSV_BlueberryQuests.cpp | 9 +++---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index 541582b6cc..197bd57cb6 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -146,6 +146,8 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ // One pass as it shows in the expected steps. const std::string PASS = "fly clear return heal"; +// A pass that returns without healing. +const std::string LAST_PASS = "fly clear return"; std::string passes(int count){ std::vector ret(count, PASS); @@ -211,40 +213,41 @@ class Test_BBQAutoBattle : public UnitTest{ static void add_tests_BBQAutoBattle(UnitTestDatabase& database){ constexpr int PASS_SECONDS = ScriptedAutoBattle::FLY_SECONDS + ScriptedAutoBattle::CLEAR_SECONDS + ScriptedAutoBattle::RETURN_SECONDS + ScriptedAutoBattle::HEAL_SECONDS; + constexpr int LAST_PASS_SAVED_SECONDS = ScriptedAutoBattle::CLEAR_TAIL_SECONDS + ScriptedAutoBattle::HEAL_SECONDS; const BBQAutoBattleScenario scenarios[] = { { - // The final pass still heals and re-flies, though the quest is done. + // The final pass stops clearing at the target, and skips the heal and re-fly. .name = "auto battle 10 at 2 kills per pass", .kills_per_clear = {2, 2, 2, 2, 2}, - .expected_steps = passes(5), - .expected_seconds = 5 * PASS_SECONDS, + .expected_steps = passes(4) + " " + LAST_PASS, + .expected_seconds = 5 * PASS_SECONDS - LAST_PASS_SAVED_SECONDS, .expected_log = { "Auto Battle pass 1: 2 kills, 2/10 in total, HP ?, 46 s elapsed. Below the target: return, heal and go again.", "Auto Battle pass 2: 2 kills, 4/10 in total, HP ?, 148 s elapsed. Below the target: return, heal and go again.", "Auto Battle pass 3: 2 kills, 6/10 in total, HP ?, 250 s elapsed. Below the target: return, heal and go again.", "Auto Battle pass 4: 2 kills, 8/10 in total, HP ?, 352 s elapsed. Below the target: return, heal and go again.", - "Auto Battle pass 5: 2 kills, 10/10 in total, HP ?, 454 s elapsed. Target reached: return and heal.", + "Auto Battle pass 5: 2 kills, 10/10 in total, HP ?, 448 s elapsed. Target reached: return without healing.", }, }, { .name = "auto battle 30 at 3 kills per pass", .kill_target = 30, .kills_per_clear = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3}, - .expected_steps = passes(10), - .expected_seconds = 10 * PASS_SECONDS, + .expected_steps = passes(9) + " " + LAST_PASS, + .expected_seconds = 10 * PASS_SECONDS - LAST_PASS_SAVED_SECONDS, }, { - // A clear keeps going while kills are heard, past the target. + // Kills heard before the clear can stop still count. .name = "kills past the target", .kills_per_clear = {4, 4, 4}, - .expected_steps = passes(3), - .expected_seconds = 3 * PASS_SECONDS, + .expected_steps = passes(2) + " " + LAST_PASS, + .expected_seconds = 3 * PASS_SECONDS - LAST_PASS_SAVED_SECONDS, }, { .name = "passes with no kill go again", .kills_per_clear = {0, 0, 5, 0, 5}, - .expected_steps = passes(5), - .expected_seconds = 5 * PASS_SECONDS, + .expected_steps = passes(4) + " " + LAST_PASS, + .expected_seconds = 5 * PASS_SECONDS - LAST_PASS_SAVED_SECONDS, }, { // Nothing bounds the loop: with no kills it never ends. diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp index 8dd448ca4c..62d0fd2de5 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include "CommonFramework/Exceptions/OperationFailedExceptionWithScreenshot.h" @@ -1264,8 +1263,7 @@ BBQAutoBattleResult run_auto_battle( const uint64_t kills_before = actions.kills(); actions.fly_to_battle_area(); - //Clear until no kill has been heard for 6 seconds, even past the target. - const std::optional hp = actions.clear(std::numeric_limits::max()); + const std::optional hp = actions.clear(policy.kill_target); const uint64_t kills = actions.kills(); const auto elapsed = std::chrono::duration_cast(actions.now() - start); @@ -1275,7 +1273,7 @@ BBQAutoBattleResult run_auto_battle( std::string next = "Below the target: return, heal and go again."; if (kills >= policy.kill_target){ end = BBQAutoBattleResult::TargetReached; - next = "Target reached: return and heal."; + next = "Target reached: return without healing."; } logger.log( "Auto Battle pass " + std::to_string(pass) + ": " @@ -1286,11 +1284,12 @@ BBQAutoBattleResult run_auto_battle( + next ); + //The next quest starts from Central Plaza, so return even when done. actions.return_to_plaza(); - actions.heal(); if (end){ return *end; } + actions.heal(); } return BBQAutoBattleResult::TargetReached; }