Skip to content

Commit c08cf59

Browse files
committed
audio only feedback type, rename program
1 parent 3b679ed commit c08cf59

File tree

9 files changed

+77
-343
lines changed

9 files changed

+77
-343
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,8 +1293,8 @@ file(GLOB MAIN_SOURCES
12931293
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h
12941294
Source/PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.cpp
12951295
Source/PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h
1296-
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.cpp
1297-
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_StarterReset.h
1296+
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.cpp
1297+
Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h
12981298
Source/PokemonRSE/Programs/TestPrograms/PokemonRSE_SoundListener.cpp
12991299
Source/PokemonRSE/Programs/TestPrograms/PokemonRSE_SoundListener.h
13001300
Source/PokemonRSE/PokemonRSE_Navigation.cpp

SerialPrograms/Source/CommonFramework/Globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ enum class FeedbackType{
6969
NONE,
7070
OPTIONAL_, // Naming conflict with macro.
7171
REQUIRED,
72+
AUDIO,
7273
VIDEO_AUDIO,
7374
};
7475

SerialPrograms/Source/CommonFramework/Panels/UI/PanelElements.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ CollapsibleGroupBox* make_panel_header(
8080
header
8181
);
8282
break;
83+
case FeedbackType::AUDIO:
84+
text = new QLabel(
85+
"<font color=\"green\">(This program requires audio feedback. Please make sure you choose the correct audio device.)</font>",
86+
header
87+
);
88+
break;
8389
case FeedbackType::VIDEO_AUDIO:
8490
text = new QLabel(
8591
"<font color=\"green\">(This program requires video and audio feedback. Please make sure you choose the correct capture device, as well as the correct audio device.)</font>",

SerialPrograms/Source/PokemonRSE/PokemonRSE_Panels.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "PokemonRSE_Settings.h"
1212

13-
#include "Programs/ShinyHunting/PokemonRSE_StarterReset.h"
13+
#include "Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h"
1414
#include "Programs/TestPrograms/PokemonRSE_SoundListener.h"
1515

1616
namespace PokemonAutomation{
@@ -20,7 +20,7 @@ namespace PokemonRSE{
2020

2121

2222
PanelListFactory::PanelListFactory()
23-
: PanelListDescriptor("Pokemon Ruby, Sapphire, and Emerald")
23+
: PanelListDescriptor("Pokemon Ruby and Sapphire, Pokemon Emerald")
2424
{}
2525

2626
std::vector<PanelEntry> PanelListFactory::make_panels() const{
@@ -35,8 +35,8 @@ std::vector<PanelEntry> PanelListFactory::make_panels() const{
3535

3636

3737
if (PreloadSettings::instance().DEVELOPER_MODE){
38-
ret.emplace("---- WIP: Shiny Hunting (Audio only) ----");
39-
ret.emplace_back(make_single_switch_program<StarterReset_Descriptor, StarterReset>());
38+
ret.emplace_back("---- WIP: Shiny Hunting (Audio only) ----");
39+
ret.emplace_back(make_single_switch_program<AudioStarterReset_Descriptor, AudioStarterReset>());
4040

4141
ret.emplace_back("---- Developer Tools ----");
4242
ret.emplace_back(make_single_switch_program<SoundListener_Descriptor, SoundListener>());

SerialPrograms/Source/PokemonRSE/PokemonRSE_Settings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ GameSettings::GameSettings()
4545
, SHINY_SOUND_THRESHOLD(
4646
"<b>Shiny Sound Threshold:</b><br>Maximum error coefficient to trigger a shiny detection.",
4747
LockMode::LOCK_WHILE_RUNNING,
48-
0.87, 0, 1.0
48+
0.97, 0, 1.0
4949
)
5050
, SHINY_SOUND_LOW_FREQUENCY(
5151
"<b>Shiny Sound Low Frequency (Hz):</b><br>High pass filter frequency for shiny sound.",

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.cpp

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
*
55
*/
66

7+
#include "Common/Cpp/PrettyPrint.h"
78
#include "CommonFramework/Exceptions/OperationFailedException.h"
8-
#include "CommonFramework/ProgramStats/StatsTracking.h"
9-
#include "CommonFramework/VideoPipeline/VideoFeed.h"
10-
#include "CommonTools/Async/InferenceRoutines.h"
9+
#include "CommonFramework/InferenceInfra/InferenceRoutines.h"
1110
#include "CommonFramework/Notifications/ProgramNotifications.h"
11+
#include "CommonFramework/Tools/VideoResolutionCheck.h"
12+
#include "CommonFramework/Tools/StatsTracking.h"
1213
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h"
13-
#include "Pokemon/Pokemon_Strings.h"
14-
#include "PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h"
14+
#include "NintendoSwitch/Commands/NintendoSwitch_Commands_Superscalar.h"
1515
#include "PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h"
1616
#include "PokemonRSE/PokemonRSE_Navigation.h"
1717
#include "PokemonRSE_AudioStarterReset.h"
@@ -23,12 +23,12 @@ namespace PokemonRSE{
2323
AudioStarterReset_Descriptor::AudioStarterReset_Descriptor()
2424
: SingleSwitchProgramDescriptor(
2525
"PokemonRSE:AudioStarterReset",
26-
Pokemon::STRING_POKEMON + " RSE", "Starter Reset (Ruby/Sapphire)",
26+
"Pokemon RSE", "[RS] Starter Reset - Audio only",
2727
"ComputerControl/blob/master/Wiki/Programs/PokemonRSE/AudioStarterReset.md",
28-
"Soft reset for a shiny starter. Ruby and Sapphire only.",
29-
FeedbackType::VIDEO_AUDIO,
28+
"Soft reset for a shiny starter. Ruby and Sapphire only. WIP, audio recognition does not work well.",
29+
FeedbackType::AUDIO,
3030
AllowCommandsWhenRunning::DISABLE_COMMANDS,
31-
{SerialPABotBase::OLD_NINTENDO_SWITCH_DEFAULT_REQUIREMENTS}
31+
PABotBaseLevel::PABOTBASE_12KB
3232
)
3333
{}
3434

@@ -61,14 +61,26 @@ AudioStarterReset::AudioStarterReset()
6161
LockMode::LOCK_WHILE_RUNNING,
6262
Target::treecko
6363
)
64+
, POOCH_WAIT(
65+
"<b>Battle start wait:</b><br>Time for battle to start and for Poochyena to appear. Make sure to add extra time in case the Poochyena is shiny.",
66+
LockMode::LOCK_WHILE_RUNNING,
67+
TICKS_PER_SECOND,
68+
"6 * TICKS_PER_SECOND"
69+
)
70+
, STARTER_WAIT(
71+
"<b>Send out starter wait:</b><br>After pressing A to send out your selected starter, wait this long for the animation. Make sure to add extra time in case it is shiny.",
72+
LockMode::LOCK_WHILE_RUNNING,
73+
TICKS_PER_SECOND,
74+
"6 * TICKS_PER_SECOND"
75+
)
6476
, NOTIFICATION_SHINY_POOCH(
6577
"Shiny Poochyena",
66-
false, false, ImageAttachmentMode::JPG,
78+
false, false,
6779
{"Notifs"}
6880
)
6981
, NOTIFICATION_SHINY_STARTER(
7082
"Shiny Starter",
71-
true, true, ImageAttachmentMode::JPG,
83+
true, false,
7284
{"Notifs", "Showcase"}
7385
)
7486
, NOTIFICATION_STATUS_UPDATE("Status Update", true, false, std::chrono::seconds(3600))
@@ -83,14 +95,12 @@ AudioStarterReset::AudioStarterReset()
8395
PA_ADD_OPTION(NOTIFICATIONS);
8496
}
8597

86-
void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context){
98+
void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, BotBaseContext& context){
99+
//assert_16_9_720p_min(env.logger(), env.console);
87100
AudioStarterReset_Descriptor::Stats& stats = env.current_stats<AudioStarterReset_Descriptor::Stats>();
88101

89102
/*
90103
* Settings: Text Speed fast.
91-
* Full screen, no filter? The device I'm using to test has similar looking output, but I don't have switch online+.
92-
* If on a retro handheld, make sure the screen matches that of NSO+.
93-
*
94104
* Setup: Stand in front of the Professor's bag and save the game.
95105
*
96106
* Required to fight, so have to do the SR method instead of run away
@@ -101,9 +111,8 @@ void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, SwitchContr
101111

102112
bool shiny_starter = false;
103113
while (!shiny_starter) {
104-
float shiny_coefficient = 1.0;
114+
105115
ShinySoundDetector pooch_detector(env.console, [&](float error_coefficient) -> bool{
106-
shiny_coefficient = error_coefficient;
107116
return true;
108117
});
109118

@@ -122,95 +131,77 @@ void AudioStarterReset::program(SingleSwitchProgramEnvironment& env, SwitchContr
122131
break;
123132
default:
124133
OperationFailedException::fire(
125-
ErrorReport::SEND_ERROR_REPORT,
126-
"AudioStarterReset: Invalid target.",
127-
env.console
134+
env.console, ErrorReport::SEND_ERROR_REPORT,
135+
"AudioStarterReset: Invalid target."
128136
);
129137
break;
130138
}
131139
pbf_mash_button(context, BUTTON_A, 540);
132-
context.wait_for_all_requests();
133-
134140
env.log("Starter selected. Checking for shiny Poochyena.");
135-
AdvanceBattleDialogWatcher pooch_appeared(COLOR_YELLOW);
136141

137-
int res = run_until<SwitchControllerContext>(
142+
143+
int ret = run_until(
138144
env.console, context,
139-
[&](SwitchControllerContext& context) {
140-
int ret = wait_until(
141-
env.console, context,
142-
std::chrono::seconds(20),
143-
{{pooch_appeared}}
144-
);
145-
if (ret == 0) {
146-
env.log("Advance arrow detected.");
147-
}
148-
pbf_wait(context, 125);
145+
[&](BotBaseContext& context){
146+
//Wait for battle to start and for Pooch battle cry
147+
pbf_wait(context, POOCH_WAIT);
148+
149149
context.wait_for_all_requests();
150+
150151
},
151152
{{pooch_detector}}
152153
);
153154
pooch_detector.throw_if_no_sound();
154-
if (res == 0){
155+
if (ret == 0){
155156
env.log("Shiny Poochyena detected!");
156157
stats.poochyena++;
157-
env.update_stats();
158-
send_program_notification(env, NOTIFICATION_SHINY_POOCH, COLOR_YELLOW, "Shiny Poochyena found", {}, "", env.console.video().snapshot(), true);
158+
send_program_status_notification(env, NOTIFICATION_SHINY_POOCH, "Shiny Poochyena found.");
159159
}
160160
else {
161161
env.log("Poochyena is not shiny.");
162162
}
163-
context.wait_for_all_requests();
164163

165-
float shiny_coefficient2 = 1.0;
166164
ShinySoundDetector starter_detector(env.console, [&](float error_coefficient) -> bool{
167-
shiny_coefficient2 = error_coefficient;
168165
return true;
169166
});
170167

171-
BattleMenuWatcher battle_menu(COLOR_RED);
172-
int res2 = run_until<SwitchControllerContext>(
168+
//Press A to send out your selected starter
169+
env.log("Sending out selected starter.");
170+
pbf_press_button(context, BUTTON_A, 40, 40);
171+
172+
int ret2 = run_until(
173173
env.console, context,
174-
[&](SwitchControllerContext& context) {
175-
env.log("Sending out selected starter.");
176-
pbf_press_button(context, BUTTON_A, 40, 40);
177-
178-
int ret = wait_until(
179-
env.console, context,
180-
std::chrono::seconds(20),
181-
{{battle_menu}}
182-
);
183-
if (ret == 0) {
184-
env.log("Battle menu detecteed!");
185-
}
186-
pbf_wait(context, 125);
174+
[&](BotBaseContext& context){
175+
env.log("Wait for starter to come out.");
176+
pbf_wait(context, STARTER_WAIT);
187177
context.wait_for_all_requests();
188178
},
189179
{{starter_detector}}
190180
);
191181
starter_detector.throw_if_no_sound();
192-
context.wait_for_all_requests();
193-
if (res2 == 0){
182+
if (ret2 == 0){
194183
env.log("Shiny starter detected!");
195184
stats.shinystarter++;
196-
env.update_stats();
197-
send_program_notification(env, NOTIFICATION_SHINY_STARTER, COLOR_YELLOW, "Shiny starter found!", {}, "", env.console.video().snapshot(), true);
185+
186+
send_program_status_notification(env, NOTIFICATION_SHINY_STARTER, "Shiny starter found!");
187+
198188
shiny_starter = true;
189+
break;
199190
}
200191
else {
201192
env.log("Starter is not shiny.");
202-
env.log("Soft resetting.");
203-
send_program_status_notification(
204-
env, NOTIFICATION_STATUS_UPDATE,
205-
"Soft resetting."
206-
);
207-
stats.resets++;
208-
env.update_stats();
209-
soft_reset(env.program_info(), env.console, context);
210193
}
194+
195+
env.log("Soft resetting.");
196+
send_program_status_notification(
197+
env, NOTIFICATION_STATUS_UPDATE,
198+
"Soft resetting."
199+
);
200+
soft_reset(env.program_info(), env.console, context);
201+
stats.resets++;
211202
}
212203

213-
//if system set to nintendo switch, have go home when done option?
204+
//TODO: if system set to nintendo switch, have go home when done option
214205

215206
send_program_finished_notification(env, NOTIFICATION_PROGRAM_FINISH);
216207
}

SerialPrograms/Source/PokemonRSE/Programs/ShinyHunting/PokemonRSE_AudioStarterReset.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AudioStarterReset_Descriptor : public SingleSwitchProgramDescriptor{
2626
class AudioStarterReset : public SingleSwitchProgramInstance{
2727
public:
2828
AudioStarterReset();
29-
virtual void program(SingleSwitchProgramEnvironment& env, SwitchControllerContext& context) override;
29+
virtual void program(SingleSwitchProgramEnvironment& env, BotBaseContext& context) override;
3030

3131
private:
3232
enum class Target{
@@ -36,6 +36,9 @@ class AudioStarterReset : public SingleSwitchProgramInstance{
3636
};
3737
EnumDropdownOption<Target> TARGET;
3838

39+
TimeExpressionOption<uint16_t> POOCH_WAIT;
40+
TimeExpressionOption<uint16_t> STARTER_WAIT;
41+
3942
EventNotificationOption NOTIFICATION_SHINY_POOCH;
4043
EventNotificationOption NOTIFICATION_SHINY_STARTER;
4144
EventNotificationOption NOTIFICATION_STATUS_UPDATE;

0 commit comments

Comments
 (0)