Skip to content

Commit 3c6a0bc

Browse files
committed
Another fix to Flying Trial Farmer.
1 parent 187e957 commit 3c6a0bc

File tree

8 files changed

+27
-18
lines changed

8 files changed

+27
-18
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,20 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
313313

314314
// std::terminate();
315315

316+
ImageRGB32 image("20250323-011605651979.png");
317+
318+
DialogBoxDetector detector;
319+
detector.make_overlays(overlays);
320+
cout << detector.detect(image) << endl;
321+
322+
323+
324+
#if 0
316325
auto image = feed.snapshot();
317326

318327
ItemPrinterMenuDetector detector(COLOR_GREEN);
319328
cout << detector.detect(image) << endl;
320-
329+
#endif
321330

322331

323332
#if 0

SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ bool DialogBoxDetector::detect(const ImageViewRGB32& screen) const{
6767

6868
ImageStats stats_border_top = image_stats(extract_box_reference(screen, m_border_top));
6969
// cout << stats_border_top.average << stats_border_top.stddev << endl;
70-
if (stats_border_top.stddev.sum() < 75){
70+
if (stats_border_top.stddev.sum() < 50){
7171
return !m_true_if_detected;
7272
}
7373

@@ -83,8 +83,8 @@ bool DialogBoxDetector::detect(const ImageViewRGB32& screen) const{
8383

8484

8585

86-
AdvanceDialogDetector::AdvanceDialogDetector(Color color)
87-
: m_box(color)
86+
AdvanceDialogDetector::AdvanceDialogDetector(Color color, DialogType type)
87+
: m_box(color, true, type)
8888
, m_arrow(0.710, 0.850, 0.030, 0.042)
8989
{}
9090
void AdvanceDialogDetector::make_overlays(VideoOverlaySet& items) const{

SerialPrograms/Source/PokemonSV/Inference/Dialogs/PokemonSV_DialogDetector.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class DialogBoxWatcher : public DetectorToFinder<DialogBoxDetector>{
6161
// It should be able to detect both the white background dialog and black background dialog.
6262
class AdvanceDialogDetector : public StaticScreenDetector{
6363
public:
64-
AdvanceDialogDetector(Color color = COLOR_RED);
64+
AdvanceDialogDetector(Color color = COLOR_RED, DialogType type = DialogType::DIALOG_ALL);
6565

6666
virtual void make_overlays(VideoOverlaySet& items) const override;
6767
virtual bool detect(const ImageViewRGB32& screen) const override;
@@ -72,8 +72,8 @@ class AdvanceDialogDetector : public StaticScreenDetector{
7272
};
7373
class AdvanceDialogWatcher : public DetectorToFinder<AdvanceDialogDetector>{
7474
public:
75-
AdvanceDialogWatcher(Color color, std::chrono::milliseconds duration = std::chrono::milliseconds(250))
76-
: DetectorToFinder("AdvanceDialogWatcher", duration, color)
75+
AdvanceDialogWatcher(Color color, DialogType type = DialogType::DIALOG_ALL, std::chrono::milliseconds duration = std::chrono::milliseconds(250))
76+
: DetectorToFinder("AdvanceDialogWatcher", duration, color, type)
7777
{}
7878
};
7979

@@ -102,14 +102,14 @@ class PromptDialogWatcher : public DetectorToFinder<PromptDialogDetector>{
102102
Color color,
103103
std::chrono::milliseconds duration = std::chrono::milliseconds(250)
104104
)
105-
: DetectorToFinder("PromptDialogWatcher", std::chrono::milliseconds(250), color)
105+
: DetectorToFinder("PromptDialogWatcher", duration, color)
106106
{}
107107
PromptDialogWatcher(
108108
Color color,
109109
const ImageFloatBox& arrow_box,
110110
std::chrono::milliseconds duration = std::chrono::milliseconds(250)
111111
)
112-
: DetectorToFinder("PromptDialogWatcher", std::chrono::milliseconds(250), color, arrow_box)
112+
: DetectorToFinder("PromptDialogWatcher", duration, color, arrow_box)
113113
{}
114114
};
115115

SerialPrograms/Source/PokemonSV/Programs/Boxes/PokemonSV_BoxAttach.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void attach_item_from_bag(
4343
GradientArrowWatcher bag_neutral(COLOR_RED, GradientArrowType::RIGHT, {0.10, 0.15, 0.05, 0.77}, std::chrono::milliseconds(1000));
4444
GradientArrowWatcher selected(COLOR_RED, GradientArrowType::RIGHT, {0.20, 0.20, 0.30, 0.60});
4545
PromptDialogWatcher prompt(COLOR_CYAN, std::chrono::milliseconds(100));
46-
AdvanceDialogWatcher advance_dialog(COLOR_YELLOW, std::chrono::milliseconds(100));
46+
AdvanceDialogWatcher advance_dialog(COLOR_YELLOW, DialogType::DIALOG_ALL, std::chrono::milliseconds(100));
4747

4848
context.wait_for_all_requests();
4949
int ret = wait_until(

SerialPrograms/Source/PokemonSV/Programs/Boxes/PokemonSV_BoxRelease.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void release_one_pokemon(
4545
BoxWatcher box_detector(COLOR_RED);
4646
BoxSelectWatcher selected(COLOR_YELLOW, std::chrono::milliseconds(100));
4747
PromptDialogWatcher confirm(COLOR_CYAN, std::chrono::milliseconds(100));
48-
AdvanceDialogWatcher advance_dialog(COLOR_GREEN, std::chrono::milliseconds(250));
48+
AdvanceDialogWatcher advance_dialog(COLOR_GREEN, DialogType::DIALOG_ALL, std::chrono::milliseconds(250));
4949

5050
context.wait_for_all_requests();
5151
int ret = wait_until(

SerialPrograms/Source/PokemonSV/Programs/Eggs/PokemonSV_EggRoutines.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void order_compote_du_fils(
157157
while(eating == false){
158158
context.wait_for_all_requests();
159159

160-
AdvanceDialogWatcher dialog_watcher(COLOR_RED, std::chrono::milliseconds(100));
160+
AdvanceDialogWatcher dialog_watcher(COLOR_RED, DialogType::DIALOG_ALL, std::chrono::milliseconds(100));
161161
GradientArrowWatcher menu_item_0_watcher(COLOR_BLUE, GradientArrowType::RIGHT, {0.037, 0.224, 0.074, 0.104});
162162
GradientArrowWatcher menu_item_1_watcher(COLOR_BLUE, GradientArrowType::RIGHT, {0.037, 0.339, 0.074, 0.104});
163163
PromptDialogWatcher prompt_watcher(COLOR_RED, {0.535, 0.450, 0.367, 0.124});
@@ -205,7 +205,7 @@ void order_compote_du_fils(
205205
} // end state machine for restaurant menu
206206

207207
{ // Now wait for eating animation to finish.
208-
AdvanceDialogWatcher dialog_watcher(COLOR_RED, std::chrono::milliseconds(100));
208+
AdvanceDialogWatcher dialog_watcher(COLOR_RED, DialogType::DIALOG_ALL, std::chrono::milliseconds(100));
209209
int ret = run_until<ProControllerContext>(
210210
stream, context,
211211
[](ProControllerContext& context){
@@ -229,7 +229,7 @@ void order_compote_du_fils(
229229
while(true){
230230
context.wait_for_all_requests();
231231

232-
AdvanceDialogWatcher dialog_watcher(COLOR_RED, std::chrono::milliseconds(100));
232+
AdvanceDialogWatcher dialog_watcher(COLOR_RED, DialogType::DIALOG_ALL, std::chrono::milliseconds(100));
233233
OverworldWatcher overworld(stream.logger(), COLOR_CYAN);
234234
int ret = wait_until(
235235
stream, context,

SerialPrograms/Source/PokemonSV/Programs/Farming/PokemonSV_FlyingTrialFarmer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ FlyingTrialFarmer::FlyingTrialFarmer()
116116
bool FlyingTrialFarmer::run_rewards(SingleSwitchProgramEnvironment& env, ProControllerContext& context){
117117
// Wait until a dialog shows up.
118118
{
119-
DialogBoxWatcher dialog(COLOR_GREEN, true);
119+
AdvanceDialogWatcher dialog(COLOR_RED);
120120
int ret = wait_until(
121121
env.console, context,
122122
std::chrono::seconds(180),
@@ -135,8 +135,8 @@ bool FlyingTrialFarmer::run_rewards(SingleSwitchProgramEnvironment& env, ProCont
135135
bool trial_passed = false;
136136
while (true){
137137
OverworldWatcher overworld(env.console, COLOR_CYAN);
138-
DialogBoxWatcher dialog_white(COLOR_GREEN, true, std::chrono::milliseconds(250), DialogType::DIALOG_WHITE);
139-
DialogBoxWatcher dialog_black(COLOR_GREEN, true, std::chrono::milliseconds(250), DialogType::DIALOG_BLACK);
138+
AdvanceDialogWatcher dialog_white(COLOR_RED, DialogType::DIALOG_WHITE);
139+
AdvanceDialogWatcher dialog_black(COLOR_RED, DialogType::DIALOG_BLACK);
140140
context.wait_for_all_requests();
141141

142142
int ret_finish = wait_until(

SerialPrograms/Source/PokemonSV/Programs/Trading/PokemonSV_TradeRoutines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void trade_current_pokemon(
150150
TradeDoneHold trade_done(stream.overlay());
151151

152152
while (true){
153-
AdvanceDialogWatcher dialog(COLOR_YELLOW, std::chrono::seconds(2));
153+
AdvanceDialogWatcher dialog(COLOR_YELLOW, DialogType::DIALOG_ALL, std::chrono::seconds(2));
154154
PromptDialogWatcher learn_move(COLOR_BLUE);
155155

156156
int ret = wait_until(

0 commit comments

Comments
 (0)