Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@

}

void run_bbq_rounds(Logger& logger, const BBQOption& options, BBQGameActions& game){

Check failure on line 135 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQSoloFarmer.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

PokemonAutomation::NintendoSwitch::PokemonSV::run_bbq_rounds( Logger & logger , const BBQOption & options , BBQGameActions & game): function_lines=129, limit=50, allowed 121
if (!exclusions_leave_a_blue_quest(options)){
throw UserSetupError(logger, "The quest exclusions table skips or rerolls every blue quest the program can do.");
}
Expand Down Expand Up @@ -205,6 +205,7 @@
//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){
Expand All @@ -231,6 +232,8 @@
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);
Expand All @@ -244,6 +247,11 @@
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();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Pokemon SV BBQ Tests

Check failure on line 1 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

<file>: file_lines=1027, limit=1000, allowed 1000
*
* From: https://github.com/PokemonAutomation/
*
Expand Down Expand Up @@ -164,6 +164,7 @@
bool reuse_rerolled_panel = false;

std::vector<std::string> events;
std::vector<BBQuests> attempted_quests;

virtual std::vector<BBQuests> read_quests() override{
events.push_back("read");
Expand Down Expand Up @@ -192,6 +193,7 @@
}
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){
Expand Down Expand Up @@ -267,6 +269,7 @@
BBQOption::OutOfRetries out_of_retries = BBQOption::OutOfRetries::Skip;
bool reuse_rerolled_panel = false;
uint64_t expected_completed = 0;
std::vector<BBQuests> expected_attempted = {};
std::string expected;
};

Expand All @@ -277,7 +280,7 @@
, m_scenario(std::move(scenario))
{}

virtual UnitTestResult run(Logger&, CancellableScope&) const override{

Check failure on line 283 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

PokemonAutomation::NintendoSwitch::PokemonSV::Test_BBQFarmerRounds::run( Logger & , CancellableScope &) const: function_lines=59, limit=50, allowed 50
BBQOption options;
options.NUM_QUESTS.set(m_scenario.num_quests);
options.SAVE_NUM_QUESTS.set(m_scenario.save_num_quests);
Expand Down Expand Up @@ -318,6 +321,18 @@
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<std::string> expected_quests;
std::vector<std::string> 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;
Expand All @@ -340,7 +355,7 @@
return ret;
}

static void add_tests_BBQFarmerRounds(UnitTestDatabase& database){

Check failure on line 358 in SerialPrograms/Source/VideoGames/PokemonSV/Programs/Farming/PokemonSV_BBQTests.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health

PokemonAutomation::NintendoSwitch::PokemonSV::add_tests_BBQFarmerRounds( UnitTestDatabase & database): function_lines=232, limit=50, allowed 197
const std::string round_of_3 = "read process read do completed read do completed read do completed";
std::string read_30_times;
for (int c = 0; c < 30; c++){
Expand All @@ -349,6 +364,41 @@
std::vector<std::pair<BBQuests, BBQAction>> 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,
Expand Down Expand Up @@ -454,17 +504,17 @@
.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
Expand Down
Loading