Skip to content

Commit 998e2d1

Browse files
committed
Improve HP reading for AutoDA.
1 parent bc02681 commit 998e2d1

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

SerialPrograms/Source/NintendoSwitch/DevPrograms/TestProgramSwitch.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
#include "NintendoSwitch/Programs/NintendoSwitch_NumberCodeEntry.h"
122122
#include "PokemonSV/Inference/ItemPrinter/PokemonSV_ItemPrinterMenuDetector.h"
123123
#include "PokemonSV/Inference/Picnics/PokemonSV_SandwichHandDetector.h"
124+
#include "PokemonSwSh/MaxLair/Inference/PokemonSwSh_MaxLair_Detect_PokemonSwapMenu.h"
124125

125126

126127
#include <QPixmap>
@@ -317,6 +318,15 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
317318

318319
// std::terminate();
319320

321+
ImageRGB32 image("20250420-043111395281.png");
322+
323+
OcrFailureWatchdog watchdog(logger);
324+
325+
PokemonSwSh::MaxLairInternal::PokemonSwapMenuReader reader(logger, overlay, Language::Korean, watchdog);
326+
327+
double hp[4];
328+
reader.read_hp(image, hp);
329+
320330

321331
#if 0
322332
ImageRGB32 image("20250404-154507236508.png");
@@ -385,17 +395,17 @@ void TestProgram::program(MultiSwitchProgramEnvironment& env, CancellableScope&
385395
#endif
386396

387397

388-
numberpad_enter_code(logger, context, "708538991006", false);
398+
// numberpad_enter_code(logger, context, "708538991006", false);
389399

390400

391401

392402
#if 0
393403
for (size_t i = 0; i < 100; i++){
394-
for (size_t c = 0; c < 7; c++){
395-
ssf_issue_scroll(context, DPAD_RIGHT, 40ms);
404+
for (size_t c = 0; c < 4; c++){
405+
ssf_issue_scroll(context, DPAD_RIGHT, 17ms);
396406
}
397-
for (size_t c = 0; c < 7; c++){
398-
ssf_issue_scroll(context, DPAD_LEFT, 40ms);
407+
for (size_t c = 0; c < 4; c++){
408+
ssf_issue_scroll(context, DPAD_LEFT, 17ms);
399409
}
400410
}
401411
#endif

SerialPrograms/Source/Pokemon/Inference/Pokemon_ReadHpBar.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ double read_hp_bar_internal(const ImageViewRGB32& image){
3535
max_color = std::max(max_color, stats.average.g);
3636
max_color = std::max(max_color, stats.average.b);
3737
// cout << "max_color: " << max_color << ", stddev: " << stats.stddev.sum() << endl;
38-
if (max_color > 128 && stats.stddev.sum() < 70){
38+
if (max_color > 128 && stats.stddev.sum() < 120){
3939
break;
4040
}
4141
bar *= 0.5;
@@ -83,8 +83,10 @@ double read_hp_bar(const ImageViewRGB32& image){
8383

8484
double read_hp_bar(Logger& logger, const ImageViewRGB32& image){
8585
double hp = read_hp_bar(image);
86+
8687
// static int c = 0;
8788
// image.save("test-" + std::to_string(c++) + ".png");
89+
8890
if (hp <= 0){
8991
logger.log("HP Read: ?", COLOR_RED);
9092
}else{

0 commit comments

Comments
 (0)