Skip to content

Commit 0018383

Browse files
committed
2 parents 508a6d8 + ba77395 commit 0018383

17 files changed

+1802
-35
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,6 +1485,18 @@ file(GLOB MAIN_SOURCES
14851485
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h
14861486
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp
14871487
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h
1488+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp
1489+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h
1490+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp
1491+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h
1492+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp
1493+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h
1494+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp
1495+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h
1496+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp
1497+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h
1498+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp
1499+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h
14881500
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp
14891501
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h
14901502
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,12 @@ SOURCES += \
740740
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.cpp \
741741
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.cpp \
742742
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.cpp \
743+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.cpp \
744+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.cpp \
745+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.cpp \
746+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.cpp \
747+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.cpp \
748+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.cpp \
743749
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp \
744750
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp \
745751
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.cpp \
@@ -1857,6 +1863,12 @@ HEADERS += \
18571863
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_16.h \
18581864
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_17.h \
18591865
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_18.h \
1866+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_19.h \
1867+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_20.h \
1868+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_21.h \
1869+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_22.h \
1870+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_23.h \
1871+
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory_Segment_24.h \
18601872
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.h \
18611873
Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h \
18621874
Source/PokemonSV/Programs/AutoStory/PokemonSV_MenuOption.h \

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStory.cpp

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h"
2121
#include "PokemonSV/Inference/Overworld/PokemonSV_OverworldDetector.h"
2222
#include "PokemonSV/Inference/Overworld/PokemonSV_OliveDetector.h"
23+
#include "PokemonSV/Inference/Overworld/PokemonSV_NoMinimapDetector.h"
2324
#include "PokemonSV_AutoStory_Segment_00.h"
2425
#include "PokemonSV_AutoStory_Segment_01.h"
2526
#include "PokemonSV_AutoStory_Segment_02.h"
@@ -37,19 +38,19 @@
3738
#include "PokemonSV_AutoStory_Segment_14.h"
3839
#include "PokemonSV_AutoStory_Segment_15.h"
3940
#include "PokemonSV_AutoStory_Segment_16.h"
40-
// #include "PokemonSV_AutoStory_Segment_17.h"
41-
// #include "PokemonSV_AutoStory_Segment_18.h"
42-
// #include "PokemonSV_AutoStory_Segment_19.h"
43-
// #include "PokemonSV_AutoStory_Segment_20.h"
44-
// #include "PokemonSV_AutoStory_Segment_21.h"
45-
// #include "PokemonSV_AutoStory_Segment_22.h"
46-
// #include "PokemonSV_AutoStory_Segment_23.h"
47-
// #include "PokemonSV_AutoStory_Segment_24.h"
41+
#include "PokemonSV_AutoStory_Segment_17.h"
42+
#include "PokemonSV_AutoStory_Segment_18.h"
43+
#include "PokemonSV_AutoStory_Segment_19.h"
44+
#include "PokemonSV_AutoStory_Segment_20.h"
45+
#include "PokemonSV_AutoStory_Segment_21.h"
46+
#include "PokemonSV_AutoStory_Segment_22.h"
47+
#include "PokemonSV_AutoStory_Segment_23.h"
48+
#include "PokemonSV_AutoStory_Segment_24.h"
4849
#include "PokemonSV_AutoStory.h"
4950

50-
// #include <iostream>
51-
// using std::cout;
52-
// using std::endl;
51+
#include <iostream>
52+
using std::cout;
53+
using std::endl;
5354
//#include <unordered_map>
5455
//#include <algorithm>
5556

@@ -81,11 +82,11 @@ std::vector<std::unique_ptr<AutoStory_Segment>> make_autoStory_segment_list(){
8182
segment_list.emplace_back(std::make_unique<AutoStory_Segment_14>());
8283
segment_list.emplace_back(std::make_unique<AutoStory_Segment_15>());
8384
segment_list.emplace_back(std::make_unique<AutoStory_Segment_16>());
84-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_17>());
85-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_18>());
86-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_19>());
87-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_20>());
88-
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_21>());
85+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_17>());
86+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_18>());
87+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_19>());
88+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_20>());
89+
segment_list.emplace_back(std::make_unique<AutoStory_Segment_21>());
8990
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_22>());
9091
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_23>());
9192
// segment_list.emplace_back(std::make_unique<AutoStory_Segment_24>());
@@ -213,6 +214,7 @@ AutoStory::AutoStory()
213214
)
214215
, MAINSTORY_NOTE{
215216
"Ensure you have a level 100 Gardevoir with the moves in the following order: Moonblast, Dazzling Gleam, Psychic, Mystical Fire.<br>"
217+
"Also, make sure you have two other strong pokemon (e.g. level 100 Talonflames)<br>"
216218
"Refer to the documentation on github for more details."
217219
}
218220
, START_DESCRIPTION(
@@ -600,26 +602,30 @@ void AutoStory::test_checkpoints(
600602
checkpoint_list.push_back([&](){checkpoint_34(env, context, notif_status_update);});
601603
checkpoint_list.push_back([&](){checkpoint_35(env, context, notif_status_update);});
602604
checkpoint_list.push_back([&](){checkpoint_36(env, context, notif_status_update);});
603-
// checkpoint_list.push_back([&](){checkpoint_37(env, context, notif_status_update);});
604-
// checkpoint_list.push_back([&](){checkpoint_38(env, context, notif_status_update);});
605-
// checkpoint_list.push_back([&](){checkpoint_39(env, context, notif_status_update);});
606-
// checkpoint_list.push_back([&](){checkpoint_40(env, context, notif_status_update);});
607-
// checkpoint_list.push_back([&](){checkpoint_41(env, context, notif_status_update);});
608-
// checkpoint_list.push_back([&](){checkpoint_42(env, context, notif_status_update);});
609-
// checkpoint_list.push_back([&](){checkpoint_43(env, context, notif_status_update);});
610-
// checkpoint_list.push_back([&](){checkpoint_44(env, context, notif_status_update);});
611-
// checkpoint_list.push_back([&](){checkpoint_45(env, context, notif_status_update);});
612-
// checkpoint_list.push_back([&](){checkpoint_46(env, context, notif_status_update);});
613-
// checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update);});
614-
// checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update);});
615-
// checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update);});
605+
checkpoint_list.push_back([&](){checkpoint_37(env, context, notif_status_update);});
606+
checkpoint_list.push_back([&](){checkpoint_38(env, context, notif_status_update);});
607+
checkpoint_list.push_back([&](){checkpoint_39(env, context, notif_status_update);});
608+
checkpoint_list.push_back([&](){checkpoint_40(env, context, notif_status_update);});
609+
checkpoint_list.push_back([&](){checkpoint_41(env, context, notif_status_update);});
610+
checkpoint_list.push_back([&](){checkpoint_42(env, context, notif_status_update);});
611+
checkpoint_list.push_back([&](){checkpoint_43(env, context, notif_status_update);});
612+
checkpoint_list.push_back([&](){checkpoint_44(env, context, notif_status_update);});
613+
checkpoint_list.push_back([&](){checkpoint_45(env, context, notif_status_update);});
614+
checkpoint_list.push_back([&](){checkpoint_46(env, context, notif_status_update);});
615+
checkpoint_list.push_back([&](){checkpoint_47(env, context, notif_status_update);});
616+
checkpoint_list.push_back([&](){checkpoint_48(env, context, notif_status_update);});
617+
checkpoint_list.push_back([&](){checkpoint_49(env, context, notif_status_update);});
616618

617619
for (int checkpoint = start; checkpoint <= end; checkpoint++){
618620
if (checkpoint == 0){
619621
console.log("checkpoint_0");
620622
checkpoint_list[checkpoint]();
621623
continue;
622624
}
625+
bool has_minimap = true;
626+
if (checkpoint < 3){
627+
has_minimap = false;
628+
}
623629

624630
const size_t DIGITS = 3;
625631
std::string number = std::to_string(checkpoint);
@@ -629,11 +635,21 @@ void AutoStory::test_checkpoints(
629635
if (checkpoint >= start_loop && checkpoint <= end_loop){
630636
for (int i = 0; i < loop; i++){
631637
if (i > 0){
632-
reset_game(env.program_info(), console, context);
633-
enter_menu_from_overworld(env.program_info(), env.console, context, -1);
634-
// we wait 10 seconds then save, so that the initial conditions are slightly different on each reset.
635-
env.log("Wait 10 seconds.");
636-
context.wait_for(Milliseconds(10 * 1000));
638+
try {
639+
reset_game(env.program_info(), console, context);
640+
enter_menu_from_overworld(env.program_info(), env.console, context, -1, MenuSide::NONE, has_minimap);
641+
// we wait 5 seconds then save, so that the initial conditions are slightly different on each reset.
642+
env.log("Wait 5 seconds.");
643+
context.wait_for(Milliseconds(5 * 1000));
644+
}catch(...){
645+
// try one more time
646+
reset_game(env.program_info(), console, context);
647+
enter_menu_from_overworld(env.program_info(), env.console, context, -1, MenuSide::NONE, has_minimap);
648+
// we wait 5 seconds then save, so that the initial conditions are slightly different on each reset.
649+
env.log("Wait 5 seconds.");
650+
context.wait_for(Milliseconds(5 * 1000));
651+
652+
}
637653
}
638654
console.log("checkpoint_" + number + ": loop " + std::to_string(i));
639655
checkpoint_list[checkpoint]();
@@ -740,7 +756,7 @@ void AutoStory::test_code(SingleSwitchProgramEnvironment& env, BotBaseContext& c
740756
// 128, 0, 60, 10, false);
741757

742758
DirectionDetector direction;
743-
759+
744760
return;
745761
}
746762

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,39 @@ void handle_when_stationary_in_overworld(
779779
}
780780

781781

782+
void handle_failed_action(
783+
const ProgramInfo& info,
784+
ConsoleHandle& console,
785+
BotBaseContext& context,
786+
std::function<
787+
void(const ProgramInfo& info,
788+
ConsoleHandle& console,
789+
BotBaseContext& context)
790+
>&& action,
791+
std::function<
792+
void(const ProgramInfo& info,
793+
ConsoleHandle& console,
794+
BotBaseContext& context)
795+
>&& recovery_action,
796+
size_t max_failures
797+
){
798+
size_t num_failures = 0;
799+
while (true){
800+
try {
801+
context.wait_for_all_requests();
802+
action(info, console, context);
803+
return;
804+
}catch (OperationFailedException& e){
805+
num_failures++;
806+
if (num_failures > max_failures){
807+
throw e;
808+
}
809+
recovery_action(info, console, context);
810+
}
811+
}
812+
}
813+
814+
782815
void wait_for_gradient_arrow(
783816
const ProgramInfo& info,
784817
ConsoleHandle& console,

SerialPrograms/Source/PokemonSV/Programs/AutoStory/PokemonSV_AutoStoryTools.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,24 @@ void handle_when_stationary_in_overworld(
213213
size_t max_attempts = 2
214214
);
215215

216+
// do action. if error is thrown, catch the error and try the recovery action
217+
void handle_failed_action(
218+
const ProgramInfo& info,
219+
ConsoleHandle& console,
220+
BotBaseContext& context,
221+
std::function<
222+
void(const ProgramInfo& info,
223+
ConsoleHandle& console,
224+
BotBaseContext& context)
225+
>&& action,
226+
std::function<
227+
void(const ProgramInfo& info,
228+
ConsoleHandle& console,
229+
BotBaseContext& context)
230+
>&& recovery_action,
231+
size_t max_failures
232+
);
233+
216234
void wait_for_gradient_arrow(
217235
const ProgramInfo& info,
218236
ConsoleHandle& console,

0 commit comments

Comments
 (0)