Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
346b15a
BDSP MenuDetector and ShortDialogDetector: also detect the new game's…
dayfine Nov 2, 2026
b033840
BDSP MenuDetector: keep its check; test the new game's menu with skip…
dayfine Nov 2, 2026
5059026
Merge remote-tracking branch 'origin/bdsp/walk-v4' into bdsp/detector…
dayfine Nov 2, 2026
2b44bfe
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
cc96587
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
a947b3d
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
25068d0
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
c20de26
Merge bdsp/walk-v4 forward
dayfine Nov 2, 2026
6bafbb4
Merge bdsp/nav-v4 forward
dayfine Nov 2, 2026
15100a0
Merge bdsp/nav-v4 forward
dayfine Nov 2, 2026
4f6d3d2
Merge the BDSP chain forward
dayfine Nov 2, 2026
28d6105
Merge the BDSP chain forward
dayfine Nov 2, 2026
451cfaf
Merge the BDSP chain forward
dayfine Nov 2, 2026
6195ebc
Merge the BDSP chain forward
dayfine Nov 2, 2026
cddc4a8
Merge the BDSP chain forward
dayfine Nov 2, 2026
b05be8a
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
41cfcf1
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
f85bad6
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
a46a54f
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
3934be6
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
25f75b7
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
a69880e
BDSP MenuDetector: columns clear of the NEW tags' edges
dayfine Nov 2, 2026
81d410d
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
67c6ca5
BDSP detectors: Floaroma and Jubilife menu and dialogue images
dayfine Nov 2, 2026
99f22ff
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
13a56e1
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
843d063
Merge bdsp/maps-v4 (coord events) into bdsp/detectors-v4
dayfine Nov 2, 2026
0d4d23e
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 2, 2026
139d483
Merge bdsp/walk-v4 (b22e9471c: verify mode from #122) into bdsp/detec…
dayfine Nov 3, 2026
f5a3c42
Merge commit '89f673f74988cea2333e7dd157136f3aa5f39f0e' into HEAD
dayfine Nov 5, 2026
6251b06
Merge remote-tracking branch 'origin/bdsp/walk-v4' into bdsp/detector…
dayfine Nov 6, 2026
1b23b0c
BDSP MenuDetector: label namespace closing braces
dayfine Nov 6, 2026
176f793
BDSP detectors: use explicit image test cases and current style
dayfine Nov 7, 2026
814798e
Merge remote-tracking branch 'origin/bdsp/walk-v4' into bdsp/detector…
dayfine Nov 7, 2026
46a5fae
Merge remote-tracking branch 'origin/bdsp/walk-v4' into bdsp/detector…
dayfine Nov 7, 2026
48f3792
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 8, 2026
8cde2ac
Merge remote-tracking branch 'origin/bdsp/walk-v4' into bdsp/detector…
dayfine Nov 8, 2026
f4dfe38
Merge remote-tracking branch 'origin/bdsp/walk-v4' into bdsp/detector…
dayfine Nov 8, 2026
27ce3d5
Merge origin/bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 8, 2026
305f659
Merge remote-tracking branch 'origin/bdsp/walk-v4' into HEAD
dayfine Nov 9, 2026
024466b
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
efc8d9a
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
5678f2f
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
e8c03d0
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
cc9e573
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
6be7975
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
19e1038
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
cd4cf05
BDSP: register the dialog and menu detector tests with the BDSP tests
dayfine Nov 9, 2026
2e01abc
Merge bdsp/walk-v4 (merge of #122 b3aa69e19) into bdsp/detectors-v4
dayfine Nov 9, 2026
3b2e4a2
Merge bdsp/walk-v4 (timed walk events, open-leg battle placement) int…
dayfine Nov 9, 2026
a770bf7
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
f3b024b
Merge bdsp/walk-v4 (open-leg battles placed by screen events) into bd…
dayfine Nov 9, 2026
5b662ec
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
9700de8
Merge bdsp/walk-v4 into bdsp/detectors-v4
dayfine Nov 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
*
*/

#include <array>
#include <format>
#include <string_view>
#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "CommonFramework/VideoPipeline/VideoOverlay.h"
#include "CommonTools/Images/SolidColorTest.h"
#include "Tests/ImageUnitTest.h"
#include "PokemonBDSP_DialogDetector.h"

//#include <iostream>
Expand All @@ -23,16 +28,18 @@
, m_left_white(0.21, 0.835, 0.008, 0.12)
, m_left(0.18, 0.835, 0.02, 0.12)
, m_right_white(0.785, 0.835, 0.008, 0.12)
, m_right_white_low(0.785, 0.915, 0.008, 0.04)
, m_right(0.822, 0.835, 0.02, 0.12)
{}
void ShortDialogDetector::make_overlays(VideoOverlaySet& items) const{
// items.add(m_color, m_bottom);
items.add(m_color, m_left_white);
items.add(m_color, m_left);
items.add(m_color, m_right_white);
items.add(m_color, m_right_white_low);
items.add(m_color, m_right);
}
bool ShortDialogDetector::detect(const ImageViewRGB32& screen){

Check warning on line 42 in SerialPrograms/Source/PokemonBDSP/Inference/PokemonBDSP_DialogDetector.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::ShortDialogDetector::detect( const ImageViewRGB32 & screen): function_lines=29 (advisory above 25, limit 50)

Check warning on line 42 in SerialPrograms/Source/PokemonBDSP/Inference/PokemonBDSP_DialogDetector.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::ShortDialogDetector::detect( const ImageViewRGB32 & screen): function_lines=29 (advisory above 25, limit 50)
ImageStats left_white = image_stats(extract_box_reference(screen, m_left_white));
// cout << left_white.average << left_white.stddev << endl;
if (!is_white(left_white)){
Expand All @@ -40,7 +47,9 @@
}
ImageStats right_white = image_stats(extract_box_reference(screen, m_right_white));
// cout << right_white.average << right_white.stddev << endl;
if (!is_white(right_white)){
// A long first line runs into m_right_white (Rowan's "Now, go on, and
// leap into the world of Pokemon!"). Check below that line as well.
if (!is_white(right_white) && !is_white(image_stats(extract_box_reference(screen, m_right_white_low)))){
return false;
}
// ImageStats bottom = image_stats(extract_box_reference(screen, m_bottom));
Expand Down Expand Up @@ -125,6 +134,63 @@





namespace{

// The captured screen supplied to the short-dialog detector.
struct DialogInput{
std::string_view image;
};
// Whether a short dialog should be visible in that screen.
struct DialogExpectation{
bool detected = false;
};
// One image and its independently specified expected result.
struct DialogCase{
DialogInput input;
DialogExpectation expectation;
};

// Runs the detector on the original image and the image-test color distortions.
class Test_ShortDialogDetector : public ImageUnitTest{
public:
explicit Test_ShortDialogDetector(const DialogCase& test)
: ImageUnitTest(std::format("PokemonBDSP::ShortDialogDetector - {}", test.input.image), {std::string(test.input.image)})
, m_expectation(test.expectation)
{}

virtual UnitTestResult run_on_images(
Logger&, CancellableScope&,
const std::vector<ImageRGB32>& images
) const override{
const bool detected = ShortDialogDetector().detect(images[0]);
if (detected != m_expectation.detected){
return std::format("Expected short dialog detected={}, read {}.", m_expectation.detected, detected);
}
return true;
}

private:
DialogExpectation m_expectation;
};

} // namespace

void add_tests_DialogDetector(UnitTestDatabase& database){
static constexpr std::array<DialogCase, 6> CASES{{
{.input = {.image = "PokemonBDSP/DialogDetector/IntroRowanNameTab_True.png"}, .expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/DialogDetector/IntroRowanNoArrow_True.png"}, .expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/DialogDetector/IntroRowanShortLine_True.png"}, .expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/DialogDetector/JubilifeUnknownNameTab_True.png"}, .expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/DialogDetector/FloaromaOldManOneLine_True.png"}, .expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/DialogDetector/FloaromaCloudShadows_False.png"}, .expectation = {.detected = false}},
}};
for (const DialogCase& test : CASES){
database.add<Test_ShortDialogDetector>(test);
}
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we get another one here that's "regular"?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added IntroRowanShortLine_True.png (dayfine/CommandLineTests#1): a normal box with one short line that the old right-end check already accepts. It is still an intro frame; an overworld one needs a console capture if you want that too.

}
}

} // namespace PokemonBDSP
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_PokemonBDSP_BattleDialogDetector_H
#define PokemonAutomation_PokemonBDSP_BattleDialogDetector_H

#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"
#include "CommonTools/VisualDetector.h"
#include "PokemonBDSP_SelectionArrow.h"
Expand All @@ -31,6 +32,7 @@ class ShortDialogDetector : public StaticScreenDetector{
ImageFloatBox m_left_white;
ImageFloatBox m_left;
ImageFloatBox m_right_white;
ImageFloatBox m_right_white_low;
ImageFloatBox m_right;
};
class ShortDialogWatcher : public DetectorToFinder<ShortDialogDetector>{
Expand Down Expand Up @@ -79,7 +81,11 @@ class ShortDialogPromptDetector : public VisualInferenceCallback{



}
}
}

// The screenshot tests in CommandLineTests/PokemonBDSP/DialogDetector/.
void add_tests_DialogDetector(UnitTestDatabase& database);

} // namespace PokemonBDSP
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,38 @@
*
*/

#include <array>
#include <format>
#include <string_view>
#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "CommonFramework/ImageTools/ImageStats.h"
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
#include "CommonTools/Images/SolidColorTest.h"
#include "Tests/ImageUnitTest.h"
#include "PokemonBDSP_MenuDetector.h"

namespace PokemonAutomation{
namespace NintendoSwitch{
namespace PokemonBDSP{


const double STRIPE_TOP = 0.110;
const double STRIPE_TOP_BELOW_BANNER = 0.170;
const double STRIPE_BOTTOM = 0.598;
namespace{

static ImageFloatBox menu_stripe(size_t index, bool skip_new_banner){
constexpr double STRIPE_TOP = 0.110;
constexpr double STRIPE_TOP_BELOW_BANNER = 0.170;
constexpr double STRIPE_BOTTOM = 0.598;

// Each column sits in the gap right of an icon, clear of the "NEW" tag on
// its top right corner. The tag on TOWN MAP extends into a column at 0.160.
constexpr double STRIPE_LEFT = 0.166;

ImageFloatBox menu_stripe(size_t index, bool skip_new_banner){
double top = skip_new_banner ? STRIPE_TOP_BELOW_BANNER : STRIPE_TOP;
return ImageFloatBox(0.160 + 0.166 * (double)index, top, 0.015, STRIPE_BOTTOM - top);
return ImageFloatBox(STRIPE_LEFT + 0.166 * (double)index, top, 0.015, STRIPE_BOTTOM - top);
}

} // namespace

MenuDetector::MenuDetector(Color color, bool skip_new_banner)
: m_color(color)
, m_line0(menu_stripe(0, skip_new_banner))
Expand Down Expand Up @@ -84,6 +97,108 @@



namespace{

// Selects full-height columns or columns starting below the NEW tags.
enum class Columns{
FromTop,
BelowNewTags,
};
// A screen and the existing detector mode used to inspect it.
struct MenuInput{
std::string_view image;
Columns columns = Columns::FromTop;
};
// Whether the screen should be recognized as the X menu.
struct MenuExpectation{
bool detected = false;
};
// One screen/mode pair and its independently specified expected result.
struct MenuCase{
MenuInput input;
MenuExpectation expectation;
};

// Verifies both detector modes, including the image-test color distortions.
class Test_MenuDetector : public ImageUnitTest{
public:
explicit Test_MenuDetector(const MenuCase& test)
: ImageUnitTest(
std::format("PokemonBDSP::MenuDetector{} - {}",
test.input.columns == Columns::BelowNewTags ? "(skip_new_banner)" : "", test.input.image),
{std::string(test.input.image)}
)
, m_columns(test.input.columns)
, m_expectation(test.expectation)
{}

virtual UnitTestResult run_on_images(
Logger&, CancellableScope&,
const std::vector<ImageRGB32>& images
) const override{
MenuDetector detector(COLOR_RED, /*skip_new_banner=*/m_columns == Columns::BelowNewTags);
const bool detected = detector.detect(images[0]);
if (detected != m_expectation.detected){
return std::format("Expected menu detected={}, read {}.", m_expectation.detected, detected);
}
return true;
}

private:
Columns m_columns = Columns::FromTop;
MenuExpectation m_expectation;
};

} // namespace

void add_tests_MenuDetector(UnitTestDatabase& database){

Check warning on line 154 in SerialPrograms/Source/PokemonBDSP/Inference/PokemonBDSP_MenuDetector.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::add_tests_MenuDetector( UnitTestDatabase & database): function_lines=47 (advisory above 25, limit 50)

Check warning on line 154 in SerialPrograms/Source/PokemonBDSP/Inference/PokemonBDSP_MenuDetector.cpp

View workflow job for this annotation

GitHub Actions / code-health

Code health (advisory)

PokemonAutomation::NintendoSwitch::PokemonBDSP::add_tests_MenuDetector( UnitTestDatabase & database): function_lines=47 (advisory above 25, limit 50)
static constexpr std::array<MenuCase, 20> CASES{{
{.input = {.image = "PokemonBDSP/MenuDetector/NewGameBagOptions_True.png", .columns = Columns::FromTop},
.expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/MenuDetector/NewGameBagOptions_True.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/MenuDetector/JubilifeTownMapNew_True.png", .columns = Columns::FromTop},
.expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/MenuDetector/JubilifeTownMapNew_True.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/MenuDetector/FloaromaMenuThreeNew_True.png", .columns = Columns::FromTop},
.expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/MenuDetector/FloaromaMenuThreeNew_True.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = true}},
{.input = {.image = "PokemonBDSP/MenuDetector/Home_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/Home_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/OverworldSandgemMart_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/OverworldSandgemMart_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/OverworldOreburghMine_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/OverworldOreburghMine_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/IntroDialog_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/IntroDialog_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/IntroBarry_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/IntroBarry_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/FloaromaOldManDialog_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/FloaromaOldManDialog_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/FloaromaCloudShadows_False.png", .columns = Columns::FromTop},
.expectation = {.detected = false}},
{.input = {.image = "PokemonBDSP/MenuDetector/FloaromaCloudShadows_False.png", .columns = Columns::BelowNewTags},
.expectation = {.detected = false}},
}};
for (const MenuCase& test : CASES){
database.add<Test_MenuDetector>(test);
}
}
}
}

} // namespace PokemonBDSP
} // namespace NintendoSwitch
} // namespace PokemonAutomation
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#ifndef PokemonAutomation_PokemonBDSP_MenuDetector_H
#define PokemonAutomation_PokemonBDSP_MenuDetector_H

#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "Common/Cpp/Color.h"
#include "CommonFramework/ImageTools/ImageBoxes.h"
#include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h"
Expand Down Expand Up @@ -46,7 +47,10 @@ class MenuWatcher : public MenuDetector, public VisualInferenceCallback{



}
}
}
// The screenshot tests in CommandLineTests/PokemonBDSP/MenuDetector/.
void add_tests_MenuDetector(UnitTestDatabase& database);

} // namespace PokemonBDSP
} // namespace NintendoSwitch
} // namespace PokemonAutomation
#endif
4 changes: 4 additions & 0 deletions SerialPrograms/Source/PokemonBDSP/PokemonBDSP_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/

#include "Common/Cpp/TestRunners/UnitTestDatabase.h"
#include "Inference/PokemonBDSP_DialogDetector.h"
#include "Inference/PokemonBDSP_MenuDetector.h"
#include "Programs/AutoStory/PokemonBDSP_AutoStory_Maps_Tests.h"
#include "Programs/AutoStory/PokemonBDSP_AutoStory_PlannedRoute_Tests.h"
#include "Programs/AutoStory/PokemonBDSP_AutoStory_RoutePlanner_Tests.h"
Expand All @@ -21,6 +23,8 @@ namespace PokemonBDSP{


void add_tests(UnitTestDatabase& database){
add_tests_DialogDetector(database);
add_tests_MenuDetector(database);
add_tests_AutoStory_Maps(database);
add_tests_AutoStory_StoryWorld(database);
add_tests_AutoStory_RoutePlanner(database);
Expand Down
Loading