From 225171d940eea2bb49f38c559b3c5dd1a6733e25 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 26 Oct 2025 22:14:00 -0700 Subject: [PATCH 01/34] add extra segments/checkpoints --- .../AutoStory/PokemonSV_AutoStory.cpp | 19 ++++- .../PokemonSV_AutoStory_Segment_34.cpp | 8 -- .../PokemonSV_AutoStory_Segment_34.h | 10 --- .../PokemonSV_AutoStory_Segment_35.cpp | 74 ++++++++++++++++++- .../PokemonSV_AutoStory_Segment_35.h | 50 +++++++++++++ .../PokemonSV_AutoStory_Segment_36.cpp | 66 +++++++++++++++++ .../PokemonSV_AutoStory_Segment_36.h | 35 +++++++++ .../PokemonSV_AutoStory_Segment_37.cpp | 66 +++++++++++++++++ .../PokemonSV_AutoStory_Segment_37.h | 35 +++++++++ .../PokemonSV_AutoStory_Segment_38.cpp | 66 +++++++++++++++++ .../PokemonSV_AutoStory_Segment_38.h | 35 +++++++++ .../PokemonSV_AutoStory_Segment_39.cpp | 66 +++++++++++++++++ .../PokemonSV_AutoStory_Segment_39.h | 35 +++++++++ .../PokemonSV_AutoStory_Segment_40.cpp | 66 +++++++++++++++++ .../PokemonSV_AutoStory_Segment_40.h | 35 +++++++++ SerialPrograms/SourceFiles.cmake | 10 +++ 16 files changed, 656 insertions(+), 20 deletions(-) create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.h create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.h create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.h create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.h create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp create mode 100644 SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 67be7aeb5d..77a65c0be8 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -57,6 +57,11 @@ #include "PokemonSV_AutoStory_Segment_33.h" #include "PokemonSV_AutoStory_Segment_34.h" #include "PokemonSV_AutoStory_Segment_35.h" +#include "PokemonSV_AutoStory_Segment_36.h" +#include "PokemonSV_AutoStory_Segment_37.h" +#include "PokemonSV_AutoStory_Segment_38.h" +#include "PokemonSV_AutoStory_Segment_39.h" +#include "PokemonSV_AutoStory_Segment_40.h" #include "PokemonSV_AutoStory.h" #include @@ -112,7 +117,12 @@ std::vector> make_autoStory_segment_list(){ segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); - // segment_list.emplace_back(std::make_unique()); + segment_list.emplace_back(std::make_unique()); + // segment_list.emplace_back(std::make_unique()); + // segment_list.emplace_back(std::make_unique()); + // segment_list.emplace_back(std::make_unique()); + // segment_list.emplace_back(std::make_unique()); + // segment_list.emplace_back(std::make_unique()); return segment_list; }; @@ -275,6 +285,13 @@ std::vector> make_autoStory_checkpoint_lis checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); + checkpoint_list.emplace_back(std::make_unique()); + checkpoint_list.emplace_back(std::make_unique()); + // checkpoint_list.emplace_back(std::make_unique()); + // checkpoint_list.emplace_back(std::make_unique()); + // checkpoint_list.emplace_back(std::make_unique()); + // checkpoint_list.emplace_back(std::make_unique()); + // checkpoint_list.emplace_back(std::make_unique()); return checkpoint_list; diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.cpp index 02d1435ccb..da5c645e00 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.cpp @@ -244,14 +244,6 @@ void checkpoint_92(SingleSwitchProgramEnvironment& env, ProControllerContext& co }); } -void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - -void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} - -void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ -} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.h index 446c41d488..361b12f0eb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.h @@ -64,17 +64,7 @@ void checkpoint_91(SingleSwitchProgramEnvironment& env, ProControllerContext& co // end: Beat Arven. At Los Platos Pokecenter. void checkpoint_92(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: -void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: -void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); - -// start: -// end: -void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 53c2f4c4af..0bacb01ffb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -52,13 +52,85 @@ void AutoStory_Segment_35::run_segment( context.wait_for_all_requests(); env.console.log("Start Segment " + name(), COLOR_ORANGE); - // checkpoint_(env, context, options.notif_status_update, stats); + AutoStory_Checkpoint_93().run_checkpoint(env, context, options, stats); + context.wait_for_all_requests(); env.console.log("End Segment " + name(), COLOR_GREEN); } +std::string AutoStory_Checkpoint_93::name() const{ return "093 - " + AutoStory_Segment_35().name(); } +std::string AutoStory_Checkpoint_93::start_text() const{ return "";} +std::string AutoStory_Checkpoint_93::end_text() const{ return "";} +void AutoStory_Checkpoint_93::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ + checkpoint_93(env, context, options.notif_status_update, stats); +} + +std::string AutoStory_Checkpoint_94::name() const{ return "094 - " + AutoStory_Segment_35().name(); } +std::string AutoStory_Checkpoint_94::start_text() const{ return "";} +std::string AutoStory_Checkpoint_94::end_text() const{ return "";} +void AutoStory_Checkpoint_94::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ + checkpoint_94(env, context, options.notif_status_update, stats); +} + +std::string AutoStory_Checkpoint_95::name() const{ return "095 - " + AutoStory_Segment_35().name(); } +std::string AutoStory_Checkpoint_95::start_text() const{ return "";} +std::string AutoStory_Checkpoint_95::end_text() const{ return "";} +void AutoStory_Checkpoint_95::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ + checkpoint_95(env, context, options.notif_status_update, stats); +} + +// std::string AutoStory_Checkpoint_96::name() const{ return "096 - " + AutoStory_Segment_3().name(); } +// std::string AutoStory_Checkpoint_96::start_text() const{ return "";} +// std::string AutoStory_Checkpoint_96::end_text() const{ return "";} +// void AutoStory_Checkpoint_96::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ +// checkpoint_96(env, context, options.notif_status_update, stats); +// } + +// std::string AutoStory_Checkpoint_97::name() const{ return "097 - " + AutoStory_Segment_3().name(); } +// std::string AutoStory_Checkpoint_97::start_text() const{ return "";} +// std::string AutoStory_Checkpoint_97::end_text() const{ return "";} +// void AutoStory_Checkpoint_97::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ +// checkpoint_97(env, context, options.notif_status_update, stats); +// } + +// std::string AutoStory_Checkpoint_98::name() const{ return "098 - " + AutoStory_Segment_3().name(); } +// std::string AutoStory_Checkpoint_98::start_text() const{ return "";} +// std::string AutoStory_Checkpoint_98::end_text() const{ return "";} +// void AutoStory_Checkpoint_98::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ +// checkpoint_98(env, context, options.notif_status_update, stats); +// } + +// std::string AutoStory_Checkpoint_99::name() const{ return "099 - " + AutoStory_Segment_3().name(); } +// std::string AutoStory_Checkpoint_99::start_text() const{ return "";} +// std::string AutoStory_Checkpoint_99::end_text() const{ return "";} +// void AutoStory_Checkpoint_99::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ +// checkpoint_99(env, context, options.notif_status_update, stats); +// } + +void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +} + +// void checkpoint_96(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +// } + +// void checkpoint_97(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +// } + +// void checkpoint_98(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +// } + +// void checkpoint_99(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ +// } + + } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h index 982db9ee6f..cc69ac92c0 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h @@ -26,7 +26,57 @@ class AutoStory_Segment_35 : public AutoStory_Segment{ ) const override; }; +class AutoStory_Checkpoint_93 : public AutoStory_Checkpoint{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override; +}; + +class AutoStory_Checkpoint_94 : public AutoStory_Checkpoint{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override; +}; + +class AutoStory_Checkpoint_95 : public AutoStory_Checkpoint{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override; +}; + +// start: +// end: +void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_96(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_97(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); + +// start: +// end: +void checkpoint_98(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); +// start: +// end: +void checkpoint_99(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.cpp new file mode 100644 index 0000000000..9140320030 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.cpp @@ -0,0 +1,66 @@ +/* AutoStory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_36.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + + +std::string AutoStory_Segment_36::name() const{ + return ""; +} + +std::string AutoStory_Segment_36::start_text() const{ + return "Start: "; +} + +std::string AutoStory_Segment_36::end_text() const{ + return "End: "; +} + +void AutoStory_Segment_36::run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats +) const{ + + + stats.m_segment++; + env.update_stats(); + context.wait_for_all_requests(); + env.console.log("Start Segment " + name(), COLOR_ORANGE); + + // AutoStory_Checkpoint_9().run_checkpoint(env, context, options, stats); + + context.wait_for_all_requests(); + env.console.log("End Segment " + name(), COLOR_GREEN); + +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.h new file mode 100644 index 0000000000..d2ea31c292 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.h @@ -0,0 +1,35 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_36_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_36_H + +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_36 : public AutoStory_Segment{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats + ) const override; +}; + + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.cpp new file mode 100644 index 0000000000..25058db639 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.cpp @@ -0,0 +1,66 @@ +/* AutoStory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_37.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + + +std::string AutoStory_Segment_37::name() const{ + return ""; +} + +std::string AutoStory_Segment_37::start_text() const{ + return "Start: "; +} + +std::string AutoStory_Segment_37::end_text() const{ + return "End: "; +} + +void AutoStory_Segment_37::run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats +) const{ + + + stats.m_segment++; + env.update_stats(); + context.wait_for_all_requests(); + env.console.log("Start Segment " + name(), COLOR_ORANGE); + + // AutoStory_Checkpoint_9().run_checkpoint(env, context, options, stats); + + context.wait_for_all_requests(); + env.console.log("End Segment " + name(), COLOR_GREEN); + +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.h new file mode 100644 index 0000000000..a029548119 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.h @@ -0,0 +1,35 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_37_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_37_H + +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_37 : public AutoStory_Segment{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats + ) const override; +}; + + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.cpp new file mode 100644 index 0000000000..33158c60fb --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.cpp @@ -0,0 +1,66 @@ +/* AutoStory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_38.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + + +std::string AutoStory_Segment_38::name() const{ + return ""; +} + +std::string AutoStory_Segment_38::start_text() const{ + return "Start: "; +} + +std::string AutoStory_Segment_38::end_text() const{ + return "End: "; +} + +void AutoStory_Segment_38::run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats +) const{ + + + stats.m_segment++; + env.update_stats(); + context.wait_for_all_requests(); + env.console.log("Start Segment " + name(), COLOR_ORANGE); + + // AutoStory_Checkpoint_9().run_checkpoint(env, context, options, stats); + + context.wait_for_all_requests(); + env.console.log("End Segment " + name(), COLOR_GREEN); + +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.h new file mode 100644 index 0000000000..c8e62174c0 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.h @@ -0,0 +1,35 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_38_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_38_H + +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_38 : public AutoStory_Segment{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats + ) const override; +}; + + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.cpp new file mode 100644 index 0000000000..bc9e910a70 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.cpp @@ -0,0 +1,66 @@ +/* AutoStory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_39.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + + +std::string AutoStory_Segment_39::name() const{ + return ""; +} + +std::string AutoStory_Segment_39::start_text() const{ + return "Start: "; +} + +std::string AutoStory_Segment_39::end_text() const{ + return "End: "; +} + +void AutoStory_Segment_39::run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats +) const{ + + + stats.m_segment++; + env.update_stats(); + context.wait_for_all_requests(); + env.console.log("Start Segment " + name(), COLOR_ORANGE); + + // AutoStory_Checkpoint_9().run_checkpoint(env, context, options, stats); + + context.wait_for_all_requests(); + env.console.log("End Segment " + name(), COLOR_GREEN); + +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.h new file mode 100644 index 0000000000..58760b7387 --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.h @@ -0,0 +1,35 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_39_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_39_H + +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_39 : public AutoStory_Segment{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats + ) const override; +}; + + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp new file mode 100644 index 0000000000..dc0c19231e --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp @@ -0,0 +1,66 @@ +/* AutoStory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include "CommonFramework/Exceptions/OperationFailedException.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "PokemonSV/Programs/PokemonSV_GameEntry.h" +#include "PokemonSV/Programs/PokemonSV_SaveGame.h" +#include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" +#include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" +#include "PokemonSV_AutoStoryTools.h" +#include "PokemonSV_AutoStory_Segment_40.h" + +//#include +//using std::cout; +//using std::endl; +//#include +//#include + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + + + + +std::string AutoStory_Segment_40::name() const{ + return ""; +} + +std::string AutoStory_Segment_40::start_text() const{ + return "Start: "; +} + +std::string AutoStory_Segment_40::end_text() const{ + return "End: "; +} + +void AutoStory_Segment_40::run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats +) const{ + + + stats.m_segment++; + env.update_stats(); + context.wait_for_all_requests(); + env.console.log("Start Segment " + name(), COLOR_ORANGE); + + // AutoStory_Checkpoint_9().run_checkpoint(env, context, options, stats); + + context.wait_for_all_requests(); + env.console.log("End Segment " + name(), COLOR_GREEN); + +} + + + +} +} +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h new file mode 100644 index 0000000000..a34117ff7a --- /dev/null +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h @@ -0,0 +1,35 @@ +/* Autostory + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#ifndef PokemonAutomation_PokemonSV_AutoStory_Segment_40_H +#define PokemonAutomation_PokemonSV_AutoStory_Segment_40_H + +#include "PokemonSV_AutoStoryTools.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonSV{ + +class AutoStory_Segment_40 : public AutoStory_Segment{ +public: + virtual std::string name() const override; + virtual std::string start_text() const override; + virtual std::string end_text() const override; + virtual void run_segment( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + AutoStoryOptions options, + AutoStoryStats& stats + ) const override; +}; + + + + +} +} +} +#endif diff --git a/SerialPrograms/SourceFiles.cmake b/SerialPrograms/SourceFiles.cmake index dbe36de3ea..14f5e83414 100644 --- a/SerialPrograms/SourceFiles.cmake +++ b/SerialPrograms/SourceFiles.cmake @@ -1897,6 +1897,16 @@ file(GLOB LIBRARY_SOURCES Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_34.h Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_36.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_37.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_38.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_39.h + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.cpp + Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_40.h Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOptionDatabase.cpp From 006e2f1a47ff8db4809eb6fe45e184b62f232b66 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 27 Oct 2025 23:02:43 -0700 Subject: [PATCH 02/34] checkpoint 93: Entered Area Zero Gate. Flew down to Area Zero from the platform. --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 4 +- .../PokemonSV_AutoStory_Segment_35.cpp | 129 +++++++++++++++++- .../PokemonSV_AutoStory_Segment_35.h | 4 +- 3 files changed, 129 insertions(+), 8 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 76f42784be..f95a279ca1 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -82,10 +82,10 @@ void clear_dialog(VideoStream& stream, ProControllerContext& context, bool seen_dialog = false; WallClock start = current_time(); while (true){ - if (current_time() - start > std::chrono::minutes(3)){ + if (current_time() - start > std::chrono::minutes(5)){ OperationFailedException::fire( ErrorReport::SEND_ERROR_REPORT, - "clear_dialog(): Failed to clear dialog after 3 minutes.", + "clear_dialog(): Failed to clear dialog after 5 minutes.", stream ); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 0bacb01ffb..9a03f0ca66 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -28,11 +28,11 @@ namespace PokemonSV{ std::string AutoStory_Segment_35::name() const{ - return ""; + return "35: Area Zero Gate, Station 1"; } std::string AutoStory_Segment_35::start_text() const{ - return "Start: "; + return "Start: Beat Nemona, Penny, and Arven. At Los Platos Pokecenter."; } std::string AutoStory_Segment_35::end_text() const{ @@ -61,8 +61,8 @@ void AutoStory_Segment_35::run_segment( } std::string AutoStory_Checkpoint_93::name() const{ return "093 - " + AutoStory_Segment_35().name(); } -std::string AutoStory_Checkpoint_93::start_text() const{ return "";} -std::string AutoStory_Checkpoint_93::end_text() const{ return "";} +std::string AutoStory_Checkpoint_93::start_text() const{ return "Beat Arven. At Los Platos Pokecenter.";} +std::string AutoStory_Checkpoint_93::end_text() const{ return "Entered Area Zero Gate. Flew down to Area Zero from the platform.";} void AutoStory_Checkpoint_93::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ checkpoint_93(env, context, options.notif_status_update, stats); } @@ -110,6 +110,127 @@ void AutoStory_Checkpoint_95::run_checkpoint(SingleSwitchProgramEnvironment& env // } void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + // fly to Medali West + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 95, 0, 170}, FlyPoint::POKECENTER); + + // marker 1 {0.580729, 0.286111} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.580729, 0.286111} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 2 {0.475, 0.4} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.475, 0.4} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 3 {0.473958, 0.260185} {0.479687, 0.250926} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 255, 30}, + FlyPoint::POKECENTER, + {0.479687, 0.250926} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 4 {0.425, 0.289815} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.425, 0.289815} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 5 {0.465104, 0.292593} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 0, 20}, + FlyPoint::POKECENTER, + {0.465104, 0.292593} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 6 {0.439583, 0.274074} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_OUT, 255, 255, 20}, + FlyPoint::POKECENTER, + {0.439583, 0.274074} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 120, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX}); + pbf_move_left_joystick(context, 128, 0, 100, 50); + pbf_move_left_joystick(context, 255, 70, 300, 50); + mash_button_till_overworld(env.console, context, BUTTON_A); + // clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 120, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX, CallbackEnum::PROMPT_DIALOG}); + + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30); + mash_button_till_overworld(env.console, context, BUTTON_A); // prompt, black dialog. random A press + + } void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h index cc69ac92c0..0cf84aedbe 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h @@ -50,8 +50,8 @@ class AutoStory_Checkpoint_95 : public AutoStory_Checkpoint{ virtual void run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const override; }; -// start: -// end: +// start: Beat Arven. At Los Platos Pokecenter. +// end: Entered Area Zero Gate. Flew down to Area Zero from the platform. void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); // start: From 2e192e597110832c776644ab295487199c7ae8a9 Mon Sep 17 00:00:00 2001 From: jw098 Date: Wed, 29 Oct 2025 21:02:04 -0700 Subject: [PATCH 03/34] minor update to checkpoint 93 --- .../PokemonSV_AutoStory_Segment_35.cpp | 252 +++++++++--------- 1 file changed, 130 insertions(+), 122 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 9a03f0ca66..8d84080b4a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -68,8 +68,8 @@ void AutoStory_Checkpoint_93::run_checkpoint(SingleSwitchProgramEnvironment& env } std::string AutoStory_Checkpoint_94::name() const{ return "094 - " + AutoStory_Segment_35().name(); } -std::string AutoStory_Checkpoint_94::start_text() const{ return "";} -std::string AutoStory_Checkpoint_94::end_text() const{ return "";} +std::string AutoStory_Checkpoint_94::start_text() const{ return AutoStory_Checkpoint_93().end_text();} +std::string AutoStory_Checkpoint_94::end_text() const{ return "At Area Zero Station 1.";} void AutoStory_Checkpoint_94::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ checkpoint_94(env, context, options.notif_status_update, stats); } @@ -110,130 +110,138 @@ void AutoStory_Checkpoint_95::run_checkpoint(SingleSwitchProgramEnvironment& env // } void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ - // fly to Medali West - move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 95, 0, 170}, FlyPoint::POKECENTER); - - // marker 1 {0.580729, 0.286111} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.580729, 0.286111} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 20, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 2 {0.475, 0.4} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.475, 0.4} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 20, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 3 {0.473958, 0.260185} {0.479687, 0.250926} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 255, 30}, - FlyPoint::POKECENTER, - {0.479687, 0.250926} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 20, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 4 {0.425, 0.289815} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 0, 0, 0}, - FlyPoint::POKECENTER, - {0.425, 0.289815} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 20, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 5 {0.465104, 0.292593} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::KEEP_ZOOM, 255, 0, 20}, - FlyPoint::POKECENTER, - {0.465104, 0.292593} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 20, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 0, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - // marker 6 {0.439583, 0.274074} - place_marker_offset_from_flypoint(env.program_info(), env.console, context, - {ZoomChange::ZOOM_OUT, 255, 255, 20}, - FlyPoint::POKECENTER, - {0.439583, 0.274074} - ); - handle_when_stationary_in_overworld(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - overworld_navigation(env.program_info(), env.console, context, - NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, - 128, 0, 40, 20, false); - }, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 255, 255, 40, 50); - realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); - } - ); - - clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 120, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX}); - pbf_move_left_joystick(context, 128, 0, 100, 50); - pbf_move_left_joystick(context, 255, 70, 300, 50); - mash_button_till_overworld(env.console, context, BUTTON_A); - // clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 120, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX, CallbackEnum::PROMPT_DIALOG}); - - walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30); - mash_button_till_overworld(env.console, context, BUTTON_A); // prompt, black dialog. random A press - + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + // fly to Medali West + move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 95, 0, 170}, FlyPoint::POKECENTER); + + // marker 1 {0.580729, 0.286111} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.580729, 0.286111} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 2 {0.475, 0.4} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.475, 0.4} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 3 {0.473958, 0.260185} {0.479687, 0.250926} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 255, 30}, + FlyPoint::POKECENTER, + {0.479687, 0.250926} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 4 {0.425, 0.289815} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 0, 0, 0}, + FlyPoint::POKECENTER, + {0.425, 0.289815} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 5 {0.465104, 0.292593} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::KEEP_ZOOM, 255, 0, 20}, + FlyPoint::POKECENTER, + {0.465104, 0.292593} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_MARKER, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 0, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + // marker 6 {0.439583, 0.274074} + place_marker_offset_from_flypoint(env.program_info(), env.console, context, + {ZoomChange::ZOOM_OUT, 255, 255, 20}, + FlyPoint::POKECENTER, + {0.439583, 0.274074} + ); + handle_when_stationary_in_overworld(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + overworld_navigation(env.program_info(), env.console, context, + NavigationStopCondition::STOP_DIALOG, NavigationMovementMode::DIRECTIONAL_ONLY, + 128, 0, 40, 20, false); + }, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_move_left_joystick(context, 255, 255, 40, 50); + realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_OLD_MARKER); + } + ); + + clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 120, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX}); + pbf_move_left_joystick(context, 128, 0, 100, 50); + pbf_move_left_joystick(context, 255, 70, 300, 50); + mash_button_till_overworld(env.console, context, BUTTON_A); + // clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 120, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX, CallbackEnum::PROMPT_DIALOG}); + + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 30); + mash_button_till_overworld(env.console, context, BUTTON_A); // prompt, black dialog. random A press + + }); } void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ + + + }); } void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ From 0f92e892ef74da46ed0b609ca0b65ba413180b03 Mon Sep 17 00:00:00 2001 From: jw098 Date: Fri, 7 Nov 2025 23:50:03 -0800 Subject: [PATCH 04/34] add functions that move player forward and move the camera, based on yolo object detection --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 238 ++++++++++++++++++ .../AutoStory/PokemonSV_AutoStoryTools.h | 71 +++++- 2 files changed, 308 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index f95a279ca1..f5eb0bc728 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1331,6 +1331,244 @@ void checkpoint_reattempt_loop_tutorial( } } +void move_player_forward( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + uint8_t num_rounds, + uint16_t forward_ticks, + uint8_t y, + uint16_t delay_after_forward_move, + uint16_t delay_after_lets_go +){ + + context.wait_for_all_requests(); + for (size_t i = 0; i < num_rounds; i++){ + try{ + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }catch (UnexpectedBattleException&){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + } + } + +} + +ImageFloatBox get_yolo_box( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + VideoOverlaySet& overlays, + YOLOv5Detector& yolo_detector, + const std::string& target_label +){ + context.wait_for_all_requests(); + overlays.clear(); + const std::vector& detected_boxes = yolo_detector.detected_boxes(); + auto snapshot = env.console.video().snapshot(); + yolo_detector.detect(snapshot); + + ImageFloatBox target_box{-1, -1, -1, -1}; + for (YOLOv5Session::DetectionBox detected_box : detected_boxes){ + ImageFloatBox box = detected_box.box; + std::string label = yolo_detector.session()->label_name(detected_box.label_idx); + if (target_label == label){ + target_box = box; + } + overlays.add(COLOR_RED, box, label); + } + + return target_box; +} + +void move_forward_until_yolo_object_above_min_size( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double min_width, double min_height, + std::function&& recovery_action, + uint16_t forward_ticks, + uint8_t y, + uint16_t delay_after_forward_move, + uint16_t delay_after_lets_go +){ + VideoOverlaySet overlays(env.console.overlay()); + size_t num_reattempts = 0; + for (size_t i = 0;;i++){ + try{ + + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + + bool not_found_target = target_box.x == -1; + if (not_found_target){ + num_reattempts++; + if (num_reattempts > 3){ + break; // just assume we're too close to the target to detect it. and continue + } + context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. + continue; + }else{ + num_reattempts = 0; + } + + if (target_box.width < min_width && target_box.height < min_height){ + break; // stop when the target is above a certain size. i.e. we are close enough to the target. + } + + + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }catch (UnexpectedBattleException&){ + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // move_camera_yolo(); + } + } +} + + + +void move_forward_until_yolo_object_detected( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + std::function&& recovery_action, + uint16_t max_rounds, + uint16_t forward_ticks, + uint8_t y, + uint16_t delay_after_forward_move, + uint16_t delay_after_lets_go +){ + VideoOverlaySet overlays(env.console.overlay()); + for (size_t i = 0; ; i++){ + try{ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + bool found_target = target_box.x != -1; + if (found_target){ + break; + } + + if (i > max_rounds){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_forward_until_yolo_object_detected(): Unable to detect target object.", + env.console + ); + } + + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + + }catch (UnexpectedBattleException&){ + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // move_camera_yolo(); + } + } +} + + +void move_camera_yolo( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + CameraAxis axis, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double target_line +){ + VideoOverlaySet overlays(env.console.overlay()); + size_t max_attempts = 10; + size_t num_reattempts = 0; + for (size_t i = 0; i < max_attempts; i++){ + try{ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + + bool not_found_target = target_box.x == -1; + if (not_found_target){ + num_reattempts++; + if (num_reattempts > 3){ + break; // just assume we're too close to the target to detect it. stop. + } + context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. + continue; + }else{ + num_reattempts = 0; + } + + double diff; + switch(axis){ + case CameraAxis::X:{ + double object_x_pos = target_box.x + target_box.width/2; + diff = target_line - object_x_pos; + break; + } + case CameraAxis::Y:{ + double object_y_pos = target_box.y + target_box.height/2; + diff = target_line - object_y_pos; + break; + } + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); + } + + env.console.log("diff: " + std::to_string(diff)); + if (std::abs(diff) < 0.01){ + break; // close enough to target_x. stop. + } + + + double duration_scale_factor; + double push_magnitude_scale_factor; + switch(axis){ + case CameraAxis::X: + duration_scale_factor = 300 / std::sqrt(std::abs(diff)); + if (std::abs(diff) < 0.05){ + duration_scale_factor /= 2; + } + push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); + break; + case CameraAxis::Y: + duration_scale_factor = 200 / std::sqrt(std::abs(diff)); + if (std::abs(diff) < 0.05){ + duration_scale_factor *= 0.75; + } + push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); + break; + + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); + } + + uint16_t push_duration = std::max(uint16_t(std::abs(diff * duration_scale_factor)), uint16_t(8)); + int16_t push_direction = (diff > 0) ? -1 : 1; + double push_magnitude = std::max(double(std::abs(diff * push_magnitude_scale_factor)), double(15)); + uint8_t axis_push = uint8_t(std::max(std::min(int(128 + (push_direction * push_magnitude)), 255), 0)); + + // env.console.log("object_x: {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); + // env.console.log("object_x_pos: " + std::to_string(object_x_pos)); + env.console.log("axis push: " + std::to_string(axis_push) + ", push duration: " + std::to_string(push_duration)); + switch(axis){ + case CameraAxis::X:{ + pbf_move_right_joystick(context, axis_push, 128, push_duration, 100); + break; + } + case CameraAxis::Y:{ + pbf_move_right_joystick(context, 128, axis_push, push_duration, 100); + break; + } + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); + } + + }catch (UnexpectedBattleException&){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + } + } +} + diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index bf5809a9a9..d2fcb45202 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -8,17 +8,18 @@ #define PokemonAutomation_PokemonSV_AutoStoryTools_H #include +#include "ML/Inference/ML_YOLOv5Detector.h" #include "CommonFramework/Language.h" #include "CommonFramework/ImageTools/ImageBoxes.h" #include "CommonFramework/ProgramStats/StatsTracking.h" #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" #include "PokemonSV/Programs/PokemonSV_WorldNavigation.h" -// #include "PokemonSV/Programs/PokemonSV_Navigation.h" namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonSV{ +using namespace ML; struct AutoStoryStats : public StatsTracker{ AutoStoryStats() @@ -74,6 +75,10 @@ enum class NavigationStopCondition{ STOP_BATTLE, }; +// struct MinimumDetectedSize{ +// double width; +// double height; +// }; struct AutoStoryOptions{ @@ -345,11 +350,75 @@ void checkpoint_reattempt_loop_tutorial( ); +// clear path with Let's Go. walk forward forward_ticks. repeat this for num_rounds. +// if detect battle, kill the Pokemon. then continue. If we run into a battle, this round is considered to be done and will not be repeated. +void move_player_forward( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + uint8_t num_rounds, + uint16_t forward_ticks, + uint8_t y, + uint16_t delay_after_forward_move, + uint16_t delay_after_lets_go +); +// get the box of the target object +// return ImageFloatBox{-1, -1, -1, -1} if target object not found +ImageFloatBox get_yolo_box( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + VideoOverlaySet& overlays, + YOLOv5Detector& yolo_detector, + const std::string& target_label +); +// move forward until detected object is a certain width and height on screen (min_size) +// walk forward forward_ticks each time, while clearing path with Let's Go. +// if caught in battle, run recovery_action +void move_forward_until_yolo_object_above_min_size( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double min_width, double min_height, + std::function&& recovery_action, + uint16_t forward_ticks = 100, + uint8_t y = 0, + uint16_t delay_after_forward_move = 50, + uint16_t delay_after_lets_go = 105 +); +// walk forward forward_ticks each time, while clearing path with Let's Go. +// walk until we find the target object. +// if caught in battle, run recovery_action +// throw exception if exceed max_rounds. +void move_forward_until_yolo_object_detected( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + std::function&& recovery_action, + uint16_t max_rounds, + uint16_t forward_ticks = 100, + uint8_t y = 0, + uint16_t delay_after_forward_move = 50, + uint16_t delay_after_lets_go = 105 +); +enum class CameraAxis{ + X, + Y, +}; +// move the camera along `axis` until the target object is aligned with target_line +void move_camera_yolo( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + CameraAxis axis, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double target_line +); From 992db95616a1dcd8d810921dfea69e587f16fd54 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 15:09:19 -0800 Subject: [PATCH 05/34] for routines that move the player/camera based on yolo, throw exception if caught in battle. adjust scale factors for move_camera_yolo --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 244 ++++++++++-------- .../AutoStory/PokemonSV_AutoStoryTools.h | 8 +- 2 files changed, 137 insertions(+), 115 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index f5eb0bc728..570df90702 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1344,8 +1344,11 @@ void move_player_forward( context.wait_for_all_requests(); for (size_t i = 0; i < num_rounds; i++){ try{ - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }); }catch (UnexpectedBattleException&){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); } @@ -1376,6 +1379,9 @@ ImageFloatBox get_yolo_box( overlays.add(COLOR_RED, box, label); } + env.console.log(std::string(target_label) + ": {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); + env.console.log("center-y: " + std::to_string(target_box.y + target_box.height/2) + " center-x: " + std::to_string(target_box.x + target_box.width/2)); + return target_box; } @@ -1393,31 +1399,37 @@ void move_forward_until_yolo_object_above_min_size( ){ VideoOverlaySet overlays(env.console.overlay()); size_t num_reattempts = 0; - for (size_t i = 0;;i++){ + bool reached_target = false; + bool exceed_reattempts = false; + while(!reached_target && !exceed_reattempts){ try{ - - context.wait_for_all_requests(); - ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); - - bool not_found_target = target_box.x == -1; - if (not_found_target){ - num_reattempts++; - if (num_reattempts > 3){ - break; // just assume we're too close to the target to detect it. and continue + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + + bool not_found_target = target_box.x == -1; + if (not_found_target){ + num_reattempts++; + if (num_reattempts > 3){ + exceed_reattempts = true; + return; // when too many failed attempts, just assume we're too close to the target to detect it. + } + context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. + return; + }else{ + num_reattempts = 0; } - context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. - continue; - }else{ - num_reattempts = 0; - } - if (target_box.width < min_width && target_box.height < min_height){ - break; // stop when the target is above a certain size. i.e. we are close enough to the target. - } - - - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + if (target_box.width > min_width && target_box.height > min_height){ + reached_target = true; + return; // stop when the target is above a certain size. i.e. we are close enough to the target. + } + + + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }); }catch (UnexpectedBattleException&){ recovery_action(); // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); @@ -1441,31 +1453,37 @@ void move_forward_until_yolo_object_detected( uint16_t delay_after_lets_go ){ VideoOverlaySet overlays(env.console.overlay()); - for (size_t i = 0; ; i++){ + bool found_target = false; + size_t round_num = 0; + while(!found_target){ try{ - context.wait_for_all_requests(); - ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); - bool found_target = target_box.x != -1; - if (found_target){ - break; - } + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + found_target = target_box.x != -1; + if (found_target){ + return; + } - if (i > max_rounds){ - OperationFailedException::fire( - ErrorReport::SEND_ERROR_REPORT, - "move_forward_until_yolo_object_detected(): Unable to detect target object.", - env.console - ); - } + if (round_num > max_rounds){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_forward_until_yolo_object_detected(): Unable to detect target object.", + env.console + ); + } - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }); }catch (UnexpectedBattleException&){ recovery_action(); // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); // move_camera_yolo(); } + round_num++; } } @@ -1480,88 +1498,92 @@ void move_camera_yolo( ){ VideoOverlaySet overlays(env.console.overlay()); size_t max_attempts = 10; - size_t num_reattempts = 0; + // size_t num_reattempts = 0; + bool reached_target_line = false; for (size_t i = 0; i < max_attempts; i++){ try{ - context.wait_for_all_requests(); - ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); - bool not_found_target = target_box.x == -1; - if (not_found_target){ - num_reattempts++; - if (num_reattempts > 3){ - break; // just assume we're too close to the target to detect it. stop. + bool not_found_target = target_box.x == -1; + if (not_found_target){ + context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. + return; + } + + + double diff; + switch(axis){ + case CameraAxis::X:{ + double object_x_pos = target_box.x + target_box.width/2; + diff = target_line - object_x_pos; + break; + } + case CameraAxis::Y:{ + double object_y_pos = target_box.y + target_box.height/2; + diff = target_line - object_y_pos; + break; + } + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); } - context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. - continue; - }else{ - num_reattempts = 0; - } - - double diff; - switch(axis){ - case CameraAxis::X:{ - double object_x_pos = target_box.x + target_box.width/2; - diff = target_line - object_x_pos; - break; - } - case CameraAxis::Y:{ - double object_y_pos = target_box.y + target_box.height/2; - diff = target_line - object_y_pos; - break; - } - default: - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); - } - env.console.log("diff: " + std::to_string(diff)); - if (std::abs(diff) < 0.01){ - break; // close enough to target_x. stop. - } + env.console.log("diff: " + std::to_string(diff)); + if (std::abs(diff) < 0.01){ + reached_target_line = true; + return; // close enough to target_line. stop. + } - - double duration_scale_factor; - double push_magnitude_scale_factor; - switch(axis){ - case CameraAxis::X: - duration_scale_factor = 300 / std::sqrt(std::abs(diff)); - if (std::abs(diff) < 0.05){ - duration_scale_factor /= 2; + + double duration_scale_factor; + double push_magnitude_scale_factor; + switch(axis){ + case CameraAxis::X: + duration_scale_factor = 250 / std::sqrt(std::abs(diff)); + if (std::abs(diff) < 0.05){ + duration_scale_factor /= 2; + } + push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); + break; + case CameraAxis::Y: + duration_scale_factor = 150 / std::sqrt(std::abs(diff)); + if (std::abs(diff) < 0.1){ + duration_scale_factor *= 0.5; + } + push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); + break; + + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); } - push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); - break; - case CameraAxis::Y: - duration_scale_factor = 200 / std::sqrt(std::abs(diff)); - if (std::abs(diff) < 0.05){ - duration_scale_factor *= 0.75; + + uint16_t push_duration = std::max(uint16_t(std::abs(diff * duration_scale_factor)), uint16_t(8)); + int16_t push_direction = (diff > 0) ? -1 : 1; + double push_magnitude = std::max(double(std::abs(diff * push_magnitude_scale_factor)), double(15)); + uint8_t axis_push = uint8_t(std::max(std::min(int(128 + (push_direction * push_magnitude)), 255), 0)); + + // env.console.log("object_x: {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); + // env.console.log("object_x_pos: " + std::to_string(object_x_pos)); + env.console.log("axis push: " + std::to_string(axis_push) + ", push duration: " + std::to_string(push_duration)); + switch(axis){ + case CameraAxis::X:{ + pbf_move_right_joystick(context, axis_push, 128, push_duration, 100); + break; } - push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); - break; - - default: - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); - } + case CameraAxis::Y:{ + pbf_move_right_joystick(context, 128, axis_push, push_duration, 100); + break; + } + default: + throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); + } + }); - uint16_t push_duration = std::max(uint16_t(std::abs(diff * duration_scale_factor)), uint16_t(8)); - int16_t push_direction = (diff > 0) ? -1 : 1; - double push_magnitude = std::max(double(std::abs(diff * push_magnitude_scale_factor)), double(15)); - uint8_t axis_push = uint8_t(std::max(std::min(int(128 + (push_direction * push_magnitude)), 255), 0)); - - // env.console.log("object_x: {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); - // env.console.log("object_x_pos: " + std::to_string(object_x_pos)); - env.console.log("axis push: " + std::to_string(axis_push) + ", push duration: " + std::to_string(push_duration)); - switch(axis){ - case CameraAxis::X:{ - pbf_move_right_joystick(context, axis_push, 128, push_duration, 100); - break; - } - case CameraAxis::Y:{ - pbf_move_right_joystick(context, 128, axis_push, push_duration, 100); + if(reached_target_line){ break; } - default: - throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); - } }catch (UnexpectedBattleException&){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index d2fcb45202..b75116d605 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -356,10 +356,10 @@ void move_player_forward( SingleSwitchProgramEnvironment& env, ProControllerContext& context, uint8_t num_rounds, - uint16_t forward_ticks, - uint8_t y, - uint16_t delay_after_forward_move, - uint16_t delay_after_lets_go + uint16_t forward_ticks = 100, + uint8_t y = 0, + uint16_t delay_after_forward_move = 50, + uint16_t delay_after_lets_go = 105 ); // get the box of the target object From 9e5db9ca4be21776216a830905509700aec9e363 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 15:09:57 -0800 Subject: [PATCH 06/34] add TEST_YOLO_BOX --- .../AutoStory/PokemonSV_AutoStory.cpp | 55 +++++++++++++++++++ .../Programs/AutoStory/PokemonSV_AutoStory.h | 7 +++ 2 files changed, 62 insertions(+) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 77a65c0be8..d47a677e2f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -3,6 +3,13 @@ * From: https://github.com/PokemonAutomation/ * */ + + +#include "ML/Inference/ML_YOLOv5Detector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonFramework/Exceptions/UnexpectedBattleException.h" + + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" @@ -75,6 +82,7 @@ namespace NintendoSwitch{ namespace PokemonSV{ using namespace Pokemon; +using namespace ML; static constexpr size_t INDEX_OF_LAST_TUTORIAL_SEGMENT = 9; static constexpr size_t INDEX_OF_LAST_TUTORIAL_CHECKPOINT = 20; @@ -675,11 +683,34 @@ AutoStory::AutoStory() LockMode::UNLOCK_WHILE_RUNNING, 0 ) + , TEST_YOLO_BOX( + "TEST: get_yolo_box():", + LockMode::UNLOCK_WHILE_RUNNING, + false + ) + , YOLO_PATH( + false, + "YOLO Path:", + LockMode::LOCK_WHILE_RUNNING, + "PokemonSV/YOLO/yolo_area0_station1.onnx", + "<.onnx file>" + ) + , TARGET_LABEL( + false, + "YOLO Object Label:", + LockMode::LOCK_WHILE_RUNNING, + "rock-1", + "" + ) { if (PreloadSettings::instance().DEVELOPER_MODE){ PA_ADD_OPTION(m_advanced_options); + PA_ADD_OPTION(TEST_YOLO_BOX); + PA_ADD_OPTION(YOLO_PATH); + PA_ADD_OPTION(TARGET_LABEL); + PA_ADD_OPTION(FLYPOINT_TYPE); PA_ADD_OPTION(TEST_FLYPOINT_LOCATIONS); PA_ADD_OPTION(TEST_MOVE_CURSOR_OFFSET_FROM_FLYPOINT); @@ -1154,6 +1185,18 @@ void AutoStory::run_autostory(SingleSwitchProgramEnvironment& env, ProController void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerContext& context){ + + if (TEST_YOLO_BOX){ + VideoOverlaySet overlays(env.console.overlay()); + YOLOv5Detector yolo_detector(RESOURCE_PATH() + std::string(YOLO_PATH)); + + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, TARGET_LABEL); + + context.wait_for(Milliseconds(1000)); + return; + } + + if (TEST_FLYPOINT_LOCATIONS){ print_flypoint_location(env.program_info(), env.console, context, FLYPOINT_TYPE); // print_flypoint_location(env.program_info(), env.console, context, FlyPoint::FAST_TRAVEL); @@ -1217,6 +1260,18 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerCont DirectionDetector direction; + YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/yolo_area0_station1.onnx"); + // move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688); + + // VideoOverlaySet overlays(env.console.overlay()); + // ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, "rock-6"); + // env.console.log("box: {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); + + // move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.5); + // move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.2); + + // move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-6", 0.221875, 0.158333, ) return; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h index ad74fea122..00a5d756cf 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h @@ -11,6 +11,7 @@ #include "Common/Cpp/Options/SimpleIntegerOption.h" #include "Common/Cpp/Options/FloatingPointOption.h" #include "Common/Cpp/Options/EnumDropdownOption.h" +#include "Common/Cpp/Options/StringOption.h" #include "CommonFramework/Notifications/EventNotificationsTable.h" #include "CommonTools/Options/StringSelectOption.h" #include "CommonTools/Options/LanguageOCROption.h" @@ -147,6 +148,12 @@ class AutoStory : public SingleSwitchProgramInstance, public ConfigOption::Liste BooleanCheckBoxOption TEST_MOVE_CURSOR_OFFSET_FROM_FLYPOINT; FloatingPointOption X_OFFSET; FloatingPointOption Y_OFFSET; + + BooleanCheckBoxOption TEST_YOLO_BOX; + StringOption YOLO_PATH; + StringOption TARGET_LABEL; + + }; const std::vector>& ALL_AUTO_STORY_SEGMENT_LIST(); From 053c36c9921b444bd6e5ce3c71662842f987596b Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 15:20:44 -0800 Subject: [PATCH 07/34] add bag detection for run_battle_press_A() --- .../PokemonSV/Programs/PokemonSV_WorldNavigation.cpp | 12 +++++++++++- .../PokemonSV/Programs/PokemonSV_WorldNavigation.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp index bcd6d887fc..919aeaad24 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp @@ -861,13 +861,14 @@ void run_battle_press_A( AdvanceDialogWatcher dialog(COLOR_RED); DialogArrowWatcher dialog_arrow(COLOR_RED, stream.overlay(), {0.850, 0.820, 0.020, 0.050}, 0.8365, 0.846); GradientArrowWatcher next_pokemon(COLOR_BLUE, GradientArrowType::RIGHT, {0.50, 0.51, 0.30, 0.10}); + GradientArrowWatcher bag(COLOR_BLUE, GradientArrowType::RIGHT, {0.10, 0.10, 0.05, 0.90}); MoveSelectWatcher move_select_menu(COLOR_YELLOW); GradientArrowWatcher select_move_target(COLOR_BLUE, GradientArrowType::DOWN, {0.38, 0.08, 0.25, 0.1}); std::vector callbacks; std::vector enum_all_callbacks; // mandatory callbacks: Battle, Overworld, Advance Dialog, Swap menu, Move select - // optional callbacks: DIALOG_ARROW, NEXT_POKEMON, SELECT_MOVE_TARGET, + // optional callbacks: DIALOG_ARROW, NEXT_POKEMON, SELECT_MOVE_TARGET, BATTLE_BAG // merge the mandatory and optional callbacks as a set, to avoid duplicates. then convert to vector std::unordered_set enum_all_callbacks_set{CallbackEnum::BATTLE, CallbackEnum::OVERWORLD, CallbackEnum::ADVANCE_DIALOG, CallbackEnum::SWAP_MENU, CallbackEnum::MOVE_SELECT}; // mandatory callbacks @@ -900,6 +901,9 @@ void run_battle_press_A( case CallbackEnum::SELECT_MOVE_TARGET: callbacks.emplace_back(select_move_target); break; + case CallbackEnum::BATTLE_BAG: + callbacks.emplace_back(bag); + break; default: throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "run_battle_press_A: Unknown callback requested."); } @@ -986,6 +990,11 @@ void run_battle_press_A( stream.log("run_battle_press_A: Detected arrows to select move target. Press A."); pbf_mash_button(context, BUTTON_A, 100); break; + case CallbackEnum::BATTLE_BAG: + stream.log("run_battle_press_A: Detected Bag. Press B. Hold Dpad Up so cursor is back on 'Battle'."); + pbf_mash_button(context, BUTTON_B, 100); + pbf_press_dpad(context, DPAD_UP, 2000ms, 100ms); + break; default: throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "run_battle_press_A: Unknown callback triggered."); @@ -1022,6 +1031,7 @@ void run_wild_battle_press_A( std::unordered_set enum_optional_callbacks, bool detect_wipeout ){ + enum_optional_callbacks.insert(CallbackEnum::BATTLE_BAG); // check for Bag. run_battle_press_A(stream, context, stop_condition, enum_optional_callbacks, detect_wipeout); } diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h index a7de9d897a..9f2a913999 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.h @@ -58,6 +58,7 @@ enum class CallbackEnum{ SWAP_MENU, MOVE_SELECT, SELECT_MOVE_TARGET, + BATTLE_BAG, }; enum class ZoomChange{ From 989fc4d6d18803a89bfa5ab568657d7bacc7c585 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 15:31:49 -0800 Subject: [PATCH 08/34] clear YOLO overlays when caught in battle --- .../PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 570df90702..55e1aa720c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1431,6 +1431,7 @@ void move_forward_until_yolo_object_above_min_size( pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); }); }catch (UnexpectedBattleException&){ + overlays.clear(); recovery_action(); // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); // move_camera_yolo(); @@ -1479,6 +1480,7 @@ void move_forward_until_yolo_object_detected( }); }catch (UnexpectedBattleException&){ + overlays.clear(); recovery_action(); // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); // move_camera_yolo(); @@ -1586,6 +1588,7 @@ void move_camera_yolo( } }catch (UnexpectedBattleException&){ + overlays.clear(); run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); } } From beba56c64ef8100493f190b3ed5c3f8fc43ad9d1 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 16:41:25 -0800 Subject: [PATCH 09/34] add move_forward_until_yolo_object_not_detected(). change color of overlays if it's the target object. --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 50 ++++++++++++++++++- .../AutoStory/PokemonSV_AutoStoryTools.h | 15 ++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 55e1aa720c..976a3a9e72 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1375,8 +1375,11 @@ ImageFloatBox get_yolo_box( std::string label = yolo_detector.session()->label_name(detected_box.label_idx); if (target_label == label){ target_box = box; + overlays.add(COLOR_RED, box, label); + }else{ + overlays.add(COLOR_BLUE, box, label); } - overlays.add(COLOR_RED, box, label); + } env.console.log(std::string(target_label) + ": {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); @@ -1397,6 +1400,9 @@ void move_forward_until_yolo_object_above_min_size( uint16_t delay_after_forward_move, uint16_t delay_after_lets_go ){ + context.wait_for_all_requests(); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + VideoOverlaySet overlays(env.console.overlay()); size_t num_reattempts = 0; bool reached_target = false; @@ -1453,6 +1459,9 @@ void move_forward_until_yolo_object_detected( uint16_t delay_after_forward_move, uint16_t delay_after_lets_go ){ + context.wait_for_all_requests(); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + VideoOverlaySet overlays(env.console.overlay()); bool found_target = false; size_t round_num = 0; @@ -1489,6 +1498,45 @@ void move_forward_until_yolo_object_detected( } } +void move_forward_until_yolo_object_not_detected( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + std::function&& recovery_action, + uint16_t forward_ticks, + uint8_t y, + uint16_t delay_after_forward_move, + uint16_t delay_after_lets_go +){ + VideoOverlaySet overlays(env.console.overlay()); + bool target_visible = true; + size_t round_num = 0; + while(target_visible){ + try{ + do_action_and_monitor_for_battles(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + target_visible = target_box.x != -1; + if (!target_visible){ // stop when target not visible + return; + } + + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }); + + }catch (UnexpectedBattleException&){ + overlays.clear(); + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // move_camera_yolo(); + } + round_num++; + } +} + void move_camera_yolo( SingleSwitchProgramEnvironment& env, diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index b75116d605..593b31fd1a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -405,6 +405,21 @@ void move_forward_until_yolo_object_detected( uint16_t delay_after_lets_go = 105 ); +// walk forward forward_ticks each time, while clearing path with Let's Go. +// walk until we no longer see the target object. +// if caught in battle, run recovery_action +void move_forward_until_yolo_object_not_detected( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + std::function&& recovery_action, + uint16_t forward_ticks = 100, + uint8_t y = 0, + uint16_t delay_after_forward_move = 50, + uint16_t delay_after_lets_go = 105 +); + enum class CameraAxis{ X, Y, From 9369570f8c08b31afbcf8b06c11c59c35dbc4db4 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 17:25:38 -0800 Subject: [PATCH 10/34] add do_action_and_monitor_for_battles_early(), which uses NoMinimapWatcher --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 42 +++++++++++++++++-- .../AutoStory/PokemonSV_AutoStoryTools.h | 13 ++++++ 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 976a3a9e72..eab6849f9e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -17,6 +17,7 @@ #include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h" #include "PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h" #include "PokemonSV/Inference/Overworld/PokemonSV_StationaryOverworldWatcher.h" +#include "PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h" #include "PokemonSV/Inference/PokemonSV_MainMenuDetector.h" #include "PokemonSV/Programs/PokemonSV_MenuNavigation.h" #include "PokemonSV/Programs/PokemonSV_GameEntry.h" @@ -728,6 +729,41 @@ void do_action_and_monitor_for_battles( } } +void do_action_and_monitor_for_battles_early( + const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context, + std::function< + void(const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context) + >&& action +){ + NoMinimapWatcher no_minimap(stream.logger(), COLOR_RED, Milliseconds(250)); + int ret = run_until( + stream, context, + [&](ProControllerContext& context){ + context.wait_for_all_requests(); + action(info, stream, context); + }, + {no_minimap} + ); + if (ret == 0){ // if see no minimap. stop and see if we detect a battle. if so, throw Battl exception + do_action_and_monitor_for_battles(info, stream, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + pbf_wait(context, Seconds(10)); + }); + + // if no battle seen, then throw Exception. + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "do_action_and_monitor_for_battles_early(): Expected to see a battle, but didn't. Possible false positive on NoMinimapWatcher.", + stream + ); + } + +} + void handle_unexpected_battles( const ProgramInfo& info, @@ -1344,7 +1380,7 @@ void move_player_forward( context.wait_for_all_requests(); for (size_t i = 0; i < num_rounds; i++){ try{ - do_action_and_monitor_for_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); @@ -1409,7 +1445,7 @@ void move_forward_until_yolo_object_above_min_size( bool exceed_reattempts = false; while(!reached_target && !exceed_reattempts){ try{ - do_action_and_monitor_for_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ context.wait_for_all_requests(); ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); @@ -1467,7 +1503,7 @@ void move_forward_until_yolo_object_detected( size_t round_num = 0; while(!found_target){ try{ - do_action_and_monitor_for_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ context.wait_for_all_requests(); ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 593b31fd1a..0209a820fb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -186,6 +186,19 @@ void do_action_and_monitor_for_battles( >&& action ); +// run the given `action`. if detect a no minimap, stop the action. +// wait 10 seconds and see if we find a battle. if so, throw Battle exception. if no battle, then throw OperationFailedException +void do_action_and_monitor_for_battles_early( + const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context, + std::function< + void(const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context) + >&& action +); + // catch any UnexpectedBattle exceptions from `action`. then use run_battle_press_A until overworld, and re-try the `action`. void handle_unexpected_battles( const ProgramInfo& info, From feba15f3062e7f0751a6f7037970a535ca11ae9c Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 17:50:28 -0800 Subject: [PATCH 11/34] add times_not_seen_threshold to move_forward_until_yolo_object_not_detected() --- .../Programs/AutoStory/PokemonSV_AutoStoryTools.cpp | 13 +++++++++---- .../Programs/AutoStory/PokemonSV_AutoStoryTools.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index eab6849f9e..15f5e04326 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1539,6 +1539,7 @@ void move_forward_until_yolo_object_not_detected( ProControllerContext& context, YOLOv5Detector& yolo_detector, const std::string& target_label, + size_t times_not_seen_threshold, std::function&& recovery_action, uint16_t forward_ticks, uint8_t y, @@ -1547,16 +1548,20 @@ void move_forward_until_yolo_object_not_detected( ){ VideoOverlaySet overlays(env.console.overlay()); bool target_visible = true; + size_t times_not_seen = 0; size_t round_num = 0; - while(target_visible){ + while(times_not_seen < times_not_seen_threshold){ try{ - do_action_and_monitor_for_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ context.wait_for_all_requests(); ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); target_visible = target_box.x != -1; if (!target_visible){ // stop when target not visible - return; + times_not_seen++; + if (times_not_seen >= times_not_seen_threshold){ + return; + } } pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); @@ -1588,7 +1593,7 @@ void move_camera_yolo( bool reached_target_line = false; for (size_t i = 0; i < max_attempts; i++){ try{ - do_action_and_monitor_for_battles(env.program_info(), env.console, context, + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ context.wait_for_all_requests(); ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 0209a820fb..647a21688e 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -419,13 +419,14 @@ void move_forward_until_yolo_object_detected( ); // walk forward forward_ticks each time, while clearing path with Let's Go. -// walk until we no longer see the target object. +// walk until we no longer see the target object. and haven't seen `it times_not_seen_threshold` times. // if caught in battle, run recovery_action void move_forward_until_yolo_object_not_detected( SingleSwitchProgramEnvironment& env, ProControllerContext& context, YOLOv5Detector& yolo_detector, const std::string& target_label, + size_t times_not_seen_threshold, std::function&& recovery_action, uint16_t forward_ticks = 100, uint8_t y = 0, From c769f667ec312ef0607ce1520d3215b91127877c Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 18:07:13 -0800 Subject: [PATCH 12/34] partial checkpoint_94: arrive at rock-3 --- .../AutoStory/PokemonSV_AutoStory.cpp | 9 +- .../PokemonSV_AutoStory_Segment_35.cpp | 126 +++++++++++++++++- 2 files changed, 120 insertions(+), 15 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index d47a677e2f..03437840a7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -1262,16 +1262,9 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, ProControllerCont YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/yolo_area0_station1.onnx"); // move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688); + // move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688); - // VideoOverlaySet overlays(env.console.overlay()); - // ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, "rock-6"); - // env.console.log("box: {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); - // move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.5); - // move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.2); - - // move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-6", 0.221875, 0.158333, ) return; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 8d84080b4a..98a266efc9 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -4,6 +4,9 @@ * */ +#include "ML/Inference/ML_YOLOv5Detector.h" +#include "CommonFramework/VideoPipeline/VideoFeed.h" + #include "CommonFramework/Exceptions/OperationFailedException.h" #include "CommonTools/Async/InferenceRoutines.h" #include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" @@ -17,15 +20,13 @@ //#include //using std::cout; //using std::endl; -//#include -//#include namespace PokemonAutomation{ namespace NintendoSwitch{ namespace PokemonSV{ - +using namespace ML; std::string AutoStory_Segment_35::name() const{ return "35: Area Zero Gate, Station 1"; @@ -237,11 +238,122 @@ void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& co } void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ - checkpoint_reattempt_loop(env, context, notif_status_update, stats, - [&](size_t attempt_number){ - + // checkpoint_reattempt_loop(env, context, notif_status_update, stats, + // [&](size_t attempt_number){ + + + YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/yolo_area0_station1.onnx"); + + #if 0 + #endif + + move_player_forward(env, context, 6); + + // confirm we can see tree-tera + move_forward_until_yolo_object_detected(env, context, yolo_detector, "tree-tera", + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + }, + 5 + ); + // align to tree-tera. center-y: 0.294444 center-x: 0.604688 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688); + + // move towards tree-tera until {0.721875, 0.277778, 0.146875, 0.180556} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-tera", + 0.146, 0.180, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.583594); + } + ); + + // align to rock-1. center-y: 0.191667 center-x: 0.583594 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-1", 0.191667); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.583594); + + // move towards rock-1 until {0.626563, 0.113889, 0.279688, 0.230556} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-1", + 0.279, 0.230, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.564063); + } + ); + + + // align to rock-2. center-y: 0.194444 center-x: 0.508594 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-2", 0.194444); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.508594); + + + // move towards rock-2 until {0.471875, 0.244444, 0.103125, 0.266667} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-2", + 0.103, 0.266, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.535937); + } + ); + + // align to rock-3. center-y: 0.190278 center-x: 0.566406 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.190278); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.566406); + + // move towards rock-3 until {0.598438, 0.186111, 0.121875, 0.136111} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-3", + 0.121, 0.136, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.535937); + } + ); + + + // align to stream. center-y: 0.481944 center-x: 0.528906 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "stream", 0.481944); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.528906); + + + // move forward until stream not detected + move_forward_until_yolo_object_not_detected(env, context, yolo_detector, "stream", + 3, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.5); + } + ); + + // confirm we can see rock-3 + move_forward_until_yolo_object_detected(env, context, yolo_detector, "rock-3", + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + }, + 9 + ); + + // align to rock-3. center-y: 0.291667 center-x: 0.501563 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.291667); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563); + + // move towards rock-3 until {0.371875, 0.038889, 0.257812, 0.286111} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-3", + 0.257, 0.25, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563); + } + ); + + + + + + + - }); + // }); } void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ From a395af12f21f76addae9863d7f2d02216072ba4b Mon Sep 17 00:00:00 2001 From: jw098 Date: Sat, 8 Nov 2025 23:54:49 -0800 Subject: [PATCH 13/34] add move_player_to_realign_via_yolo() --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 109 +++++++++++++++++- .../AutoStory/PokemonSV_AutoStoryTools.h | 17 ++- 2 files changed, 123 insertions(+), 3 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 15f5e04326..ddd376a64f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1589,8 +1589,9 @@ void move_camera_yolo( ){ VideoOverlaySet overlays(env.console.overlay()); size_t max_attempts = 10; - // size_t num_reattempts = 0; + size_t num_reattempts = 0; bool reached_target_line = false; + bool exceed_reattempts = false; for (size_t i = 0; i < max_attempts; i++){ try{ do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, @@ -1600,8 +1601,15 @@ void move_camera_yolo( bool not_found_target = target_box.x == -1; if (not_found_target){ + num_reattempts++; + if (num_reattempts > 3){ + exceed_reattempts = true; + return; // when too many failed attempts, just assume we're too close to the target to detect it. + } context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. return; + }else{ + num_reattempts = 0; } @@ -1672,7 +1680,7 @@ void move_camera_yolo( } }); - if(reached_target_line){ + if(reached_target_line || exceed_reattempts){ break; } @@ -1683,6 +1691,103 @@ void move_camera_yolo( } } +bool move_player_to_realign_via_yolo( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double x_target +){ + + VideoOverlaySet overlays(env.console.overlay()); + size_t max_attempts = 10; + size_t num_reattempts = 0; + bool reached_target_line = false; + bool exceed_reattempts = false; + for (size_t i = 0; i < max_attempts; i++){ + try{ + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + + bool not_found_target = target_box.x == -1; + if (not_found_target){ + num_reattempts++; + if (num_reattempts > 3){ + exceed_reattempts = true; + return; // when too many failed attempts, just assume we're too close to the target to detect it. + } + context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. + return; + }else{ + num_reattempts = 0; + } + + double object_x_pos = target_box.x + target_box.width/2; + double diff = x_target - object_x_pos; + + env.console.log("diff: " + std::to_string(diff)); + if (std::abs(diff) < 0.05){ + reached_target_line = true; + return; // close enough to target_line. stop. + } + + double duration_scale_factor = 500 / std::sqrt(std::abs(diff)); + // if (std::abs(diff) < 0.05){ + // duration_scale_factor /= 2; + // } + double push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); + + uint16_t push_duration = std::max(uint16_t(std::abs(diff * duration_scale_factor)), uint16_t(8)); + int16_t push_direction = (diff > 0) ? -1 : 1; + double push_magnitude = std::max(double(std::abs(diff * push_magnitude_scale_factor)), double(15)); + uint8_t x_push = uint8_t(std::max(std::min(int(128 + (push_direction * push_magnitude)), 255), 0)); + + // env.console.log("object_x: {" + std::to_string(target_box.x) + ", " + std::to_string(target_box.y) + ", " + std::to_string(target_box.width) + ", " + std::to_string(target_box.height) + "}"); + // env.console.log("object_x_pos: " + std::to_string(object_x_pos)); + env.console.log("x push: " + std::to_string(x_push) + ", push duration: " + std::to_string(push_duration)); + if (i == 0){ + pbf_move_left_joystick(context, x_push, 128, 10, 50); + pbf_press_button(context, BUTTON_R, 20, 105); + } + + pbf_move_left_joystick(context, x_push, 128, push_duration, 100); + + }); + + if (exceed_reattempts){ + return false; + } + + if(reached_target_line){ + return true; + } + + }catch (UnexpectedBattleException&){ + overlays.clear(); + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + } + } + + return false; +} + + +void move_player_to_realign_via_yolo_with_recovery( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double x_target, + std::function&& recovery_action +){ + bool succeed_realign_attempt_1 = move_player_to_realign_via_yolo(env, context, yolo_detector, target_label, x_target); + if (!succeed_realign_attempt_1){ + recovery_action(); + move_player_to_realign_via_yolo(env, context, yolo_detector, target_label, x_target); // second attempt. + } +} diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 647a21688e..034599a2bd 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -449,8 +449,23 @@ void move_camera_yolo( double target_line ); +// move the player sideways until the target object is aligned with x_target +bool move_player_to_realign_via_yolo( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double x_target +); - +void move_player_to_realign_via_yolo_with_recovery( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + double x_target, + std::function&& recovery_action +); } From e5ce75e871cb3f79e5155441875a775b24b844e1 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 00:04:37 -0800 Subject: [PATCH 14/34] adjust recovery routine after battle to use move_player_to_realign_via_yolo() --- .../PokemonSV_AutoStory_Segment_35.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 98a266efc9..39f5977db7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -265,7 +265,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.146, 0.180, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.583594); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.583594); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -278,7 +279,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.279, 0.230, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.564063); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.564063); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -293,7 +295,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.103, 0.266, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.535937); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.535937); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -306,7 +309,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.121, 0.136, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.535937); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.535937); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -321,7 +325,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 3, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.5); + move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.5); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -342,7 +347,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.257, 0.25, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.501563); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); From 666bc6922b56df9cf20717103dec87654d819541 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 13:06:50 -0800 Subject: [PATCH 15/34] add move_camera_until_yolo_object_detected() --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 51 +++++++++++++++++++ .../AutoStory/PokemonSV_AutoStoryTools.h | 14 +++++ 2 files changed, 65 insertions(+) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index ddd376a64f..a75c9d1ecb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1790,6 +1790,57 @@ void move_player_to_realign_via_yolo_with_recovery( } +void move_camera_until_yolo_object_detected( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + uint8_t initial_x_move, + uint16_t initial_hold_ticks, + std::function&& recovery_action, + uint16_t max_rounds +){ + VideoOverlaySet overlays(env.console.overlay()); + bool found_target = false; + size_t round_num = 0; + uint8_t x_move = initial_x_move > 128 ? 255 : 0; + while(!found_target){ + try{ + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + + if (round_num == 0){ + pbf_move_right_joystick(context, initial_x_move, 128, initial_hold_ticks, 50); + } + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + found_target = target_box.x != -1; + if (found_target){ + return; + } + + if (round_num > max_rounds){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_camera_until_yolo_object_detected(): Unable to detect target object.", + env.console + ); + } + + pbf_move_right_joystick(context, x_move, 128, 10, 50); + }); + + }catch (UnexpectedBattleException&){ + overlays.clear(); + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // move_camera_yolo(); + } + round_num++; + } +} + + } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 034599a2bd..639a39e166 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -467,6 +467,20 @@ void move_player_to_realign_via_yolo_with_recovery( std::function&& recovery_action ); +// move camera in X direction until we find the target object. +// if caught in battle, run recovery_action +// throw exception if exceed max_rounds. +void move_camera_until_yolo_object_detected( + SingleSwitchProgramEnvironment& env, + ProControllerContext& context, + YOLOv5Detector& yolo_detector, + const std::string& target_label, + uint8_t initial_x_move, + uint16_t initial_hold_ticks, + std::function&& recovery_action, + uint16_t max_rounds = 50 +); + } } From 83c1c863e5f8f97c5e4dc95112e4c11f77d52b0c Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 15:38:25 -0800 Subject: [PATCH 16/34] add do_action_until_dialog(). adjust move_player_forward() to include a recovery_action --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 51 ++++++++++++++++--- .../AutoStory/PokemonSV_AutoStoryTools.h | 18 +++++-- 2 files changed, 59 insertions(+), 10 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index a75c9d1ecb..7345837fda 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -751,7 +751,7 @@ void do_action_and_monitor_for_battles_early( if (ret == 0){ // if see no minimap. stop and see if we detect a battle. if so, throw Battl exception do_action_and_monitor_for_battles(info, stream, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_wait(context, Seconds(10)); + pbf_wait(context, Seconds(15)); }); // if no battle seen, then throw Exception. @@ -765,6 +765,44 @@ void do_action_and_monitor_for_battles_early( } +void do_action_until_dialog( + const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context, + std::function< + void(const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context) + >&& action +){ + AdvanceDialogWatcher dialog(COLOR_RED); + int ret = run_until( + stream, context, + [&](ProControllerContext& context){ + context.wait_for_all_requests(); + action(info, stream, context); + }, + {dialog} + ); + context.wait_for(std::chrono::milliseconds(100)); + + switch (ret){ + case 0: // dialog + stream.log("do_action_until_dialog(): Detected dialog."); + return; + default: + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "do_action_until_dialog(): Finished action. Did not detect dialog.", + stream + ); + } + +} + + + + void handle_unexpected_battles( const ProgramInfo& info, VideoStream& stream, @@ -1371,6 +1409,7 @@ void move_player_forward( SingleSwitchProgramEnvironment& env, ProControllerContext& context, uint8_t num_rounds, + std::function&& recovery_action, uint16_t forward_ticks, uint8_t y, uint16_t delay_after_forward_move, @@ -1386,7 +1425,8 @@ void move_player_forward( pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); }); }catch (UnexpectedBattleException&){ - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); } } @@ -1647,7 +1687,7 @@ void move_camera_yolo( push_magnitude_scale_factor = 60 / std::sqrt(std::abs(diff)); break; case CameraAxis::Y: - duration_scale_factor = 150 / std::sqrt(std::abs(diff)); + duration_scale_factor = 100 / std::sqrt(std::abs(diff)); if (std::abs(diff) < 0.1){ duration_scale_factor *= 0.5; } @@ -1797,7 +1837,6 @@ void move_camera_until_yolo_object_detected( const std::string& target_label, uint8_t initial_x_move, uint16_t initial_hold_ticks, - std::function&& recovery_action, uint16_t max_rounds ){ VideoOverlaySet overlays(env.console.overlay()); @@ -1832,9 +1871,7 @@ void move_camera_until_yolo_object_detected( }catch (UnexpectedBattleException&){ overlays.clear(); - recovery_action(); - // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - // move_camera_yolo(); + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); } round_num++; } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 639a39e166..89d13a0940 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -186,8 +186,8 @@ void do_action_and_monitor_for_battles( >&& action ); -// run the given `action`. if detect a no minimap, stop the action. -// wait 10 seconds and see if we find a battle. if so, throw Battle exception. if no battle, then throw OperationFailedException +// run the given `action`. if detect no minimap, stop the action. +// wait 15 seconds and see if we find a battle. if so, throw Battle exception. if no battle, then throw OperationFailedException void do_action_and_monitor_for_battles_early( const ProgramInfo& info, VideoStream& stream, @@ -199,6 +199,18 @@ void do_action_and_monitor_for_battles_early( >&& action ); +void do_action_until_dialog( + const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context, + std::function< + void(const ProgramInfo& info, + VideoStream& stream, + ProControllerContext& context) + >&& action +); + + // catch any UnexpectedBattle exceptions from `action`. then use run_battle_press_A until overworld, and re-try the `action`. void handle_unexpected_battles( const ProgramInfo& info, @@ -369,6 +381,7 @@ void move_player_forward( SingleSwitchProgramEnvironment& env, ProControllerContext& context, uint8_t num_rounds, + std::function&& recovery_action, uint16_t forward_ticks = 100, uint8_t y = 0, uint16_t delay_after_forward_move = 50, @@ -477,7 +490,6 @@ void move_camera_until_yolo_object_detected( const std::string& target_label, uint8_t initial_x_move, uint16_t initial_hold_ticks, - std::function&& recovery_action, uint16_t max_rounds = 50 ); From b1617f7dabe25e975fc3e0d6442265d3e463a16b Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 15:41:07 -0800 Subject: [PATCH 17/34] partial checkpoint_94: arrive at station-1 dialog --- .../PokemonSV_AutoStory_Segment_35.cpp | 119 +++++++++++++++++- 1 file changed, 118 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 39f5977db7..8169a676bb 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -247,7 +247,11 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co #if 0 #endif - move_player_forward(env, context, 6); + move_player_forward(env, context, 6, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + } + ); // confirm we can see tree-tera move_forward_until_yolo_object_detected(env, context, yolo_detector, "tree-tera", @@ -355,6 +359,119 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co + // align to rock-4. center-y: 0.200000 center-x: 0.575000 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.575000); + + // move towards rock-4 until {0.621875, 0.202778, 0.262500, 0.177778} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-4", + 0.25, 0.177, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.575000); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + + move_camera_until_yolo_object_detected(env, context, yolo_detector, "tree-1", 0, 70); + + // align to tree-1. center-y: 0.390278 center-x: 0.5 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-1", 0.390278); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.5); + + // move towards tree-1 until {0.064063, 0.002778, 0.523438, 0.305556} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-1", + 0.52, 0.27, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + + + // align to tree-1. center-y: 0.341667 center-x: 0.500000 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-1", 0.341667); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.500000); + + // move towards tree-1 until {-0.064063, -0.008333, 1.073438, 0.602778} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-1", + 0.9, 0.500, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.500000); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + + move_camera_until_yolo_object_detected(env, context, yolo_detector, "rock-5", 255, 50); + + // align to rock-5. center-y: 0.206944 center-x: 0.600000 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-5", 0.206944); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5", 0.600000); + + // move towards rock-5 until {0.548438, -0.002778, 0.271875, 0.327778} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-5", + 0.271875, 0.327778, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.600000); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + + move_camera_until_yolo_object_detected(env, context, yolo_detector, "rock-6", 255, 50); + + + + // align to rock-6. center-y: 0.333333 center-x: 0.372656 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.333333); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656); + + // move towards rock-6 until {0.148438, 0.313889, 0.225000, 0.119444} + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-6", + 0.22, 0.119, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.372656); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + + + // align to station-1. center-y: 0.286111 center-x: 0.483594 + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "station-1", 0.286111); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.483594); + + do_action_until_dialog(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + move_player_forward(env, context, 10, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.5); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + } + ); + + #if 0 + // align to rock. + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock", 0.000); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock", 0.000); + + // move towards rock until + move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock", + 0.000, 0.000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + + #endif + From cee3086f2d1e7a327ef9d3fb2080a3091439c11d Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 16:33:59 -0800 Subject: [PATCH 18/34] add recovery action to move_camera_yolo() --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 6 +- .../AutoStory/PokemonSV_AutoStoryTools.h | 4 +- .../PokemonSV_AutoStory_Segment_35.cpp | 215 +++++++++++++++--- 3 files changed, 195 insertions(+), 30 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 7345837fda..98df1cc478 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1625,7 +1625,8 @@ void move_camera_yolo( CameraAxis axis, YOLOv5Detector& yolo_detector, const std::string& target_label, - double target_line + double target_line, + std::function&& recovery_action ){ VideoOverlaySet overlays(env.console.overlay()); size_t max_attempts = 10; @@ -1726,7 +1727,8 @@ void move_camera_yolo( }catch (UnexpectedBattleException&){ overlays.clear(); - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); } } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 89d13a0940..1415ee60de 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -453,13 +453,15 @@ enum class CameraAxis{ }; // move the camera along `axis` until the target object is aligned with target_line +// if caught in battle, run recovery_action void move_camera_yolo( SingleSwitchProgramEnvironment& env, ProControllerContext& context, CameraAxis axis, YOLOv5Detector& yolo_detector, const std::string& target_label, - double target_line + double target_line, + std::function&& recovery_action ); // move the player sideways until the target object is aligned with x_target diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 8169a676bb..523a7d1c20 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -261,8 +261,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 5 ); // align to tree-tera. center-y: 0.294444 center-x: 0.604688 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-tera", 0.294444, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.277344); // x-position of tree-tera prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.277344); // x-position of tree-tera prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards tree-tera until {0.721875, 0.277778, 0.146875, 0.180556} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-tera", @@ -275,8 +287,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co ); // align to rock-1. center-y: 0.191667 center-x: 0.583594 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-1", 0.191667); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.583594); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-1", 0.191667, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.578); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.583594, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.578); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-1 until {0.626563, 0.113889, 0.279688, 0.230556} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-1", @@ -290,8 +314,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to rock-2. center-y: 0.194444 center-x: 0.508594 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-2", 0.194444); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.508594); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-2", 0.194444, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.223); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.508594, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.223); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-2 until {0.471875, 0.244444, 0.103125, 0.266667} @@ -305,8 +341,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co ); // align to rock-3. center-y: 0.190278 center-x: 0.566406 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.190278); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.566406); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.190278, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.724); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.566406, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.724); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-3 until {0.598438, 0.186111, 0.121875, 0.136111} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-3", @@ -320,8 +368,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to stream. center-y: 0.481944 center-x: 0.528906 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "stream", 0.481944); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.528906); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "stream", 0.481944, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.404); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.528906, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.404); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move forward until stream not detected @@ -343,8 +403,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co ); // align to rock-3. center-y: 0.291667 center-x: 0.501563 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.291667); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.291667, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.8); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.8); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-3 until {0.371875, 0.038889, 0.257812, 0.286111} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-3", @@ -360,8 +432,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to rock-4. center-y: 0.200000 center-x: 0.575000 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.575000); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.575000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-4 until {0.621875, 0.202778, 0.262500, 0.177778} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-4", @@ -376,8 +460,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_until_yolo_object_detected(env, context, yolo_detector, "tree-1", 0, 70); // align to tree-1. center-y: 0.390278 center-x: 0.5 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-1", 0.390278); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.5); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-1", 0.390278, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.3); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.5, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.3); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards tree-1 until {0.064063, 0.002778, 0.523438, 0.305556} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-1", @@ -391,8 +487,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to tree-1. center-y: 0.341667 center-x: 0.500000 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-1", 0.341667); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.500000); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "tree-1", 0.341667, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.500000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards tree-1 until {-0.064063, -0.008333, 1.073438, 0.602778} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-1", @@ -407,8 +515,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_until_yolo_object_detected(env, context, yolo_detector, "rock-5", 255, 50); // align to rock-5. center-y: 0.206944 center-x: 0.600000 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-5", 0.206944); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5", 0.600000); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-5", 0.206944, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.7); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5", 0.600000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.7); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-5 until {0.548438, -0.002778, 0.271875, 0.327778} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-5", @@ -425,8 +545,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to rock-6. center-y: 0.333333 center-x: 0.372656 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.333333); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.333333, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.7); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.7); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock-6 until {0.148438, 0.313889, 0.225000, 0.119444} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-6", @@ -440,15 +572,32 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to station-1. center-y: 0.286111 center-x: 0.483594 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "station-1", 0.286111); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.483594); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "station-1", 0.286111, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "station-1", 0.64); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.483594, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "station-1", 0.64); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); do_action_until_dialog(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ move_player_forward(env, context, 10, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.5); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.5, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -457,8 +606,20 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co #if 0 // align to rock. - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock", 0.000); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock", 0.000); + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock", 0.000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock", 0.000, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // x-position of target object prior to camera move + pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera + } + ); // move towards rock until move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock", From d3b1cefabd985f56a283f7b87d8a672c1c40cd4b Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 16:50:46 -0800 Subject: [PATCH 19/34] minor tweaks to station 1 navigation routine. --- .../AutoStory/PokemonSV_AutoStory_Segment_35.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 523a7d1c20..b2d491e84f 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -418,9 +418,10 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co } ); - // move towards rock-3 until {0.371875, 0.038889, 0.257812, 0.286111} + + // move towards rock-3 until {0.245313, 0.001000, 0.404688, 0.394444} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-3", - 0.257, 0.25, + 0.404, 0.25, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.501563); @@ -431,7 +432,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co - // align to rock-4. center-y: 0.200000 center-x: 0.575000 + // align to rock-4. center-y: 0.200000 center-x: 0.550781 move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); @@ -439,7 +440,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.575000, + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.550781, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move @@ -452,7 +453,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.25, 0.177, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.575000); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.550781); pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -504,7 +505,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // move towards tree-1 until {-0.064063, -0.008333, 1.073438, 0.602778} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "tree-1", - 0.9, 0.500, + 0.8, 0.500, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.500000); From 82e24e56306de10c3d166853d78a5e5b3cda3ddb Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 17:46:29 -0800 Subject: [PATCH 20/34] adjust close_game_from_home() --- .../NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp index d3302e323a..deaf3e61b0 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp @@ -70,6 +70,7 @@ void ensure_at_home(ConsoleHandle& console, ControllerContext& context){ {home_menu} ); if (ret == 0){ + console.log("Home detected."); // While we're on the Home screen, we might as well read the // console type as well. if (console.state().console_type_confirmed()){ @@ -104,7 +105,9 @@ void ensure_at_home(ConsoleHandle& console, JoyconContext& context){ // void close_game_from_home(ConsoleHandle& console, ProControllerContext& context){ + console.log("close_game_from_home"); ensure_at_home(console, context); + context.wait_for_all_requests(); // Use mashing to ensure that the X press succeeds. If it fails, the SR // will fail and can kill a den for the autohosts. @@ -113,7 +116,7 @@ void close_game_from_home(ConsoleHandle& console, ProControllerContext& context) // regardless of whether the game is initially open or closed. // if game initially open. | if game initially closed - pbf_mash_button(context, BUTTON_X, 100); // - Close game. | - does nothing + pbf_mash_button(context, BUTTON_X, 200); // - Close game. | - does nothing ssf_press_dpad_ptv(context, DPAD_DOWN); // - Does nothing. | - moves selector away from the closed game to avoid opening it. ssf_press_dpad_ptv(context, DPAD_DOWN); // - Does nothing. | - Press Down a second time in case we drop one. pbf_mash_button(context, BUTTON_A, 50); // - Confirm close game. | - opens an app on the home screen (e.g. Online) From 47c9869ab1e2c4125007fc9fdcf06befab3eb40e Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 19:01:44 -0800 Subject: [PATCH 21/34] more changes to station 1 nav routine --- .../PokemonSV_AutoStory_Segment_35.cpp | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index b2d491e84f..2212ff63c4 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -238,8 +238,8 @@ void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& co } void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ - // checkpoint_reattempt_loop(env, context, notif_status_update, stats, - // [&](size_t attempt_number){ + checkpoint_reattempt_loop(env, context, notif_status_update, stats, + [&](size_t attempt_number){ YOLOv5Detector yolo_detector(RESOURCE_PATH() + "PokemonSV/YOLO/yolo_area0_station1.onnx"); @@ -394,13 +394,17 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co } ); - // confirm we can see rock-3 - move_forward_until_yolo_object_detected(env, context, yolo_detector, "rock-3", - [&](){ - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - }, - 9 - ); + pbf_press_button(context, BUTTON_L, 20, 50); + + // // confirm we can see rock-3 + // move_forward_until_yolo_object_detected(env, context, yolo_detector, "rock-3", + // [&](){ + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // }, + // 4 + // ); + + move_camera_until_yolo_object_detected(env, context, yolo_detector, "rock-3", 255, 10); // align to rock-3. center-y: 0.291667 center-x: 0.501563 move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-3", 0.291667, @@ -433,14 +437,14 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // align to rock-4. center-y: 0.200000 center-x: 0.550781 - move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000, + move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.550781, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); - move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.550781, + move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move @@ -549,14 +553,14 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.333333, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.7); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.5); // x-position of target object prior to camera move pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.7); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.5); // x-position of target object prior to camera move pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -638,7 +642,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co - // }); + }); } void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ From 989a5ef1dea4bd69589803a5de2271cb8bfdac4c Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 19:22:26 -0800 Subject: [PATCH 22/34] adjust target x values when recovering from battles within move_camera_yolo: X. --- .../PokemonSV_AutoStory_Segment_35.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 2212ff63c4..da8811a0f9 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -271,7 +271,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.277344); // x-position of tree-tera prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.6); // 0.277344 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -297,7 +297,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.583594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.578); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.58); // 0.578 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -324,7 +324,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.508594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.223); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.5); // 0.223 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -351,7 +351,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.566406, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.724); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.6); // 0.724 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -378,7 +378,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.528906, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.404); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.5); // 0.404 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -417,7 +417,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.8); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.5015); // 0.8 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -440,14 +440,14 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.550781, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.55); // 0.8 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-4", 0.200000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.8); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.55); // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -475,7 +475,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.5, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.3); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // 0.3 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -502,7 +502,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.500000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -530,7 +530,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5", 0.600000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.7); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.6); // 0.7 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -560,7 +560,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.5); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.5); // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -587,7 +587,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.483594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "station-1", 0.64); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "station-1", 0.5); // 0.64 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -621,7 +621,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock", 0.000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // set to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); From 2245e1b2f1aea2d14555275304d1ba24c5ac36c0 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 20:19:35 -0800 Subject: [PATCH 23/34] when moving forward, don't pause to use Let's Go. --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 21 +++++++++++-------- .../AutoStory/PokemonSV_AutoStoryTools.h | 11 ++++++---- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 98df1cc478..83f19ac831 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1421,8 +1421,9 @@ void move_player_forward( try{ do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); }); }catch (UnexpectedBattleException&){ recovery_action(); @@ -1508,9 +1509,9 @@ void move_forward_until_yolo_object_above_min_size( return; // stop when the target is above a certain size. i.e. we are close enough to the target. } - - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); }); }catch (UnexpectedBattleException&){ overlays.clear(); @@ -1560,8 +1561,9 @@ void move_forward_until_yolo_object_detected( ); } - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); }); }catch (UnexpectedBattleException&){ @@ -1604,8 +1606,9 @@ void move_forward_until_yolo_object_not_detected( } } - pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); }); }catch (UnexpectedBattleException&){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 1415ee60de..437fe321fe 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -375,7 +375,7 @@ void checkpoint_reattempt_loop_tutorial( ); -// clear path with Let's Go. walk forward forward_ticks. repeat this for num_rounds. +// walk forward forward_ticks. repeat this for num_rounds. // if detect battle, kill the Pokemon. then continue. If we run into a battle, this round is considered to be done and will not be repeated. void move_player_forward( SingleSwitchProgramEnvironment& env, @@ -399,7 +399,7 @@ ImageFloatBox get_yolo_box( ); // move forward until detected object is a certain width and height on screen (min_size) -// walk forward forward_ticks each time, while clearing path with Let's Go. +// walk forward forward_ticks each time // if caught in battle, run recovery_action void move_forward_until_yolo_object_above_min_size( SingleSwitchProgramEnvironment& env, @@ -414,7 +414,7 @@ void move_forward_until_yolo_object_above_min_size( uint16_t delay_after_lets_go = 105 ); -// walk forward forward_ticks each time, while clearing path with Let's Go. +// walk forward forward_ticks each time // walk until we find the target object. // if caught in battle, run recovery_action // throw exception if exceed max_rounds. @@ -431,7 +431,7 @@ void move_forward_until_yolo_object_detected( uint16_t delay_after_lets_go = 105 ); -// walk forward forward_ticks each time, while clearing path with Let's Go. +// walk forward forward_ticks each time // walk until we no longer see the target object. and haven't seen `it times_not_seen_threshold` times. // if caught in battle, run recovery_action void move_forward_until_yolo_object_not_detected( @@ -473,6 +473,9 @@ bool move_player_to_realign_via_yolo( double x_target ); + +// move the player sideways until the target object is aligned with x_target +// if failed. try recovery action once, then re-try. void move_player_to_realign_via_yolo_with_recovery( SingleSwitchProgramEnvironment& env, ProControllerContext& context, From 5b4c275ee2ed64257848ba1ff013c3a62e8233a7 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 20:51:14 -0800 Subject: [PATCH 24/34] more changes to station 1 nav routine --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 2 +- .../PokemonSV_AutoStory_Segment_35.cpp | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 83f19ac831..8d30f1524b 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1672,7 +1672,7 @@ void move_camera_yolo( default: throw InternalProgramError(nullptr, PA_CURRENT_FUNCTION, "move_camera_yolo: Unknown CameraAxis enum."); } - + env.console.log("target_line: " + std::to_string(target_line)); env.console.log("diff: " + std::to_string(diff)); if (std::abs(diff) < 0.01){ reached_target_line = true; diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index da8811a0f9..d8a270247c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -317,14 +317,24 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-2", 0.194444, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.223); // x-position of target object prior to camera move + move_player_to_realign_via_yolo_with_recovery(env, context, yolo_detector, "rock-2", 0.25, + [&](){ + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.7); + } + ); + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.5); // x-position of target object prior to camera move pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.508594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.5); // 0.223 // set close to target x-position of target object + move_player_to_realign_via_yolo_with_recovery(env, context, yolo_detector, "rock-2", 0.5, + [&](){ + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.7); + } + ); + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.5); // 0.223 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -396,14 +406,6 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co pbf_press_button(context, BUTTON_L, 20, 50); - // // confirm we can see rock-3 - // move_forward_until_yolo_object_detected(env, context, yolo_detector, "rock-3", - // [&](){ - // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - // }, - // 4 - // ); - move_camera_until_yolo_object_detected(env, context, yolo_detector, "rock-3", 255, 10); // align to rock-3. center-y: 0.291667 center-x: 0.501563 @@ -553,14 +555,14 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock-6", 0.333333, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.5); // x-position of target object prior to camera move + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.66); // 0.7 // x-position of target object prior to camera move pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.5); // set close to target x-position of target object + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.37); // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); From 0a3298231d7471bbfb5d8bd1d3581cec6c0df574 Mon Sep 17 00:00:00 2001 From: jw098 Date: Sun, 9 Nov 2025 22:15:05 -0800 Subject: [PATCH 25/34] complete checkpoint_94 --- .../Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index d8a270247c..ec1161ac9a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -611,6 +611,11 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co } ); + clear_dialog(env.console, context, ClearDialogMode::STOP_BATTLE, 60, {CallbackEnum::BATTLE}); + run_trainer_double_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG); + mash_button_till_overworld(env.console, context, BUTTON_A); + + #if 0 // align to rock. move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock", 0.000, From 1c5658f25be7a02c194e91d01d3f9ebd78d7813f Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 12:17:38 -0800 Subject: [PATCH 26/34] adjust recovery_action for move_camera_yolo: X. Don't move the player after a battle. just adjust the camera. --- .../PokemonSV_AutoStory_Segment_35.cpp | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index ec1161ac9a..91740bc190 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -271,7 +271,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-tera", 0.604688, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.6); // 0.277344 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.6); // 0.277344 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -297,7 +297,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-1", 0.583594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.58); // 0.578 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.58); // 0.578 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -329,11 +329,11 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-2", 0.508594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo_with_recovery(env, context, yolo_detector, "rock-2", 0.5, - [&](){ - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.7); - } - ); + // move_player_to_realign_via_yolo_with_recovery(env, context, yolo_detector, "rock-2", 0.5, + // [&](){ + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.7); + // } + // ); // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.5); // 0.223 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } @@ -361,7 +361,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.566406, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.6); // 0.724 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.6); // 0.724 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -388,7 +388,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "stream", 0.528906, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.5); // 0.404 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "stream", 0.5); // 0.404 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -419,7 +419,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-3", 0.501563, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.5015); // 0.8 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.5015); // 0.8 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -442,7 +442,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-4", 0.550781, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.55); // 0.8 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-4", 0.55); // 0.8 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -477,7 +477,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.5, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // 0.3 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // 0.3 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -504,7 +504,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "tree-1", 0.500000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-1", 0.5); // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -532,7 +532,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-5", 0.600000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.6); // 0.7 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-5", 0.6); // 0.7 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -562,7 +562,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock-6", 0.372656, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.37); // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-6", 0.37); // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -589,7 +589,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "station-1", 0.483594, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "station-1", 0.5); // 0.64 // set close to target x-position of target object + // move_player_to_realign_via_yolo(env, context, yolo_detector, "station-1", 0.5); // 0.64 // set close to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -618,6 +618,8 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co #if 0 // align to rock. + // center before: + // center after: move_camera_yolo(env, context, CameraAxis::Y, yolo_detector, "rock", 0.000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); @@ -628,12 +630,11 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co move_camera_yolo(env, context, CameraAxis::X, yolo_detector, "rock", 0.000, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock", 0.000); // set to target x-position of target object pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); - // move towards rock until + // move towards rock until box: move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock", 0.000, 0.000, [&](){ From 8a8913e6e1c93bf0a0bfe4b702f288c4c72b364c Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 17:06:56 -0800 Subject: [PATCH 27/34] more adjustments to checkpoint_94 --- .../Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 91740bc190..a5cf43ba16 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -281,7 +281,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.146, 0.180, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.583594); + move_player_to_realign_via_yolo(env, context, yolo_detector, "tree-tera", 0.604688); pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -307,7 +307,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.279, 0.230, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.564063); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-1", 0.583594); pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -345,7 +345,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.103, 0.266, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.535937); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-2", 0.508594); pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); @@ -371,7 +371,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co 0.121, 0.136, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.535937); + move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.566406); pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera } ); From c49162e8a9f8e2baf5cf48efb22b310a5ddc4739 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 17:31:06 -0800 Subject: [PATCH 28/34] yolo-based camera/player movement routines: rename variables. throw exception if never detected yolo object. throw exception if exceed max rounds. reduce delays after joystick movement. --- .../AutoStory/PokemonSV_AutoStoryTools.cpp | 267 +++++++++++------- .../AutoStory/PokemonSV_AutoStoryTools.h | 5 + 2 files changed, 167 insertions(+), 105 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 8d30f1524b..e25dddeb00 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1481,44 +1481,65 @@ void move_forward_until_yolo_object_above_min_size( pbf_move_left_joystick(context, 128, 0, 10, 50); // move forward to align with camera VideoOverlaySet overlays(env.console.overlay()); - size_t num_reattempts = 0; + bool seen_object = false; + size_t not_detected_cont = 0; + size_t max_not_detected = 5; + size_t forward_move_count = 0; bool reached_target = false; - bool exceed_reattempts = false; - while(!reached_target && !exceed_reattempts){ - try{ - do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - context.wait_for_all_requests(); - ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + bool exceed_times_not_detected = false; + while(!reached_target && !exceed_times_not_detected){ + forward_move_count++; + try{ + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + + bool not_found_target = target_box.x == -1; + if (not_found_target){ + not_detected_cont++; + if (not_detected_cont > max_not_detected){ + exceed_times_not_detected = true; + return; // when too many failed attempts, just assume we're too close to the target to detect it. + } + context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. + return; + }else{ + seen_object = true; + not_detected_cont = 0; + } - bool not_found_target = target_box.x == -1; - if (not_found_target){ - num_reattempts++; - if (num_reattempts > 3){ - exceed_reattempts = true; - return; // when too many failed attempts, just assume we're too close to the target to detect it. + if (target_box.width > min_width && target_box.height > min_height){ + reached_target = true; + return; // stop when the target is above a certain size. i.e. we are close enough to the target. } - context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. - return; - }else{ - num_reattempts = 0; - } + + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }); + }catch (UnexpectedBattleException&){ + overlays.clear(); + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // move_camera_yolo(); + } - if (target_box.width > min_width && target_box.height > min_height){ - reached_target = true; - return; // stop when the target is above a certain size. i.e. we are close enough to the target. - } - - pbf_move_left_joystick(context, 128, y, forward_ticks, 0); - // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); - }); - }catch (UnexpectedBattleException&){ - overlays.clear(); - recovery_action(); - // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - // move_camera_yolo(); + if (forward_move_count > 50){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_forward_until_yolo_object_above_min_size(): Unable to reach target object after many attempts.", + env.console + ); + } } + + if (!seen_object){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_forward_until_yolo_object_above_min_size(): Never detected the yolo object.", + env.console + ); } } @@ -1543,36 +1564,39 @@ void move_forward_until_yolo_object_detected( bool found_target = false; size_t round_num = 0; while(!found_target){ - try{ - do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - context.wait_for_all_requests(); - ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); - found_target = target_box.x != -1; - if (found_target){ - return; - } + try{ + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + found_target = target_box.x != -1; + if (found_target){ + return; + } - if (round_num > max_rounds){ - OperationFailedException::fire( - ErrorReport::SEND_ERROR_REPORT, - "move_forward_until_yolo_object_detected(): Unable to detect target object.", - env.console - ); - } + - pbf_move_left_joystick(context, 128, y, forward_ticks, 0); - // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); - }); - - }catch (UnexpectedBattleException&){ - overlays.clear(); - recovery_action(); - // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - // move_camera_yolo(); - } - round_num++; + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + }); + + }catch (UnexpectedBattleException&){ + overlays.clear(); + recovery_action(); + // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + // move_camera_yolo(); + } + + + round_num++; + if (round_num > max_rounds){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_forward_until_yolo_object_detected(): Unable to detect target object.", + env.console + ); + } } } @@ -1590,6 +1614,7 @@ void move_forward_until_yolo_object_not_detected( ){ VideoOverlaySet overlays(env.console.overlay()); bool target_visible = true; + size_t max_rounds = 50; size_t times_not_seen = 0; size_t round_num = 0; while(times_not_seen < times_not_seen_threshold){ @@ -1618,6 +1643,14 @@ void move_forward_until_yolo_object_not_detected( // move_camera_yolo(); } round_num++; + + if (round_num > max_rounds){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_forward_until_yolo_object_not_detected(): Unable to walk away from target object.", + env.console + ); + } } } @@ -1632,10 +1665,12 @@ void move_camera_yolo( std::function&& recovery_action ){ VideoOverlaySet overlays(env.console.overlay()); + bool seen_object = false; size_t max_attempts = 10; - size_t num_reattempts = 0; + size_t not_detected_count = 0; + size_t max_not_detected = 5; bool reached_target_line = false; - bool exceed_reattempts = false; + bool exceed_max_not_detected = false; for (size_t i = 0; i < max_attempts; i++){ try{ do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, @@ -1645,15 +1680,16 @@ void move_camera_yolo( bool not_found_target = target_box.x == -1; if (not_found_target){ - num_reattempts++; - if (num_reattempts > 3){ - exceed_reattempts = true; + not_detected_count++; + if (not_detected_count > max_not_detected){ + exceed_max_not_detected = true; return; // when too many failed attempts, just assume we're too close to the target to detect it. } context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. return; }else{ - num_reattempts = 0; + not_detected_count = 0; + seen_object = true; } @@ -1712,11 +1748,11 @@ void move_camera_yolo( env.console.log("axis push: " + std::to_string(axis_push) + ", push duration: " + std::to_string(push_duration)); switch(axis){ case CameraAxis::X:{ - pbf_move_right_joystick(context, axis_push, 128, push_duration, 100); + pbf_move_right_joystick(context, axis_push, 128, push_duration, 0); break; } case CameraAxis::Y:{ - pbf_move_right_joystick(context, 128, axis_push, push_duration, 100); + pbf_move_right_joystick(context, 128, axis_push, push_duration, 0); break; } default: @@ -1724,7 +1760,7 @@ void move_camera_yolo( } }); - if(reached_target_line || exceed_reattempts){ + if(reached_target_line || exceed_max_not_detected){ break; } @@ -1734,6 +1770,14 @@ void move_camera_yolo( // run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); } } + + if (!seen_object){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_camera_yolo(): Never detected the yolo object.", + env.console + ); + } } bool move_player_to_realign_via_yolo( @@ -1745,10 +1789,12 @@ bool move_player_to_realign_via_yolo( ){ VideoOverlaySet overlays(env.console.overlay()); + bool seen_object = false; size_t max_attempts = 10; - size_t num_reattempts = 0; + size_t not_detected_count = 0; + size_t max_not_detected = 5; bool reached_target_line = false; - bool exceed_reattempts = false; + bool exceed_max_not_detected = false; for (size_t i = 0; i < max_attempts; i++){ try{ do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, @@ -1758,20 +1804,22 @@ bool move_player_to_realign_via_yolo( bool not_found_target = target_box.x == -1; if (not_found_target){ - num_reattempts++; - if (num_reattempts > 3){ - exceed_reattempts = true; + not_detected_count++; + if (not_detected_count > max_not_detected){ + exceed_max_not_detected = true; return; // when too many failed attempts, just assume we're too close to the target to detect it. } context.wait_for(1000ms); // if we can't see the object, it might just be temporarily obscured. wait one second and reattempt. return; }else{ - num_reattempts = 0; + seen_object = true; + not_detected_count = 0; } double object_x_pos = target_box.x + target_box.width/2; double diff = x_target - object_x_pos; + env.console.log("x_target: " + std::to_string(x_target)); env.console.log("diff: " + std::to_string(diff)); if (std::abs(diff) < 0.05){ reached_target_line = true; @@ -1797,11 +1845,11 @@ bool move_player_to_realign_via_yolo( pbf_press_button(context, BUTTON_R, 20, 105); } - pbf_move_left_joystick(context, x_push, 128, push_duration, 100); + pbf_move_left_joystick(context, x_push, 128, push_duration, 0); }); - if (exceed_reattempts){ + if (exceed_max_not_detected){ return false; } @@ -1815,6 +1863,14 @@ bool move_player_to_realign_via_yolo( } } + if (!seen_object){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_player_to_realign_via_yolo(): Never detected the yolo object.", + env.console + ); + } + return false; } @@ -1849,36 +1905,37 @@ void move_camera_until_yolo_object_detected( size_t round_num = 0; uint8_t x_move = initial_x_move > 128 ? 255 : 0; while(!found_target){ - try{ - do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, - [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ + try{ + do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, + [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - if (round_num == 0){ - pbf_move_right_joystick(context, initial_x_move, 128, initial_hold_ticks, 50); - } - context.wait_for_all_requests(); - ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); - found_target = target_box.x != -1; - if (found_target){ - return; - } + if (round_num == 0){ + pbf_move_right_joystick(context, initial_x_move, 128, initial_hold_ticks, 50); + } + context.wait_for_all_requests(); + ImageFloatBox target_box = get_yolo_box(env, context, overlays, yolo_detector, target_label); + found_target = target_box.x != -1; + if (found_target){ + return; + } - if (round_num > max_rounds){ - OperationFailedException::fire( - ErrorReport::SEND_ERROR_REPORT, - "move_camera_until_yolo_object_detected(): Unable to detect target object.", - env.console - ); - } + - pbf_move_right_joystick(context, x_move, 128, 10, 50); - }); - - }catch (UnexpectedBattleException&){ - overlays.clear(); - run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); - } - round_num++; + pbf_move_right_joystick(context, x_move, 128, 10, 50); + }); + + }catch (UnexpectedBattleException&){ + overlays.clear(); + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + } + round_num++; + if (round_num > max_rounds){ + OperationFailedException::fire( + ErrorReport::SEND_ERROR_REPORT, + "move_camera_until_yolo_object_detected(): Unable to detect target object.", + env.console + ); + } } } diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 437fe321fe..7c7271eb2a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -401,6 +401,8 @@ ImageFloatBox get_yolo_box( // move forward until detected object is a certain width and height on screen (min_size) // walk forward forward_ticks each time // if caught in battle, run recovery_action +// throw exception if forward_move_count is above 50. +// throw exception if never detected yolo object void move_forward_until_yolo_object_above_min_size( SingleSwitchProgramEnvironment& env, ProControllerContext& context, @@ -434,6 +436,7 @@ void move_forward_until_yolo_object_detected( // walk forward forward_ticks each time // walk until we no longer see the target object. and haven't seen `it times_not_seen_threshold` times. // if caught in battle, run recovery_action +// throw exception if exceed max_rounds. void move_forward_until_yolo_object_not_detected( SingleSwitchProgramEnvironment& env, ProControllerContext& context, @@ -454,6 +457,7 @@ enum class CameraAxis{ // move the camera along `axis` until the target object is aligned with target_line // if caught in battle, run recovery_action +// throw exception if never detected yolo object void move_camera_yolo( SingleSwitchProgramEnvironment& env, ProControllerContext& context, @@ -465,6 +469,7 @@ void move_camera_yolo( ); // move the player sideways until the target object is aligned with x_target +// throw exception if never detected yolo object bool move_player_to_realign_via_yolo( SingleSwitchProgramEnvironment& env, ProControllerContext& context, From f2475faf0545acb74331d5558dcae33d052c4b90 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 20:13:17 -0800 Subject: [PATCH 29/34] more checkpoint_94 adjustments --- .../Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index a5cf43ba16..8cfc822a6c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -368,7 +368,7 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co // move towards rock-3 until {0.598438, 0.186111, 0.121875, 0.136111} move_forward_until_yolo_object_above_min_size(env, context, yolo_detector, "rock-3", - 0.121, 0.136, + 0.121, 0.1, [&](){ run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); move_player_to_realign_via_yolo(env, context, yolo_detector, "rock-3", 0.566406); From d9f439dc486ddc3280a876602921d5e954f708a3 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 20:15:38 -0800 Subject: [PATCH 30/34] minor changes to close_game_from_home --- .../NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp index deaf3e61b0..8d4f2768ea 100644 --- a/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp +++ b/SerialPrograms/Source/NintendoSwitch/Programs/NintendoSwitch_GameEntry.cpp @@ -107,7 +107,6 @@ void ensure_at_home(ConsoleHandle& console, JoyconContext& context){ void close_game_from_home(ConsoleHandle& console, ProControllerContext& context){ console.log("close_game_from_home"); ensure_at_home(console, context); - context.wait_for_all_requests(); // Use mashing to ensure that the X press succeeds. If it fails, the SR // will fail and can kill a den for the autohosts. @@ -116,7 +115,7 @@ void close_game_from_home(ConsoleHandle& console, ProControllerContext& context) // regardless of whether the game is initially open or closed. // if game initially open. | if game initially closed - pbf_mash_button(context, BUTTON_X, 200); // - Close game. | - does nothing + pbf_mash_button(context, BUTTON_X, 100); // - Close game. | - does nothing ssf_press_dpad_ptv(context, DPAD_DOWN); // - Does nothing. | - moves selector away from the closed game to avoid opening it. ssf_press_dpad_ptv(context, DPAD_DOWN); // - Does nothing. | - Press Down a second time in case we drop one. pbf_mash_button(context, BUTTON_A, 50); // - Confirm close game. | - opens an app on the home screen (e.g. Online) @@ -127,6 +126,7 @@ void close_game_from_home(ConsoleHandle& console, ProControllerContext& context) pbf_mash_button(context, BUTTON_B, 350); } void close_game_from_home(ConsoleHandle& console, JoyconContext& context){ + console.log("close_game_from_home"); ensure_at_home(console, context); // Use mashing to ensure that the X press succeeds. If it fails, the SR // will fail and can kill a den for the autohosts. From b0b2ce51aaaec0251344eaa9a0fef7af099b3437 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 20:55:11 -0800 Subject: [PATCH 31/34] move_camera_yolo: increase max_attempts --- .../PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index e25dddeb00..0cad821872 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1666,7 +1666,7 @@ void move_camera_yolo( ){ VideoOverlaySet overlays(env.console.overlay()); bool seen_object = false; - size_t max_attempts = 10; + size_t max_attempts = 20; size_t not_detected_count = 0; size_t max_not_detected = 5; bool reached_target_line = false; From 17cb7aab57a7e4a55299f60b9d5a690aeec1e3d0 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 21:34:46 -0800 Subject: [PATCH 32/34] updated move_player_forward() and walk_forward_until_dialog() --- .../Programs/AutoStory/PokemonSV_AutoStoryTools.cpp | 10 +++++++--- .../Programs/AutoStory/PokemonSV_AutoStoryTools.h | 1 + .../PokemonSV/Programs/PokemonSV_WorldNavigation.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp index 0cad821872..523892dcc1 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp @@ -1410,6 +1410,7 @@ void move_player_forward( ProControllerContext& context, uint8_t num_rounds, std::function&& recovery_action, + bool use_lets_go, uint16_t forward_ticks, uint8_t y, uint16_t delay_after_forward_move, @@ -1421,9 +1422,12 @@ void move_player_forward( try{ do_action_and_monitor_for_battles_early(env.program_info(), env.console, context, [&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){ - pbf_move_left_joystick(context, 128, y, forward_ticks, 0); - // pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); - // pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + if (!use_lets_go){ + pbf_move_left_joystick(context, 128, y, forward_ticks, 0); + }else{ + pbf_press_button(context, BUTTON_R, 20, delay_after_lets_go); + pbf_move_left_joystick(context, 128, y, forward_ticks, delay_after_forward_move); + } }); }catch (UnexpectedBattleException&){ recovery_action(); diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h index 7c7271eb2a..78a5c03426 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h @@ -382,6 +382,7 @@ void move_player_forward( ProControllerContext& context, uint8_t num_rounds, std::function&& recovery_action, + bool use_lets_go = false, uint16_t forward_ticks = 100, uint8_t y = 0, uint16_t delay_after_forward_move = 50, diff --git a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp index 919aeaad24..257a08d26c 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/PokemonSV_WorldNavigation.cpp @@ -665,7 +665,7 @@ void walk_forward_until_dialog( int ret = run_until( stream, context, [&](ProControllerContext& context){ - ssf_press_left_joystick(context, 128, y, 0, seconds_timeout * TICKS_PER_SECOND); + ssf_press_left_joystick(context, x, y, 0, seconds_timeout * TICKS_PER_SECOND); if (movement_mode == NavigationMovementMode::DIRECTIONAL_ONLY){ pbf_wait(context, seconds_timeout * TICKS_PER_SECOND); } else if (movement_mode == NavigationMovementMode::DIRECTIONAL_SPAM_A){ From 4374af38872e69fb8f91872070da2c2c239f1a41 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 21:36:58 -0800 Subject: [PATCH 33/34] preliminary checkpoint 95: entering station 1 --- .../AutoStory/PokemonSV_AutoStory.cpp | 3 +- .../PokemonSV_AutoStory_Segment_35.cpp | 37 +++++++++++++++++-- .../PokemonSV_AutoStory_Segment_35.h | 8 ++-- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index 03437840a7..c24f122b10 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -125,13 +125,14 @@ std::vector> make_autoStory_segment_list(){ segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); + if (PreloadSettings::instance().DEVELOPER_MODE){ segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); - + } return segment_list; }; diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp index 8cfc822a6c..f796be0d16 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.cpp @@ -37,7 +37,7 @@ std::string AutoStory_Segment_35::start_text() const{ } std::string AutoStory_Segment_35::end_text() const{ - return "End: "; + return "End: At Area Zero Station 1. Deactivated the locks."; } void AutoStory_Segment_35::run_segment( @@ -54,6 +54,8 @@ void AutoStory_Segment_35::run_segment( env.console.log("Start Segment " + name(), COLOR_ORANGE); AutoStory_Checkpoint_93().run_checkpoint(env, context, options, stats); + AutoStory_Checkpoint_94().run_checkpoint(env, context, options, stats); + AutoStory_Checkpoint_95().run_checkpoint(env, context, options, stats); context.wait_for_all_requests(); @@ -70,14 +72,14 @@ void AutoStory_Checkpoint_93::run_checkpoint(SingleSwitchProgramEnvironment& env std::string AutoStory_Checkpoint_94::name() const{ return "094 - " + AutoStory_Segment_35().name(); } std::string AutoStory_Checkpoint_94::start_text() const{ return AutoStory_Checkpoint_93().end_text();} -std::string AutoStory_Checkpoint_94::end_text() const{ return "At Area Zero Station 1.";} +std::string AutoStory_Checkpoint_94::end_text() const{ return "Outside Area Zero Station 1. Defeated Glimmora.";} void AutoStory_Checkpoint_94::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ checkpoint_94(env, context, options.notif_status_update, stats); } std::string AutoStory_Checkpoint_95::name() const{ return "095 - " + AutoStory_Segment_35().name(); } -std::string AutoStory_Checkpoint_95::start_text() const{ return "";} -std::string AutoStory_Checkpoint_95::end_text() const{ return "";} +std::string AutoStory_Checkpoint_95::start_text() const{ return AutoStory_Checkpoint_94().end_text();} +std::string AutoStory_Checkpoint_95::end_text() const{ return "At Area Zero Station 1. Deactivated the locks.";} void AutoStory_Checkpoint_95::run_checkpoint(SingleSwitchProgramEnvironment& env, ProControllerContext& context, AutoStoryOptions options, AutoStoryStats& stats) const{ checkpoint_95(env, context, options.notif_status_update, stats); } @@ -654,6 +656,33 @@ void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& co } void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ + // checkpoint_reattempt_loop(env, context, notif_status_update, stats, + // [&](size_t attempt_number){ + #if 0 + move_player_forward(env, context, 5, + [&](){ + run_wild_battle_press_A(env.console, context, BattleStopCondition::STOP_OVERWORLD); + }, + true + ); + // pbf_move_left_joystick(context, 0, 128, 200, 50); + // clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::BLACK_DIALOG_BOX}); + + pbf_move_left_joystick(context, 0, 128, 10, 0); + pbf_press_button(context, BUTTON_L, 20, 20); + #endif + + // enter Station 1 + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_ONLY, 20); + mash_button_till_overworld(env.console, context, BUTTON_A); // black dialog + + // disable Lock at Station 1 + walk_forward_until_dialog(env.program_info(), env.console, context, NavigationMovementMode::DIRECTIONAL_SPAM_A, 20); + mash_button_till_overworld(env.console, context, BUTTON_A); // prompt, black dialog, + + + + // }); } // void checkpoint_96(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats){ diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h index 0cf84aedbe..83227f449a 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_35.h @@ -54,12 +54,12 @@ class AutoStory_Checkpoint_95 : public AutoStory_Checkpoint{ // end: Entered Area Zero Gate. Flew down to Area Zero from the platform. void checkpoint_93(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: Entered Area Zero Gate. Flew down to Area Zero from the platform. +// end: Outside Area Zero Station 1. Defeated Glimmora. void checkpoint_94(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); -// start: -// end: +// start: Outside Area Zero Station 1. Defeated Glimmora. +// end: At Area Zero Station 1. Deactivated the locks. void checkpoint_95(SingleSwitchProgramEnvironment& env, ProControllerContext& context, EventNotificationOption& notif_status_update, AutoStoryStats& stats); // start: From 938fc466fef5a4a10163a2cb86080d4979379f58 Mon Sep 17 00:00:00 2001 From: jw098 Date: Mon, 10 Nov 2025 21:42:34 -0800 Subject: [PATCH 34/34] more tidy up --- .../PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp index c24f122b10..331f148bc7 100644 --- a/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp +++ b/SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp @@ -125,6 +125,7 @@ std::vector> make_autoStory_segment_list(){ segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); segment_list.emplace_back(std::make_unique()); + if (PreloadSettings::instance().DEVELOPER_MODE){ segment_list.emplace_back(std::make_unique()); // segment_list.emplace_back(std::make_unique()); @@ -294,14 +295,16 @@ std::vector> make_autoStory_checkpoint_lis checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); + + if (PreloadSettings::instance().DEVELOPER_MODE){ checkpoint_list.emplace_back(std::make_unique()); checkpoint_list.emplace_back(std::make_unique()); - // checkpoint_list.emplace_back(std::make_unique()); + checkpoint_list.emplace_back(std::make_unique()); // checkpoint_list.emplace_back(std::make_unique()); // checkpoint_list.emplace_back(std::make_unique()); // checkpoint_list.emplace_back(std::make_unique()); // checkpoint_list.emplace_back(std::make_unique()); - + } return checkpoint_list; };