-
Notifications
You must be signed in to change notification settings - Fork 108
FRLG Starter Auto-RNG #1205
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
Merged
Mysticial
merged 13 commits into
PokemonAutomation:main
from
theastrogoth:tag/starter-rng
Apr 24, 2026
Merged
FRLG Starter Auto-RNG #1205
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
bbdd2af
reorganize FRLG RNG programs
theastrogoth c7af71d
Merge branch 'main' into tag/rng-organization
theastrogoth e739f5b
expose move_to_user
theastrogoth d54380a
get working seed/advance search
theastrogoth 36da38b
implement most of the program
theastrogoth 33824d0
fixes
theastrogoth 495b5a6
tweaks
theastrogoth 4bb6376
fix conflicts
theastrogoth f39d3af
merge main
theastrogoth 0a03a83
fix filters update
theastrogoth 1afb7d9
add get_hits_string() message for no hits
theastrogoth 3da14a8
add missing hits display update
theastrogoth f098660
make a few things const
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
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
188 changes: 188 additions & 0 deletions
188
SerialPrograms/Source/PokemonFRLG/Programs/RngManipulation/PokemonFRLG_RngDisplays.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,188 @@ | ||
| /* RNG Displays | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #include <vector> | ||
| #include <iostream> | ||
| #include <sstream> | ||
| #include "PokemonFRLG_RngDisplays.h" | ||
|
|
||
| namespace PokemonAutomation{ | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonFRLG{ | ||
|
|
||
| using namespace Pokemon; | ||
|
|
||
| RngFilterDisplay::RngFilterDisplay() | ||
| : GroupOption("Observed Stats", LockMode::READ_ONLY) | ||
| , hp(false, "<b>HP IV:</b>", LockMode::READ_ONLY, "-", "") | ||
| , atk(false, "<b>Attack IV:</b>", LockMode::READ_ONLY, "-", "") | ||
| , def(false, "<b>Defense IV:</b>", LockMode::READ_ONLY, "-", "") | ||
| , spatk(false, "<b>Special Attack IV:</b>", LockMode::READ_ONLY, "-", "") | ||
| , spdef(false, "<b>Special Defense IV:</b>", LockMode::READ_ONLY, "-", "") | ||
| , speed(false, "<b>Speed IV:</b>", LockMode::READ_ONLY, "-", "") | ||
| , gender(false, "<b>Gender:</b>", LockMode::READ_ONLY, "-", "") | ||
| , nature(false, "<b>Nature:</b>", LockMode::READ_ONLY, "-", "") | ||
| { | ||
| PA_ADD_STATIC(hp); | ||
| PA_ADD_STATIC(atk); | ||
| PA_ADD_STATIC(def); | ||
| PA_ADD_STATIC(spatk); | ||
| PA_ADD_STATIC(spdef); | ||
| PA_ADD_STATIC(speed); | ||
| PA_ADD_STATIC(gender); | ||
| PA_ADD_STATIC(nature); | ||
|
|
||
| } | ||
| std::string RngFilterDisplay::get_range_string(const IvRange& range){ | ||
| if (range.low < 0 || range.high < 0){ | ||
| return "(invalid or unable to read)"; | ||
| } | ||
| if (range.low == range.high){ | ||
| return std::to_string(range.low); | ||
| } | ||
| return std::to_string(range.low) + " - " + std::to_string(range.high); | ||
| } | ||
| std::string RngFilterDisplay::get_gender_string(const AdvGender& gender){ | ||
| switch (gender){ | ||
| case AdvGender::Male: | ||
| return "Male"; | ||
| case AdvGender::Female: | ||
| return "Female"; | ||
| default: | ||
| return "Any"; | ||
| } | ||
| } | ||
| std::string RngFilterDisplay::get_nature_string(const AdvNature& nature){ | ||
| switch (nature){ | ||
| case AdvNature::Hardy: | ||
| return "Hardy"; | ||
| case AdvNature::Lonely: | ||
| return "Lonely"; | ||
| case AdvNature::Brave: | ||
| return "Brave"; | ||
| case AdvNature::Adamant: | ||
| return "Adamant"; | ||
| case AdvNature::Naughty: | ||
| return "Naughty"; | ||
| case AdvNature::Bold: | ||
| return "Bold"; | ||
| case AdvNature::Docile: | ||
| return "Docile"; | ||
| case AdvNature::Relaxed: | ||
| return "Relaxed"; | ||
| case AdvNature::Impish: | ||
| return "Impish"; | ||
| case AdvNature::Lax: | ||
| return "Lax"; | ||
| case AdvNature::Timid: | ||
| return "Timid"; | ||
| case AdvNature::Hasty: | ||
| return "Hasty"; | ||
| case AdvNature::Serious: | ||
| return "Serious"; | ||
| case AdvNature::Jolly: | ||
| return "Jolly"; | ||
| case AdvNature::Naive: | ||
| return "Naive"; | ||
| case AdvNature::Modest: | ||
| return "Modest"; | ||
| case AdvNature::Mild: | ||
| return "Mild"; | ||
| case AdvNature::Quiet: | ||
| return "Quiet"; | ||
| case AdvNature::Bashful: | ||
| return "Bashful"; | ||
| case AdvNature::Rash: | ||
| return "Rash"; | ||
| case AdvNature::Calm: | ||
| return "Calm"; | ||
| case AdvNature::Gentle: | ||
| return "Gentle"; | ||
| case AdvNature::Sassy: | ||
| return "Sassy"; | ||
| case AdvNature::Careful: | ||
| return "Careful"; | ||
| case AdvNature::Quirky: | ||
| return "Quirky"; | ||
| default: | ||
| return "Any"; | ||
| } | ||
| } | ||
| void RngFilterDisplay::set(const AdvRngFilters& filter){ | ||
| hp.set(get_range_string(filter.ivs.hp)); | ||
| atk.set(get_range_string(filter.ivs.attack)); | ||
| def.set(get_range_string(filter.ivs.defense)); | ||
| spatk.set(get_range_string(filter.ivs.spatk)); | ||
| spdef.set(get_range_string(filter.ivs.spdef)); | ||
| speed.set(get_range_string(filter.ivs.speed)); | ||
| gender.set(get_gender_string(filter.gender)); | ||
| nature.set(get_nature_string(filter.nature)); | ||
| } | ||
|
|
||
| void RngFilterDisplay::reset(){ | ||
| hp.set("-"); | ||
| atk.set("-"); | ||
| def.set("-"); | ||
| spatk.set("-"); | ||
| spdef.set("-"); | ||
| speed.set("-"); | ||
| gender.set("-"); | ||
| nature.set("-"); | ||
| } | ||
|
|
||
| PossibleHitsDisplay::PossibleHitsDisplay() | ||
| : GroupOption("Possible Hits", LockMode::READ_ONLY) | ||
| , hits(false, "<b>Seeds/Advances:</b>", LockMode::READ_ONLY, "-", "") | ||
| { | ||
| PA_ADD_STATIC(hits); | ||
| } | ||
|
|
||
| std::vector<AdvRngState> PossibleHitsDisplay::get_rng_states_from_map(const std::map<AdvRngState,AdvPokemonResult>& hits_map){ | ||
| std::vector<AdvRngState> rng_states; | ||
| for(std::map<AdvRngState,AdvPokemonResult>::const_iterator it = hits_map.begin(); it != hits_map.end(); ++it) { | ||
| rng_states.emplace_back(it->first); | ||
| } | ||
| return rng_states; | ||
| } | ||
|
|
||
| std::string PossibleHitsDisplay::get_hits_string(const std::vector<AdvRngState>& rng_states){ | ||
| std::string hits_string; | ||
| for (size_t i=0; i<rng_states.size(); i++){ | ||
| if (i > 0){ | ||
| hits_string += ", "; | ||
| } | ||
| AdvRngState hit = rng_states[i]; | ||
| uint16_t seed = hit.seed; | ||
| std::ostringstream s; | ||
| s << std::hex << seed; | ||
| hits_string += s.str(); | ||
| hits_string += "/"; | ||
| hits_string += std::to_string(hit.advance); | ||
| } | ||
| if (hits_string.size() == 0){ | ||
| hits_string += "No matches found"; | ||
| } | ||
| return hits_string; | ||
| } | ||
| std::string PossibleHitsDisplay::get_hits_string(const std::map<AdvRngState, AdvPokemonResult>& hits_map){ | ||
| return get_hits_string(get_rng_states_from_map(hits_map)); | ||
| } | ||
|
|
||
| void PossibleHitsDisplay::set(const std::vector<AdvRngState>& rng_states){ | ||
| hits.set(get_hits_string(rng_states)); | ||
| } | ||
| void PossibleHitsDisplay::set(const std::map<AdvRngState, AdvPokemonResult>& hits_map){ | ||
| std::vector<AdvRngState> rng_states = get_rng_states_from_map(hits_map); | ||
| set(rng_states); | ||
| } | ||
|
|
||
| void PossibleHitsDisplay::reset(){ | ||
| hits.set("-"); | ||
| } | ||
|
|
||
| } | ||
| } | ||
| } | ||
66 changes: 66 additions & 0 deletions
66
SerialPrograms/Source/PokemonFRLG/Programs/RngManipulation/PokemonFRLG_RngDisplays.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,66 @@ | ||
| /* RNG Displays | ||
| * | ||
| * From: https://github.com/PokemonAutomation/ | ||
| * | ||
| */ | ||
|
|
||
| #ifndef PokemonAutomation_PokemonFRLG_RngDisplays_H | ||
| #define PokemonAutomation_PokemonFRLG_RngDisplays_H | ||
|
|
||
| #include <vector> | ||
| #include "Common/Cpp/Options/StringOption.h" | ||
| #include "CommonFramework/Notifications/EventNotificationsTable.h" | ||
| #include "NintendoSwitch/NintendoSwitch_SingleSwitchProgram.h" | ||
| #include "Pokemon/Pokemon_AdvRng.h" | ||
|
|
||
|
|
||
| namespace PokemonAutomation{ | ||
| namespace NintendoSwitch{ | ||
| namespace PokemonFRLG{ | ||
|
|
||
| using namespace Pokemon; | ||
|
|
||
| class RngFilterDisplay : public GroupOption{ | ||
| public: | ||
| RngFilterDisplay(); | ||
|
|
||
| void set(const AdvRngFilters& filter); | ||
| void reset(); | ||
|
|
||
| private: | ||
| static std::string get_range_string(const IvRange& range); | ||
| static std::string get_gender_string(const AdvGender& gender); | ||
| static std::string get_nature_string(const AdvNature& nature); | ||
|
|
||
| public: | ||
| StringOption hp; | ||
| StringOption atk; | ||
| StringOption def; | ||
| StringOption spatk; | ||
| StringOption spdef; | ||
| StringOption speed; | ||
| StringOption gender; | ||
| StringOption nature; | ||
| }; | ||
|
|
||
|
|
||
| class PossibleHitsDisplay : public GroupOption{ | ||
| public: | ||
| PossibleHitsDisplay(); | ||
|
|
||
| void set(const std::vector<AdvRngState>& rng_states); | ||
| void set(const std::map<AdvRngState, AdvPokemonResult>& hits_map); | ||
| void reset(); | ||
|
|
||
| private: | ||
| static std::vector<AdvRngState> get_rng_states_from_map(const std::map<AdvRngState, AdvPokemonResult>& hits_map); | ||
| static std::string get_hits_string(const std::vector<AdvRngState>& rng_states); | ||
| static std::string get_hits_string(const std::map<AdvRngState, AdvPokemonResult>& hits_map); | ||
| public: | ||
| StringOption hits; | ||
| }; | ||
|
|
||
| } | ||
| } | ||
| } | ||
| #endif |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you have
-as the empty state. Butget_hits_string()returns empty string on empty state. Which one should it be?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a more descriptive message in the case where there are no search hits.
-will correspond with the empty state before a search has been done, whileNo matches foundwill be displayed if a search turns up empty.