From 0667c79ac18ab37cce6fc0c896d849cbb6c55317 Mon Sep 17 00:00:00 2001 From: dayfine Date: Tue, 27 Oct 2026 23:51:13 -0700 Subject: [PATCH] BBQ: count kills heard on the way back in the Auto Battle pass log The kill sound is heard in every step, not only while clearing: the lead can finish a kill after the clear ends, as the flight back starts. Each pass counted kills from its own start, so such a kill went into the total but into no pass ("pass 2: 1 kills, 4/10" after "2/10" in R3b). Each pass now counts the kills since the previous pass's line, so the passes add up to the total. Behavior change: when kills heard on the way back reach the target, stop without healing instead of healing and then stopping. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01AKYzhrMnPK61XHWEch4a6E --- .../Programs/Farming/PokemonSV_BBQTests.cpp | 47 +++++++++++++++++++ .../Farming/PokemonSV_BlueberryQuests.cpp | 14 +++++- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp index e5e7fad2a0..196e65e8e3 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp @@ -106,6 +106,9 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ std::vector kills_per_clear; // The lead's HP read in each clear, in turn. Past the end, it is unknown. std::vector> hp_per_clear; + // 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; std::vector steps; int seconds = 0; @@ -136,6 +139,10 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ virtual void return_to_plaza() override{ steps.push_back("return"); seconds += RETURN_SECONDS; + if (m_returns < kills_per_return.size()){ + m_kills += kills_per_return[m_returns]; + } + m_returns++; } virtual void heal() override{ steps.push_back("heal"); @@ -145,6 +152,7 @@ class ScriptedAutoBattle : public BBQAutoBattleActions{ private: uint64_t m_kills = 0; size_t m_clears = 0; + size_t m_returns = 0; }; // One pass as it shows in the expected steps. @@ -172,6 +180,7 @@ struct BBQAutoBattleScenario{ int time_limit_minutes = 35; std::vector kills_per_clear; std::vector> hp_per_clear = {}; // Unknown when not given. + std::vector kills_per_return = {}; // None when not given. int heal_below_hp_percent = 50; BBQAutoBattleResult expected_result = BBQAutoBattleResult::TargetReached; std::string expected_steps; @@ -190,6 +199,7 @@ class Test_BBQAutoBattle : public UnitTest{ ScriptedAutoBattle actions; 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; RecordingLogger logger; BBQAutoBattlePolicy policy; @@ -394,6 +404,43 @@ static void add_tests_BBQAutoBattle(UnitTestDatabase& database){ .expected_steps = passes(3, LAST_PASS), .expected_seconds = 3 * (PASS_SECONDS - ScriptedAutoBattle::HEAL_SECONDS), }, + { + // R3b: "pass 2: 1 kills, 4/10 in total" after "2/10". A kill heard after a pass's + // line counts in the next one, so the passes add up to the total. + .name = "a kill heard on the way back counts in the next pass", + .kills_per_clear = {2, 1, 3, 4}, + .kills_per_return = {1}, + .expected_steps = passes(3) + " " + LAST_PASS, + .expected_seconds = 4 * 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 and HP unknown: return, heal and go again.", + "Auto Battle pass 2: 2 kills, 4/10 in total, HP ?, 148 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle pass 3: 3 kills, 7/10 in total, HP ?, 250 s elapsed. Below the target and HP unknown: return, heal and go again.", + "Auto Battle pass 4: 4 kills, 11/10 in total, HP ?, 346 s elapsed. Target reached: return without healing.", + }, + }, + { + // A pass whose only kill was heard on the previous flight back is not empty. + .name = "a kill heard on the way back resets the empty passes", + .kills_per_clear = {0, 0, 0, 0, 0, 0}, + .kills_per_return = {0, 1}, + .expected_result = BBQAutoBattleResult::NoKills, + .expected_steps = passes(5) + " " + LAST_PASS, + .expected_seconds = 6 * PASS_SECONDS - ScriptedAutoBattle::HEAL_SECONDS, + }, + { + .name = "a kill heard on the way back that reaches the target skips the heal", + .kills_per_clear = {3, 3, 3}, + .kills_per_return = {0, 0, 1}, + .expected_steps = passes(2) + " " + LAST_PASS, + .expected_seconds = 3 * PASS_SECONDS - ScriptedAutoBattle::HEAL_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: kills heard on the way back reached the target, 10/10. Stop without healing.", + }, + }, }; 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 679b833db9..f23f8e1d88 100644 --- a/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp +++ b/SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BlueberryQuests.cpp @@ -1259,9 +1259,12 @@ BBQAutoBattleResult run_auto_battle( const WallClock start = actions.now(); uint64_t pass = 0; uint64_t empty_passes = 0; + //The kill sound is heard in every step, not only while clearing: the lead can finish a kill + //after the clear ends, as the flight back starts. Each pass counts the kills since the last + //pass log, so a kill heard after it goes to the next pass and the passes add up to the total. + uint64_t kills_before = actions.kills(); while (actions.kills() < policy.kill_target){ pass++; - const uint64_t kills_before = actions.kills(); actions.fly_to_battle_area(); const std::optional hp = actions.clear(policy.kill_target); @@ -1303,12 +1306,21 @@ BBQAutoBattleResult run_auto_battle( + std::to_string(elapsed.count()) + " s elapsed. " + next ); + kills_before = kills; //The next quest starts from Central Plaza, so return even when done. actions.return_to_plaza(); if (end){ return *end; } + if (actions.kills() >= policy.kill_target){ + logger.log( + "Auto Battle: kills heard on the way back reached the target, " + + std::to_string(actions.kills()) + "/" + std::to_string(policy.kill_target) + + ". Stop without healing." + ); + return BBQAutoBattleResult::TargetReached; + } //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){