1- /* Home Box Sorting
1+ /* Home Box Sorter
22 *
33 * From: https://github.com/PokemonAutomation/
44 *
55 */
66
77/* TODO ideas
8- break into smaller functions
98read pokemon name and store the slug (easier to detect missread than reading a number)
109Optimise the swapping algo
1110Add enum for ball ? Also, BDSP is reading from swsh data. Worth refactoring ?
@@ -49,7 +48,7 @@ language
4948#include " Pokemon/Pokemon_CollectedPokemonInfo.h"
5049#include " PokemonHome/Inference/PokemonHome_BoxGenderDetector.h"
5150#include " PokemonHome/Inference/PokemonHome_BallReader.h"
52- #include " PokemonHome_BoxSorting .h"
51+ #include " PokemonHome_BoxSorter .h"
5352
5453namespace PokemonAutomation {
5554namespace NintendoSwitch {
@@ -60,7 +59,7 @@ using namespace Pokemon;
6059const size_t MAX_BOXES = 200 ;
6160
6261
63- BoxSorting_Descriptor::BoxSorting_Descriptor ()
62+ BoxSorter_Descriptor::BoxSorter_Descriptor ()
6463 : SingleSwitchProgramDescriptor(
6564 " PokemonHome:BoxSorter" ,
6665 STRING_POKEMON + " Home" , " Box Sorter" ,
@@ -72,7 +71,7 @@ BoxSorting_Descriptor::BoxSorting_Descriptor()
7271 {}
7372 )
7473{}
75- struct BoxSorting_Descriptor ::Stats : public StatsTracker{
74+ struct BoxSorter_Descriptor ::Stats : public StatsTracker{
7675 Stats ()
7776 : pkmn(m_stats[" Pokemon" ])
7877 , empty(m_stats[" Empty Slots" ])
@@ -89,11 +88,11 @@ struct BoxSorting_Descriptor::Stats : public StatsTracker{
8988 std::atomic<uint64_t >& compare;
9089 std::atomic<uint64_t >& swaps;
9190};
92- std::unique_ptr<StatsTracker> BoxSorting_Descriptor ::make_stats () const {
91+ std::unique_ptr<StatsTracker> BoxSorter_Descriptor ::make_stats () const {
9392 return std::unique_ptr<StatsTracker>(new Stats ());
9493}
9594
96- BoxSorting::BoxSorting ()
95+ BoxSorter::BoxSorter ()
9796 : BOX_NUMBER(
9897 " <b>Number of Boxes to Sort:</b>" ,
9998 LockMode::LOCK_WHILE_RUNNING,
@@ -262,7 +261,7 @@ void sort(
262261 ProControllerContext& context,
263262 std::vector<std::optional<CollectedPokemonInfo>> boxes_data,
264263 std::vector<std::optional<CollectedPokemonInfo>> boxes_sorted,
265- BoxSorting_Descriptor ::Stats& stats,
264+ BoxSorter_Descriptor ::Stats& stats,
266265 BoxCursor& cur_cursor,
267266 uint16_t GAME_DELAY
268267){
@@ -316,15 +315,15 @@ void sort(
316315 }
317316}
318317
319- void BoxSorting ::program (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
318+ void BoxSorter ::program (SingleSwitchProgramEnvironment& env, ProControllerContext& context){
320319 StartProgramChecks::check_performance_class_wired_or_wireless (context);
321320
322321 std::vector<SortingRule> sort_preferences = SORT_TABLE.preferences ();
323322 if (sort_preferences.empty ()){
324323 throw UserSetupError (env.console , " At least one sorting method selection needs to be made!" );
325324 }
326325
327- BoxSorting_Descriptor ::Stats& stats = env.current_stats < BoxSorting_Descriptor ::Stats>();
326+ BoxSorter_Descriptor ::Stats& stats = env.current_stats < BoxSorter_Descriptor ::Stats>();
328327
329328 ImageFloatBox select_check (0.495 , 0.0045 , 0.01 , 0.005 ); // square color to check which mode is active
330329 ImageFloatBox national_dex_number_box (0.448 , 0.245 , 0.049 , 0.04 ); // pokemon national dex number pos
@@ -503,7 +502,7 @@ void BoxSorting::program(SingleSwitchProgramEnvironment& env, ProControllerConte
503502 if (dex_number <= 0 || dex_number > static_cast <int >(NATIONAL_DEX_SLUGS ().size ())) {
504503 OperationFailedException::fire (
505504 ErrorReport::SEND_ERROR_REPORT,
506- " BoxSorting Check Summary: Unable to read a correct dex number, found: " + std::to_string (dex_number),
505+ " BoxSorter Check Summary: Unable to read a correct dex number, found: " + std::to_string (dex_number),
507506 env.console
508507 );
509508 }
0 commit comments