Skip to content

Commit fee7693

Browse files
committed
FRLG tests, adjust dialog detectors
1 parent 431bff5 commit fee7693

5 files changed

Lines changed: 76 additions & 12 deletions

File tree

SerialPrograms/Source/PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ bool WhiteDialogDetector::detect(const ImageViewRGB32& screen){
3939
ImageViewRGB32 right_image = extract_box_reference(screen, m_right_box);
4040
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
4141
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
42-
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
43-
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
44-
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
42+
if (is_solid(right_image, { 0.333333, 0.333333, 0.333333 })
43+
&& is_solid(top_image, { 0.333333, 0.333333, 0.333333 })
44+
&& is_solid(bottom_image, { 0.333333, 0.333333, 0.333333 })
4545
){
4646
return true;
4747
}
@@ -81,11 +81,11 @@ bool AdvanceWhiteDialogDetector::detect(const ImageViewRGB32& screen){
8181
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
8282
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
8383

84-
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
85-
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
86-
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
87-
&& (stats.average.r > stats.average.b + 200)
88-
&& (stats.average.r > stats.average.g + 200)
84+
if (is_solid(right_image, { 0.333333, 0.333333, 0.333333 })
85+
&& is_solid(top_image, { 0.333333, 0.333333, 0.333333 })
86+
&& is_solid(bottom_image, { 0.333333, 0.333333, 0.333333 })
87+
&& (stats.average.r > stats.average.b + 180)
88+
&& (stats.average.r > stats.average.g + 180)
8989
)
9090
{
9191
return true;
@@ -110,10 +110,10 @@ bool SelectionDialogDetector::detect(const ImageViewRGB32& screen){
110110
ImageViewRGB32 top_image = extract_box_reference(screen, m_top_box);
111111
ImageViewRGB32 bottom_image = extract_box_reference(screen, m_bottom_box);
112112
ImageViewRGB32 selection_image = extract_box_reference(screen, m_selection_box);
113-
if (is_solid(right_image, { 0.25, 0.38, 0.369 })
114-
&& is_solid(top_image, { 0.25, 0.38, 0.369 })
115-
&& is_solid(bottom_image, { 0.25, 0.38, 0.369 })
116-
&& is_solid(selection_image, { 0.25, 0.38, 0.369 })
113+
if (is_solid(right_image, { 0.333333, 0.333333, 0.333333 })
114+
&& is_solid(top_image, { 0.333333, 0.333333, 0.333333 })
115+
&& is_solid(bottom_image, { 0.333333, 0.333333, 0.333333 })
116+
&& is_solid(selection_image, { 0.333333, 0.333333, 0.333333 })
117117
){
118118
return true;
119119
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* PokemonFRLG Tests
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*/
6+
7+
8+
#include "CommonFramework/Logging/Logger.h"
9+
#include "PokemonFRLG/Inference/Dialogs/PokemonFRLG_DialogDetector.h"
10+
#include "PokemonFRLG_Tests.h"
11+
#include "TestUtils.h"
12+
#include "CommonFramework/Language.h"
13+
#include "CommonFramework/ImageTools/ImageBoxes.h"
14+
#include "CommonFramework/Recording/StreamHistorySession.h"
15+
#include "NintendoSwitch/Controllers/SerialPABotBase/NintendoSwitch_SerialPABotBase_WiredController.h"
16+
#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h"
17+
18+
#include <iostream>
19+
using std::cout;
20+
using std::cerr;
21+
using std::endl;
22+
23+
namespace PokemonAutomation{
24+
25+
using namespace NintendoSwitch;
26+
using namespace NintendoSwitch::PokemonFRLG;
27+
28+
int test_pokemonFRLG_AdvanceWhiteDialogDetector(const ImageViewRGB32& image, bool target){
29+
auto overlay = DummyVideoOverlay();
30+
AdvanceWhiteDialogDetector detector(COLOR_RED);
31+
bool result = detector.detect(image);
32+
TEST_RESULT_EQUAL(result, target);
33+
return 0;
34+
}
35+
36+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* PokemonFRLG Tests
2+
*
3+
* From: https://github.com/PokemonAutomation/
4+
*
5+
*
6+
*/
7+
8+
9+
#ifndef PokemonAutomation_Tests_PokemonFRLG_Tests_H
10+
#define PokemonAutomation_Tests_PokemonFRLG_Tests_H
11+
12+
#include <vector>
13+
#include <string>
14+
15+
namespace PokemonAutomation{
16+
17+
class ImageViewRGB32;
18+
19+
20+
int test_pokemonFRLG_AdvanceWhiteDialogDetector(const ImageViewRGB32& image, bool target);
21+
22+
}
23+
24+
#endif

SerialPrograms/Source/Tests/TestMap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "CommonFramework_Tests.h"
1010
#include "Kernels_Tests.h"
1111
#include "NintendoSwitch_Tests.h"
12+
#include "PokemonFRLG_Tests.h"
1213
#include "PokemonHome_Tests.h"
1314
#include "PokemonLA_Tests.h"
1415
#include "PokemonLZA_Tests.h"
@@ -308,6 +309,7 @@ const std::map<std::string, TestFunction> TEST_MAP = {
308309
{"PokemonLZA_HyperspaceCalorieDetector", std::bind(image_int_detector_helper, test_pokemonLZA_HyperspaceCalorieDetector, _1)},
309310
{"PokemonLZA_FlavorPowerScreenDetector", test_pokemonLZA_FlavorPowerScreenDetector},
310311
{"PokemonLZA_DonutBerriesReader", test_pokemonLZA_DonutBerriesReader},
312+
{"PokemonFRLG_AdvanceWhiteDialogDetector", std::bind(image_bool_detector_helper, test_pokemonFRLG_AdvanceWhiteDialogDetector, _1)},
311313
};
312314

313315
TestFunction find_test_function(const std::string& test_space, const std::string& test_name){

SerialPrograms/cmake/SourceFiles.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2660,6 +2660,8 @@ file(GLOB LIBRARY_SOURCES
26602660
Source/Tests/Kernels_Tests.h
26612661
Source/Tests/NintendoSwitch_Tests.cpp
26622662
Source/Tests/NintendoSwitch_Tests.h
2663+
Source/Tests/PokemonFRLG_Tests.cpp
2664+
Source/Tests/PokemonFRLG_Tests.h
26632665
Source/Tests/PokemonHome_Tests.cpp
26642666
Source/Tests/PokemonHome_Tests.h
26652667
Source/Tests/PokemonLA_Tests.cpp

0 commit comments

Comments
 (0)