-
Notifications
You must be signed in to change notification settings - Fork 102
FRLG EV Trainer #1135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
theastrogoth
wants to merge
23
commits into
PokemonAutomation:main
Choose a base branch
from
theastrogoth:tag/ev-trainer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
FRLG EV Trainer #1135
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
9c46e1b
preliminary ev trainer
theastrogoth 2cb48db
Merge branch 'main' into tag/ev-trainer
theastrogoth a05dbbd
add faint detection and work out a few bugs
theastrogoth 15b1d4c
enforce filename case change
theastrogoth 23f9f5a
Delete SerialPrograms/Source/PokemonFRLG/Programs/Farming/PokemonFRLG…
theastrogoth 2329307
Delete SerialPrograms/Source/PokemonFRLG/Programs/Farming/PokemonFRLG…
theastrogoth 20f7bf8
Merge branch 'main' into tag/ev-trainer
theastrogoth 77302f2
oops
theastrogoth 865175e
tweak stats display, various fixes
theastrogoth cab5b82
handle post-battle evolution
theastrogoth e2d66c3
fixed handling of evolution
theastrogoth d6881b6
Merge branch 'main' into tag/ev-trainer
theastrogoth be373dd
implement SpD stuff
theastrogoth b369d52
add missing black border check
theastrogoth 9d4a1e3
fix Pickup Farmer changes
theastrogoth 9fad1fe
remove redundant grass_spin()
theastrogoth e642b31
pickup farmer fixes
theastrogoth 8d25ac7
small fix for teak_pickup_items() timing
theastrogoth 03c0555
better recovery for exit_wild_battle()
theastrogoth 9935e2e
Fixed review comments
theastrogoth f5e4318
tweaks to wild species OCR
theastrogoth b44ace4
oops, add missing EV info for onix
theastrogoth 7de9e47
pickup farmer typo
theastrogoth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
SerialPrograms/Source/PokemonFRLG/Inference/Map/PokemonFRLG_MapDetector.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* Map Detector | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #include "CommonTools/Images/SolidColorTest.h" | ||
| #include "CommonTools/Images/ImageFilter.h" | ||
| #include "CommonFramework/ImageTools/ImageBoxes.h" | ||
| #include "CommonFramework/ImageTools/ImageStats.h" | ||
| #include "CommonFramework/ImageTypes/ImageViewRGB32.h" | ||
| #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" | ||
| #include "CommonTools/Images/SolidColorTest.h" | ||
| #include "CommonTools/Images/WaterfillUtilities.h" | ||
| #include "PokemonFRLG/PokemonFRLG_Settings.h" | ||
| #include "PokemonFRLG_MapDetector.h" | ||
|
|
||
| namespace PokemonAutomation{ | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonFRLG{ | ||
|
|
||
| KantoMapDetector::KantoMapDetector(Color color) | ||
| : m_top_box(0.010, 0.010, 0.500, 0.080) // blue (0, 122, 255) | ||
| , m_left_box(0.069, 0.110, 0.025, 0.880) // white | ||
| , m_right_box(0.902, 0.110, 0.025, 0.880) // white | ||
| , m_land_box(0.105, 0.600, 0.087, 0.028) // green (31, 173, 0) | ||
| // , m_route_25_box(0.603, 0.252, 0.090, 0.040) // orange (255, 176, 0) | ||
| {} | ||
| void KantoMapDetector::make_overlays(VideoOverlaySet& items) const{ | ||
| const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_left_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_land_box)); | ||
| } | ||
| bool KantoMapDetector::detect(const ImageViewRGB32& screen){ | ||
| ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); | ||
|
|
||
| ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); | ||
| ImageViewRGB32 left_image = extract_box_reference(game_screen, m_left_box); | ||
| ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); | ||
| ImageViewRGB32 land_image = extract_box_reference(game_screen, m_land_box); | ||
| if (is_solid(top_image, { 0.0000, 0.3236, 0.6764 }, 0.25, 20) | ||
| && is_white(left_image) | ||
| && is_white(right_image) | ||
| && is_solid(land_image, { 0.1520, 0.8480, 0.0000 }, 0.25, 20) | ||
| ){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
SerialPrograms/Source/PokemonFRLG/Inference/Map/PokemonFRLG_MapDetector.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* Map Detector | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #ifndef PokemonAutomation_PokemonFRLG_MapDetector_H | ||
| #define PokemonAutomation_PokemonFRLG_MapDetector_H | ||
|
|
||
| #include <chrono> | ||
| #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" | ||
| #include "Common/Cpp/Color.h" | ||
| #include "CommonFramework/ImageTools/ImageBoxes.h" | ||
| #include "CommonTools/VisualDetector.h" | ||
| #include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" | ||
|
|
||
| namespace PokemonAutomation{ | ||
| class CancellableScope; | ||
| class VideoFeed; | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonFRLG{ | ||
|
|
||
| // Detect the map screen for Kanto | ||
| class KantoMapDetector : public StaticScreenDetector{ | ||
| public: | ||
| KantoMapDetector(Color color); | ||
|
|
||
| virtual void make_overlays(VideoOverlaySet& items) const override; | ||
| virtual bool detect(const ImageViewRGB32& screen) override; | ||
|
|
||
| private: | ||
| ImageFloatBox m_top_box; | ||
| ImageFloatBox m_left_box; | ||
| ImageFloatBox m_right_box; | ||
| ImageFloatBox m_land_box; | ||
| }; | ||
| class KantoMapWatcher : public DetectorToFinder<KantoMapDetector>{ | ||
| public: | ||
| KantoMapWatcher(Color color) | ||
| : DetectorToFinder("KantoMapWatcher", std::chrono::milliseconds(250), color) | ||
| {} | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif |
92 changes: 92 additions & 0 deletions
92
SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* Battle Pokemon Detector | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #include "CommonTools/Images/SolidColorTest.h" | ||
| #include "CommonTools/Images/ImageFilter.h" | ||
| #include "CommonFramework/ImageTools/ImageBoxes.h" | ||
| #include "CommonFramework/ImageTools/ImageStats.h" | ||
| #include "CommonFramework/ImageTypes/ImageViewRGB32.h" | ||
| #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" | ||
| #include "CommonTools/Images/SolidColorTest.h" | ||
| #include "CommonTools/Images/WaterfillUtilities.h" | ||
| #include "PokemonFRLG/PokemonFRLG_Settings.h" | ||
| #include "PokemonFRLG_BattlePokemonDetector.h" | ||
|
|
||
| // #include <iostream> | ||
| // using std::cout; | ||
| // using std::endl; | ||
|
|
||
| namespace PokemonAutomation{ | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonFRLG{ | ||
|
|
||
| BattlePokemonDetector::BattlePokemonDetector(Color color) | ||
| // be warned: the name/level/hp box moves up and down a little bit | ||
| : m_left_box(0.577404, 0.504327, 0.001442, 0.121875) // off-white (255, 255, 236), can be interrupted by a status condition | ||
| , m_right_box(0.948558, 0.585096, 0.000481, 0.063462) // dark teal (74, 111, 102) | ||
| , m_top_box(0.594712, 0.481971, 0.325962, 0.002163) // off-white, movement makes this unreliable | ||
| , m_bottom_box(0.554808, 0.674519, 0.034615, 0.002163) // dark teal | ||
| {} | ||
| void BattlePokemonDetector::make_overlays(VideoOverlaySet& items) const{ | ||
| const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_left_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); | ||
| } | ||
| bool BattlePokemonDetector::detect(const ImageViewRGB32& screen){ | ||
| ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); | ||
|
|
||
| ImageViewRGB32 left_image = extract_box_reference(game_screen, m_left_box); | ||
| ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); | ||
| ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); | ||
| ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); | ||
| if (is_solid(left_image, { 0.3418, 0.3418, 0.3164 }) | ||
| && is_solid(right_image, { 0.2578, 0.3868, 0.3554 }, 0.075, 5) | ||
| && is_solid(top_image, { 0.3418, 0.3418, 0.3164 }) | ||
| && is_solid(bottom_image, { 0.2578, 0.3868, 0.3554 }, 0.075, 5) | ||
| ){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| BattleOpponentDetector::BattleOpponentDetector(Color color) | ||
| : m_left_box(0.067308, 0.140865, 0.001442, 0.090144) // off-white (255, 255, 236) | ||
| , m_right_box(0.422596, 0.132211, 0.000481, 0.054808) // off-white | ||
| , m_top_box(0.085577, 0.119952, 0.329327, 0.000721) // off-white | ||
| , m_bottom_box(0.109615, 0.264182, 0.328365, 0.001442) // dark teal (74, 111, 102) | ||
| {} | ||
| void BattleOpponentDetector::make_overlays(VideoOverlaySet& items) const{ | ||
| const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_left_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_right_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_top_box)); | ||
| items.add(COLOR_RED, GAME_BOX.inner_to_outer(m_bottom_box)); | ||
| } | ||
| bool BattleOpponentDetector::detect(const ImageViewRGB32& screen){ | ||
| ImageViewRGB32 game_screen = extract_box_reference(screen, GameSettings::instance().GAME_BOX); | ||
|
|
||
| ImageViewRGB32 left_image = extract_box_reference(game_screen, m_left_box); | ||
| ImageViewRGB32 right_image = extract_box_reference(game_screen, m_right_box); | ||
| ImageViewRGB32 top_image = extract_box_reference(game_screen, m_top_box); | ||
| ImageViewRGB32 bottom_image = extract_box_reference(game_screen, m_bottom_box); | ||
|
|
||
| if (is_solid(left_image, { 0.3418, 0.3418, 0.3164 }) | ||
| && is_solid(right_image, { 0.3418, 0.3418, 0.3164 }) | ||
| && is_solid(top_image, { 0.3418, 0.3418, 0.3164 }) | ||
| && is_solid(bottom_image, { 0.2578, 0.3868, 0.3554 }, 0.075, 5) | ||
| ){ | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } |
77 changes: 77 additions & 0 deletions
77
SerialPrograms/Source/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* Map Detector | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #ifndef PokemonAutomation_PokemonFRLG_BattlePokemonDetector_H | ||
| #define PokemonAutomation_PokemonFRLG_BattlePokemonDetector_H | ||
|
|
||
| #include <chrono> | ||
| #include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" | ||
| #include "Common/Cpp/Color.h" | ||
| #include "CommonFramework/ImageTools/ImageBoxes.h" | ||
| #include "CommonTools/VisualDetector.h" | ||
| #include "CommonTools/InferenceCallbacks/VisualInferenceCallback.h" | ||
|
|
||
| namespace PokemonAutomation{ | ||
| class CancellableScope; | ||
| class VideoFeed; | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonFRLG{ | ||
|
|
||
| // Detect a player's Pokemon that is currently battling (not fainted) | ||
| class BattlePokemonDetector : public StaticScreenDetector{ | ||
| public: | ||
| BattlePokemonDetector(Color color); | ||
|
|
||
| virtual void make_overlays(VideoOverlaySet& items) const override; | ||
| virtual bool detect(const ImageViewRGB32& screen) override; | ||
|
|
||
| private: | ||
| ImageFloatBox m_left_box; | ||
| ImageFloatBox m_right_box; | ||
| ImageFloatBox m_top_box; | ||
| ImageFloatBox m_bottom_box; | ||
| }; | ||
|
|
||
| // Watches for the player's Pokemon to disappear | ||
| class BattleFaintWatcher : public DetectorToFinder<BattlePokemonDetector>{ | ||
| public: | ||
| BattleFaintWatcher(Color color) | ||
| : DetectorToFinder("BattleFaintWatcher", FinderType::GONE, std::chrono::milliseconds(2000), color) | ||
| {} | ||
| }; | ||
|
|
||
| // Detect an opposing Pokemon that is currently battling (not fainted) | ||
| class BattleOpponentDetector : public StaticScreenDetector{ | ||
| public: | ||
| BattleOpponentDetector(Color color); | ||
|
|
||
| virtual void make_overlays(VideoOverlaySet& items) const override; | ||
| virtual bool detect(const ImageViewRGB32& screen) override; | ||
|
|
||
| private: | ||
| ImageFloatBox m_left_box; | ||
| ImageFloatBox m_right_box; | ||
| ImageFloatBox m_top_box; | ||
| ImageFloatBox m_bottom_box; | ||
| }; | ||
|
|
||
| // Watches for the opponent to disappear | ||
| class BattleOpponentFaintWatcher : public DetectorToFinder<BattleOpponentDetector>{ | ||
| public: | ||
| BattleOpponentFaintWatcher(Color color) | ||
| : DetectorToFinder("BattleOPponentFaintWatcher", FinderType::GONE, std::chrono::milliseconds(1000), color) | ||
| {} | ||
| }; | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| #endif |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.