Skip to content

Commit c6c29bc

Browse files
authored
LGPE alolan trades / test program (#545)
* LGPE setup * alolan trade work, shiny symbol detector work * trading and open summary works * cleanup and comments * pull out run_trade
1 parent 57ee5ab commit c6c29bc

File tree

9 files changed

+496
-0
lines changed

9 files changed

+496
-0
lines changed

SerialPrograms/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,12 @@ file(GLOB MAIN_SOURCES
13601360
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h
13611361
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp
13621362
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h
1363+
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp
1364+
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h
1365+
Source/PokemonLGPE/Programs/PokemonLGPE_AlolanTrade.cpp
1366+
Source/PokemonLGPE/Programs/PokemonLGPE_AlolanTrade.h
1367+
Source/PokemonLGPE/PokemonLGPE_Panels.cpp
1368+
Source/PokemonLGPE/PokemonLGPE_Panels.h
13631369
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.cpp
13641370
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h
13651371
Source/PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.cpp

SerialPrograms/SerialPrograms.pro

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,9 @@ SOURCES += \
667667
Source/PokemonLA/Resources/PokemonLA_NameDatabase.cpp \
668668
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.cpp \
669669
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.cpp \
670+
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.cpp \
671+
Source/PokemonLGPE/Programs/PokemonLGPE_AlolanTrade.cpp \
672+
Source/PokemonLGPE/PokemonLGPE_Panels.cpp \
670673
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.cpp \
671674
Source/PokemonRSE/Inference/PokemonRSE_ShinyNumberDetector.cpp \
672675
Source/PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.cpp \
@@ -1846,6 +1849,9 @@ HEADERS += \
18461849
Source/PokemonLA/Resources/PokemonLA_NameDatabase.h \
18471850
Source/PokemonLA/Resources/PokemonLA_PokemonSprites.h \
18481851
Source/PokemonLA/Resources/PokemonLA_WeatherAndTimeIcons.h \
1852+
Source/PokemonLGPE/Inference/PokemonLGPE_ShinySymbolDetector.h \
1853+
Source/PokemonLGPE/Programs/PokemonLGPE_AlolanTrade.h \
1854+
Source/PokemonLGPE/PokemonLGPE_Panels.h \
18491855
Source/PokemonRSE/Inference/Dialogs/PokemonRSE_DialogDetector.h \
18501856
Source/PokemonRSE/Inference/PokemonRSE_ShinyNumberDetector.h \
18511857
Source/PokemonRSE/Inference/Sounds/PokemonRSE_ShinySoundDetector.h \

SerialPrograms/Source/PanelLists.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "PokemonHome/PokemonHome_Panels.h"
1919
#include "PokemonBDSP/PokemonBDSP_Panels.h"
2020
#include "PokemonLA/PokemonLA_Panels.h"
21+
#include "PokemonLGPE/PokemonLGPE_Panels.h"
2122
#include "PokemonRSE/PokemonRSE_Panels.h"
2223
#include "PokemonSV/PokemonSV_Panels.h"
2324
#include "ZeldaTotK/ZeldaTotK_Panels.h"
@@ -51,6 +52,7 @@ ProgramSelect::ProgramSelect(QWidget& parent, PanelHolder& holder)
5152
add(std::make_unique<NintendoSwitch::PokemonSV::PanelListFactory>());
5253
if (PreloadSettings::instance().DEVELOPER_MODE) {
5354
add(std::make_unique<NintendoSwitch::PokemonRSE::PanelListFactory>());
55+
add(std::make_unique<NintendoSwitch::PokemonLGPE::PanelListFactory>());
5456
}
5557
add(std::make_unique<NintendoSwitch::ZeldaTotK::PanelListFactory>());
5658

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* Shiny Symbol Detector
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "Common/Cpp/Color.h"
8+
#include "CommonFramework/ImageTools/ImageBoxes.h"
9+
#include "CommonFramework/ImageTools/ImageStats.h"
10+
#include "CommonFramework/ImageTypes/ImageRGB32.h"
11+
#include "CommonFramework/ImageTypes/ImageViewRGB32.h"
12+
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
13+
#include "CommonTools/Images/ImageFilter.h"
14+
#include "PokemonLGPE_ShinySymbolDetector.h"
15+
16+
#include <iostream>
17+
using std::cout;
18+
using std::endl;
19+
20+
namespace PokemonAutomation{
21+
namespace NintendoSwitch{
22+
namespace PokemonLGPE{
23+
24+
ShinySymbolDetector::ShinySymbolDetector(Color color)
25+
: m_box_star(0.666, 0.779, 0.028, 0.044)
26+
{}
27+
void ShinySymbolDetector::make_overlays(VideoOverlaySet& items) const{
28+
items.add(COLOR_RED, m_box_star);
29+
}
30+
bool ShinySymbolDetector::read(Logger& logger, const ImageViewRGB32& frame){
31+
/*
32+
Shiny (charizard):
33+
Add infer box: (0.6660, 0.7790, 0.0280, 0.0440), RGB avg [159, 123, 125] avg sum 408 ratio [0.391, 0.301, 0.308] stddev [74.898, 54.696, 53.354] sum 182.948 crop size (54, 48)
34+
35+
Not shiny (chansey):
36+
Add infer box: (0.6660, 0.7790, 0.0280, 0.0440), RGB avg [82, 113, 100] avg sum 295 ratio [0.276, 0.384, 0.340] stddev [15.477, 2.178, 2.648] sum 20.303 crop size (54, 48)
37+
38+
Only had the two to test with for now.
39+
*/
40+
41+
const auto stats = image_stats(extract_box_reference(frame, m_box_star));
42+
return stats.stddev.sum() > 100;
43+
}
44+
45+
46+
}
47+
}
48+
}
49+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/* Shiny Symbol Detector
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonRSE_ShinyNumberDetector_H
8+
#define PokemonAutomation_PokemonRSE_ShinyNumberDetector_H
9+
10+
#include "Common/Cpp/AbstractLogger.h"
11+
#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h"
12+
13+
namespace PokemonAutomation{
14+
namespace NintendoSwitch{
15+
namespace PokemonLGPE{
16+
17+
//Check for the red shiny star on a Pokemon's summary from the Party/Box menu.
18+
//This does not work for the summary that appears after a catch.
19+
class ShinySymbolDetector{
20+
public:
21+
ShinySymbolDetector(Color color);
22+
23+
virtual void make_overlays(VideoOverlaySet& items) const;
24+
bool read(Logger& logger, const ImageViewRGB32& frame);
25+
26+
private:
27+
ImageFloatBox m_box_star;
28+
};
29+
30+
31+
32+
}
33+
}
34+
}
35+
#endif
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* Pokemon LGPE Panels
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#include "CommonFramework/GlobalSettingsPanel.h"
8+
#include "Pokemon/Pokemon_Strings.h"
9+
#include "PokemonLGPE_Panels.h"
10+
11+
#include "Programs/PokemonLGPE_AlolanTrade.h"
12+
13+
namespace PokemonAutomation{
14+
namespace NintendoSwitch{
15+
namespace PokemonLGPE{
16+
17+
PanelListFactory::PanelListFactory()
18+
: PanelListDescriptor(Pokemon::STRING_POKEMON + " Let's Go Pikachu and Eevee")
19+
{}
20+
21+
std::vector<PanelEntry> PanelListFactory::make_panels() const{
22+
std::vector<PanelEntry> ret;
23+
24+
ret.emplace_back("---- Settings ----");
25+
//ret.emplace_back(make_settings<GameSettings_Descriptor, GameSettingsPanel>());
26+
27+
//ret.emplace_back("---- General ----");
28+
29+
ret.emplace_back("---- Shiny Hunting ----");
30+
ret.emplace_back(make_single_switch_program<AlolanTrade_Descriptor, AlolanTrade>());
31+
32+
return ret;
33+
}
34+
35+
36+
37+
38+
}
39+
}
40+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* Pokemon LGPE Panels
2+
*
3+
* From: https://github.com/PokemonAutomation/Arduino-Source
4+
*
5+
*/
6+
7+
#ifndef PokemonAutomation_PokemonLGPE_Panels_H
8+
#define PokemonAutomation_PokemonLGPE_Panels_H
9+
10+
#include "CommonFramework/Panels/PanelList.h"
11+
12+
namespace PokemonAutomation{
13+
namespace NintendoSwitch{
14+
namespace PokemonLGPE{
15+
16+
class PanelListFactory : public PanelListDescriptor{
17+
public:
18+
PanelListFactory();
19+
virtual std::vector<PanelEntry> make_panels() const;
20+
};
21+
22+
23+
24+
}
25+
}
26+
}
27+
#endif

0 commit comments

Comments
 (0)