Skip to content

Commit a811738

Browse files
committed
confirm able to detect direction.
1 parent 4c1500a commit a811738

21 files changed

+214
-3
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonTools/Async/InferenceRoutines.h"
810
#include "NintendoSwitch/NintendoSwitch_Settings.h"
911
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
@@ -113,6 +115,13 @@ void checkpoint_24(
113115
[&](size_t attempt_number){
114116
context.wait_for_all_requests();
115117
DirectionDetector direction;
118+
VideoSnapshot snapshot = env.console.video().snapshot();
119+
double current_direction = direction.get_current_direction(env.console, snapshot);
120+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
121+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
122+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
123+
}
124+
116125
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
117126
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
118127
direction.change_direction(env.program_info(), env.console, context, 2.71);
@@ -188,6 +197,8 @@ void checkpoint_25(
188197

189198
// section 3
190199
DirectionDetector direction;
200+
// we just hope the minimap Direction isn't covered
201+
191202
direction.change_direction(env.program_info(), env.console, context, 6.0);
192203
pbf_move_left_joystick(context, 128, 0, 700, 100);
193204

@@ -292,6 +303,8 @@ void checkpoint_26(
292303

293304
// section 1b. realign using fence corner
294305
DirectionDetector direction;
306+
// we just hope the minimap Direction isn't covered
307+
295308
direction.change_direction(env.program_info(), env.console, context, 2.74);
296309
pbf_move_left_joystick(context, 128, 0, 200, 50);
297310
direction.change_direction(env.program_info(), env.console, context, 4.328);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonFramework/Exceptions/OperationFailedException.h"
810
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
911
#include "CommonTools/Async/InferenceRoutines.h"
@@ -83,6 +85,13 @@ void checkpoint_28(
8385
[&](size_t attempt_number){
8486
context.wait_for_all_requests();
8587
DirectionDetector direction;
88+
VideoSnapshot snapshot = env.console.video().snapshot();
89+
double current_direction = direction.get_current_direction(env.console, snapshot);
90+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
91+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
92+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
93+
}
94+
8695
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
8796
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
8897
direction.change_direction(env.program_info(), env.console, context, 2.71);

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonFramework/Exceptions/OperationFailedException.h"
810
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
911
#include "CommonTools/Async/InferenceRoutines.h"
@@ -147,6 +149,17 @@ void checkpoint_32(
147149
run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG);
148150
clear_dialog(env.console, context, ClearDialogMode::STOP_OVERWORLD, 60, {CallbackEnum::OVERWORLD, CallbackEnum::BLACK_DIALOG_BOX});
149151

152+
context.wait_for_all_requests();
153+
VideoSnapshot snapshot = env.console.video().snapshot();
154+
DirectionDetector direction;
155+
double current_direction = direction.get_current_direction(env.console, snapshot);
156+
if (current_direction == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint.
157+
OperationFailedException::fire(
158+
ErrorReport::SEND_ERROR_REPORT,
159+
"Unable to detect direction. Reset.",
160+
env.console
161+
);
162+
}
150163

151164
});
152165

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonFramework/Exceptions/OperationFailedException.h"
810
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
911
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
@@ -86,6 +88,13 @@ void checkpoint_35(
8688
[&](size_t attempt_number){
8789
context.wait_for_all_requests();
8890
DirectionDetector direction;
91+
VideoSnapshot snapshot = env.console.video().snapshot();
92+
double current_direction = direction.get_current_direction(env.console, snapshot);
93+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
94+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
95+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
96+
}
97+
8998
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
9099
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
91100
direction.change_direction(env.program_info(), env.console, context, 0.3491);

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonFramework/Exceptions/OperationFailedException.h"
810
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
911
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
@@ -86,6 +88,13 @@ void checkpoint_37(
8688
[&](size_t attempt_number){
8789
context.wait_for_all_requests();
8890
DirectionDetector direction;
91+
VideoSnapshot snapshot = env.console.video().snapshot();
92+
double current_direction = direction.get_current_direction(env.console, snapshot);
93+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
94+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 255, 128, 50});
95+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_OUT, 0, 128, 80});
96+
}
97+
8998
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
9099
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
91100
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 255, 50);
@@ -129,6 +138,8 @@ void checkpoint_38(
129138
context.wait_for_all_requests();
130139
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 180, 170});
131140
DirectionDetector direction;
141+
// recently flew a significant distance, so minimap should be clear of Pokemon
142+
132143
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
133144
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
134145
direction.change_direction(env.program_info(), env.console, context, 0.3491);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void checkpoint_39(
9191
context.wait_for_all_requests();
9292

9393
DirectionDetector direction;
94+
// recently flew a significant distance, so minimap should be clear of Pokemon
9495

9596
// section 1
9697
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
@@ -256,6 +257,8 @@ void checkpoint_40(
256257
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 180, 90);
257258

258259
DirectionDetector direction;
260+
// recently flew a significant distance, so minimap should be clear of Pokemon
261+
259262
direction.change_direction(env.program_info(), env.console, context, 5.60);
260263

261264
get_on_ride(env.program_info(), env.console, context);

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonFramework/Exceptions/OperationFailedException.h"
810
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
911
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
@@ -92,6 +94,13 @@ void checkpoint_41(
9294

9395
// section 1
9496
DirectionDetector direction;
97+
VideoSnapshot snapshot = env.console.video().snapshot();
98+
double current_direction = direction.get_current_direction(env.console, snapshot);
99+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
100+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 60});
101+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 128, 60});
102+
}
103+
95104
direction.change_direction(env.program_info(), env.console, context, 0.14);
96105
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
97106
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
*/
66

7+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
8+
79
#include "CommonFramework/Exceptions/OperationFailedException.h"
810
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
911
#include "CommonTools/Async/InferenceRoutines.h"
@@ -111,6 +113,13 @@ void checkpoint_43(
111113
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 128, 50);
112114

113115
DirectionDetector direction;
116+
VideoSnapshot snapshot = env.console.video().snapshot();
117+
double current_direction = direction.get_current_direction(env.console, snapshot);
118+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
119+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 0});
120+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 128, 30});
121+
}
122+
114123
do_action_and_monitor_for_battles(env.program_info(), env.console, context,
115124
[&](const ProgramInfo& info, VideoStream& stream, ProControllerContext& context){
116125
direction.change_direction(env.program_info(), env.console, context, 6.198);
@@ -550,7 +559,7 @@ void checkpoint_46(
550559
// wait for overworld after leaving Gym
551560
wait_for_overworld(env.program_info(), env.console, context, 30);
552561

553-
// fly to Porto Marinada pokecenter
562+
// fly to Artazon east pokecenter
554563
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::ZOOM_IN, 255, 128, 50});
555564

556565
// section 1. set marker to pokecenter

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include "PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h"
77
#include "CommonTools/Async/InferenceRoutines.h"
8+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
89

910
#include "CommonFramework/Exceptions/OperationFailedException.h"
1011
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
@@ -98,6 +99,13 @@ void checkpoint_47(
9899
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 0, 110, 100);
99100

100101
DirectionDetector direction;
102+
VideoSnapshot snapshot = env.console.video().snapshot();
103+
double current_direction = direction.get_current_direction(env.console, snapshot);
104+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
105+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 255, 50});
106+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 128, 0, 50});
107+
}
108+
101109
direction.change_direction(env.program_info(), env.console, context, 2.06);
102110
pbf_move_left_joystick(context, 128, 0, 200, 100);
103111

@@ -129,6 +137,18 @@ void checkpoint_47(
129137
run_trainer_battle_press_A(env.console, context, BattleStopCondition::STOP_DIALOG);
130138
mash_button_till_overworld(env.console, context, BUTTON_A);
131139

140+
141+
context.wait_for_all_requests();
142+
VideoSnapshot snapshot2 = env.console.video().snapshot();
143+
double current_direction2 = direction.get_current_direction(env.console, snapshot2);
144+
if (current_direction2 == -1){ // if unable to detect current direction, reset. We need to be able to detect the direction for the next checkpoint.
145+
OperationFailedException::fire(
146+
ErrorReport::SEND_ERROR_REPORT,
147+
"Unable to detect direction. Reset.",
148+
env.console
149+
);
150+
}
151+
132152

133153
});
134154

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
*
55
*/
66

7-
#include "PokemonSV/Inference/Overworld/PokemonSV_DirectionDetector.h"
87
#include "PokemonSV/Inference/PokemonSV_WhiteTriangleDetector.h"
98
#include "PokemonSV/Inference/Battles/PokemonSV_NormalBattleMenus.h"
109
#include "CommonTools/Async/InferenceRoutines.h"
10+
#include "CommonFramework/VideoPipeline/VideoFeed.h"
1111

1212
#include "CommonFramework/Exceptions/OperationFailedException.h"
1313
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
@@ -111,6 +111,13 @@ void checkpoint_50(
111111
realign_player(env.program_info(), env.console, context, PlayerRealignMode::REALIGN_NEW_MARKER, 255, 60, 50);
112112

113113
DirectionDetector direction;
114+
VideoSnapshot snapshot = env.console.video().snapshot();
115+
double current_direction = direction.get_current_direction(env.console, snapshot);
116+
if (current_direction == -1){ // if unable to detect current direction, fly to neighbouring Pokecenter, then fly back. To hopefully clear any pokemon covering the Minimap.
117+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 255, 255, 70});
118+
move_cursor_towards_flypoint_and_go_there(env.program_info(), env.console, context, {ZoomChange::KEEP_ZOOM, 0, 0, 70});
119+
}
120+
114121
direction.change_direction(env.program_info(), env.console, context, 0);
115122
pbf_move_left_joystick(context, 128, 0, 150, 100);
116123

0 commit comments

Comments
 (0)