From 5ca65a89c2739a18bdf6be759848caedb0180e15 Mon Sep 17 00:00:00 2001 From: thewhitewolfking <337211553+thewhitewolfking@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:13:11 -0800 Subject: [PATCH] PokemonFRLG: battle move choice --- .../PokemonFRLG_BattleMoveReader.cpp | 158 ++++++++ .../Inference/PokemonFRLG_BattleMoveReader.h | 79 ++++ .../Programs/PokemonFRLG_BattleMoveChoice.cpp | 345 +++++++++++++++++ .../Programs/PokemonFRLG_BattleMoveChoice.h | 118 ++++++ .../Resources/PokemonFRLG_BattleData.cpp | 360 ++++++++++++++++++ .../Resources/PokemonFRLG_BattleData.h | 107 ++++++ SerialPrograms/cmake/SourceFiles.cmake | 6 + 7 files changed, 1173 insertions(+) create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.h create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.cpp create mode 100644 SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.h diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.cpp new file mode 100644 index 0000000000..1421a37701 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.cpp @@ -0,0 +1,158 @@ +/* Battle Move Reader + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include "Common/Cpp/Logging/AbstractLogger.h" +#include "CommonFramework/GlobalSettingsPanel.h" +#include "CommonFramework/ImageTypes/ImageRGB32.h" +#include "CommonFramework/ImageTypes/ImageViewRGB32.h" +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "CommonTools/Images/ImageFilter.h" +#include "CommonTools/OCR/OCR_Routines.h" +#include "Pokemon/Inference/Pokemon_NameReader.h" +#include "VideoGames/PokemonFRLG/PokemonFRLG_Settings.h" +#include "PokemonFRLG_OcrPreprocessing.h" +#include "PokemonFRLG_BattleMoveReader.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +const BattleMoveOCR& BattleMoveOCR::instance(){ + static BattleMoveOCR reader; + return reader; +} +BattleMoveOCR::BattleMoveOCR() + : SmallDictionaryMatcher("PokemonFRLG/BattleMovesOCR.json") +{} + + +BattleMoveReader::BattleMoveReader(Language language, Color color) + : m_language(language) + , m_color(color) + // Each box starts right of where the selection arrow is drawn. + , m_move_boxes{{ + {0.062, 0.765, 0.280, 0.075}, // top-left + {0.364, 0.765, 0.280, 0.075}, // top-right + {0.062, 0.862, 0.280, 0.075}, // bottom-left + {0.364, 0.862, 0.280, 0.075}, // bottom-right + }} + // The name in the player's HP box. Ends before "Lv". + , m_own_name_box(0.585, 0.482, 0.245, 0.065) + // "Lv" and the level in the player's HP box, up to the box's border. + // The level is right aligned: "Lv100" starts 5 GBA pixels left of "Lv99". + , m_own_level_box(0.818, 0.480, 0.112, 0.066) +{} + +void BattleMoveReader::make_overlays(VideoOverlaySet& items) const{ + const BoxOption& GAME_BOX = GameSettings::instance().GAME_BOX; + for (const ImageFloatBox& box : m_move_boxes){ + items.add(m_color, GAME_BOX.inner_to_outer(box)); + } + items.add(m_color, GAME_BOX.inner_to_outer(m_own_name_box)); + items.add(m_color, GAME_BOX.inner_to_outer(m_own_level_box)); +} + +std::array BattleMoveReader::read_moves(Logger& logger, const ImageViewRGB32& frame) const{ + ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); + + std::array ret; + for (size_t i = 0; i < 4; i++){ + ImageViewRGB32 box = extract_box_reference(game_screen, m_move_boxes[i]); + ImageRGB32 ready = preprocess_for_ocr(box); + OCR::StringMatchResult result = BattleMoveOCR::instance().match_substring_from_image_multifiltered( + &logger, m_language, ready, + DARK_TEXT_FILTERS(), + BattleMoveOCR::MAX_LOG10P, BattleMoveOCR::MAX_LOG10P_SPREAD + ); + if (!result.results.empty()){ + ret[i] = result.results.begin()->second.token; + continue; + } + logger.log("Move slot " + std::to_string(i + 1) + ": empty or unreadable."); + if (GlobalSettings::instance().SAVE_DEBUG_IMAGES){ + box.save("DebugDumps/ocr_move_box_" + std::to_string(i + 1) + ".png"); + } + } + return ret; +} + +std::string BattleMoveReader::read_own_species(Logger& logger, const ImageViewRGB32& frame) const{ + ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); + ImageViewRGB32 box = extract_box_reference(game_screen, m_own_name_box); + ImageRGB32 ready = preprocess_for_ocr(box); + OCR::StringMatchResult result = Pokemon::PokemonNameReader::instance().read_substring( + logger, m_language, ready, DARK_TEXT_FILTERS() + ); + if (result.results.empty()){ + logger.log("Could not read the species of the battling Pokemon.", COLOR_ORANGE); + if (GlobalSettings::instance().SAVE_DEBUG_IMAGES){ + box.save("DebugDumps/ocr_own_name_box.png"); + } + return ""; + } + return result.results.begin()->second.token; +} + +namespace{ + +// Dark text on the white HP box becomes black on white, then raw OCR. +std::string ocr_dark_text(Language language, const ImageViewRGB32& box){ + ImageRGB32 bw = to_blackwhite_rgb32_range(box, true, combine_rgb(0, 0, 0), combine_rgb(130, 130, 130)); + std::string text = OCR::ocr_read(language, bw); + while (!text.empty() && (text.back() == '\n' || text.back() == ' ')){ + text.pop_back(); + } + return text; +} + +} + +std::string BattleMoveReader::read_own_name_text(Logger& logger, const ImageViewRGB32& frame) const{ + ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); + std::string text = ocr_dark_text(m_language, extract_box_reference(game_screen, m_own_name_box)); + logger.log("Battling Pokemon's name: \"" + text + "\""); + return text; +} + +int BattleMoveReader::read_own_level(Logger& logger, const ImageViewRGB32& frame) const{ + ImageViewRGB32 game_screen = extract_box_reference(frame, GameSettings::instance().GAME_BOX); + ImageViewRGB32 box = extract_box_reference(game_screen, m_own_level_box); + + // "Lv" and digits, the same in every language: read as English. + std::string raw = ocr_dark_text(Language::English, box); + + // Only what comes after the "v" of "Lv", if it was read. An "o" there + // is a misread 0. + size_t v = raw.find_last_of("vV"); + std::string after = v == std::string::npos ? raw : raw.substr(v + 1); + std::string digits; + for (char ch : after){ + if (ch == 'o' || ch == 'O'){ + ch = '0'; + } + if (isdigit((unsigned char)ch)){ + digits += ch; + } + } + int level = digits.empty() || digits.size() > 3 ? -1 : std::stoi(digits); + if (level < 1 || level > 100){ + logger.log("Could not read the battling Pokemon's level: \"" + raw + "\"", COLOR_ORANGE); + if (GlobalSettings::instance().SAVE_DEBUG_IMAGES){ + box.save("DebugDumps/ocr_own_level_box.png"); + } + return -1; + } + logger.log("Battling Pokemon's level: " + std::to_string(level)); + return level; +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.h new file mode 100644 index 0000000000..82f5ef98a7 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.h @@ -0,0 +1,79 @@ +/* Battle Move Reader + * + * From: https://github.com/PokemonAutomation/ + * + * In a single battle: reads the four move names from the FIGHT move list, + * and the name and level of the player's Pokemon from its HP box. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BattleMoveReader_H +#define PokemonAutomation_PokemonFRLG_BattleMoveReader_H + +#include +#include +#include "Common/Cpp/Color.h" +#include "CommonFramework/ImageTools/ImageBoxes.h" +#include "CommonFramework/Language.h" +#include "CommonTools/OCR/OCR_SmallDictionaryMatcher.h" + +namespace PokemonAutomation{ + class Logger; + class ImageViewRGB32; + class VideoOverlaySet; +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// The Gen 3 move names in each language, from +// PokemonFRLG/BattleMovesOCR.json. Tokens are the move slugs of +// PokemonFRLG/BattleMoves.json. +class BattleMoveOCR : public OCR::SmallDictionaryMatcher{ +public: + static constexpr double MAX_LOG10P = -1.40; + static constexpr double MAX_LOG10P_SPREAD = 0.50; + + static const BattleMoveOCR& instance(); + +private: + BattleMoveOCR(); +}; + + +class BattleMoveReader{ +public: + BattleMoveReader(Language language, Color color = COLOR_RED); + + void make_overlays(VideoOverlaySet& items) const; + + // From the FIGHT move list: the move slugs, top-left, top-right, + // bottom-left, bottom-right. An empty slot ("-") or a name that can't be + // read is an empty string. + std::array read_moves(Logger& logger, const ImageViewRGB32& frame) const; + + // From the battle menu or move list: the species of the player's + // Pokemon, read from the name in its HP box. Empty if it can't be read, + // e.g. if the Pokemon has a nickname. + std::string read_own_species(Logger& logger, const ImageViewRGB32& frame) const; + + // The name in the player's HP box (e.g. a nickname) as raw text. Empty + // if nothing could be read. + std::string read_own_name_text(Logger& logger, const ImageViewRGB32& frame) const; + + // The level in the player's HP box. -1 if it can't be read. + int read_own_level(Logger& logger, const ImageViewRGB32& frame) const; + +private: + Language m_language; + Color m_color; + std::array m_move_boxes; + ImageFloatBox m_own_name_box; + ImageFloatBox m_own_level_box; +}; + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.cpp new file mode 100644 index 0000000000..4792fa748c --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.cpp @@ -0,0 +1,345 @@ +/* Battle Move Choice + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include +#include "CommonFramework/VideoPipeline/VideoFeed.h" +#include "CommonFramework/VideoPipeline/VideoOverlayScopes.h" +#include "CommonTools/Async/InferenceRoutines.h" +#include "NintendoSwitch/Commands/NintendoSwitch_Commands_PushButtons.h" +#include "NintendoSwitch/NintendoSwitch_ConsoleHandle.h" +#include "VideoGames/PokemonFRLG/Inference/Dialogs/PokemonFRLG_BattleDialogs.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleSelectionArrowDetector.h" +#include "VideoGames/PokemonFRLG/Inference/PokemonFRLG_WildEncounterReader.h" +#include "PokemonFRLG_BattleMenuNavigation.h" +#include "PokemonFRLG_BattleMoveChoice.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using Pokemon::PokemonType; + + +double score_move( + const BattleMove& move, + const BattleSpecies* attacker, + const BattleSpecies* defender +){ + if (move.kind == MoveKind::AVOID || move.power == 0 || move.type == PokemonType::NONE){ + return 0; + } + + double score = move.power; + + switch (move.kind){ + case MoveKind::MULTI_HIT: + score *= 3.0; + break; + case MoveKind::DOUBLE_HIT: + score *= 2.0; + break; + case MoveKind::TRIPLE_KICK: + score *= 4.0; // 10 + 20 + 30 if every kick hits; less if one misses. + break; + case MoveKind::RECHARGE: + score *= 0.6; + break; + case MoveKind::TWO_TURN: + score *= 0.5; + break; + default: + break; + } + + if (move.accuracy != 0){ + score *= move.accuracy / 100.0; + } + + // Hidden Power's type depends on the Pokemon's IVs: no STAB or type + // matchups for it. + if (attacker != nullptr && !move.type_varies){ + if (move.type == attacker->type1 || move.type == attacker->type2){ + score *= 1.5; + } + } + + // Physical or special, by type. Base stats stand in for the real stats. + const bool special = is_special_type(move.type); + if (attacker != nullptr){ + score *= special ? attacker->base_sp_attack : attacker->base_attack; + } + if (defender != nullptr){ + score /= std::max(1, special ? defender->base_sp_defense : defender->base_defense); + } + + if (defender != nullptr && !move.type_varies){ + double multiplier = type_effectiveness(move.type, defender->type1); + if (defender->type2 != defender->type1){ + multiplier *= type_effectiveness(move.type, defender->type2); + } + + uint8_t immunity = 0; + switch (move.type){ + case PokemonType::GROUND: + immunity = IMMUNE_GROUND; + break; + case PokemonType::FIRE: + immunity = IMMUNE_FIRE; + break; + case PokemonType::WATER: + immunity = IMMUNE_WATER; + break; + case PokemonType::ELECTRIC: + immunity = IMMUNE_ELECTRIC; + break; + default: + break; + } + if (defender->immunities & immunity){ + multiplier = 0; + } + if ((defender->immunities & IMMUNE_WONDER_GUARD) && multiplier <= 1.0){ + multiplier = 0; + } + score *= multiplier; + } + + return score; +} + +std::array rank_moves( + const MoveSlots& moves, + const BattleSpecies* attacker, + const BattleSpecies* defender, + size_t& usable +){ + const BattleDatabase& database = BattleDatabase::instance(); + std::array, 4> scored; + for (int i = 0; i < 4; i++){ + const BattleMove* move = moves[(size_t)i].empty() ? nullptr : database.move(moves[(size_t)i]); + scored[(size_t)i] = {move == nullptr ? 0.0 : score_move(*move, attacker, defender), i}; + } + std::stable_sort( + scored.begin(), scored.end(), + [](const std::pair& a, const std::pair& b){ + return a.first > b.first; + } + ); + + std::array ret{-1, -1, -1, -1}; + usable = 0; + for (const auto& item : scored){ + if (item.first > 0){ + ret[usable++] = item.second; + } + } + return ret; +} + + +void MoveChoiceState::new_battle(){ + grudge_active = false; + grudge_stalls = 0; + unusable_slot = -1; + unusable_turns = 0; +} + +void MoveChoiceState::forget_own_pokemon(){ + moves_read = false; + species_read = false; +} + + +namespace{ + +// Add every non-empty slot that isn't listed yet (and isn't `skip`) to the +// end of `candidates`. +void add_other_moves(std::vector& candidates, const MoveSlots& moves, int skip){ + for (int slot = 0; slot < 4; slot++){ + bool listed = slot == skip || + std::find(candidates.begin(), candidates.end(), slot) != candidates.end(); + if (!listed && !moves[(size_t)slot].empty()){ + candidates.push_back(slot); + } + } +} + +} + + +bool use_best_move( + ConsoleHandle& console, ProControllerContext& context, + MoveChoiceState& state +){ + BattleMoveReader move_reader(state.language); + VideoOverlaySet overlays(console.overlay()); + move_reader.make_overlays(overlays); + const BattleDatabase& database = BattleDatabase::instance(); + + // Our species, in single battles. (Unknown in double battles, where the + // HP boxes are laid out differently: STAB is then ignored.) + if (!state.double_battle && !state.species_read){ + VideoSnapshot screen = console.video().snapshot(); + state.own_species = move_reader.read_own_species(console.logger(), screen); + state.species_read = true; + if (database.species(state.own_species) == nullptr){ + console.log("Battling Pokemon not recognized (nickname?). Ignoring its types and stats when choosing moves.", COLOR_ORANGE); + }else{ + console.log("Battling Pokemon: " + state.own_species); + } + } + const BattleSpecies* attacker = state.double_battle ? nullptr : database.species(state.own_species); + + // Who are we fighting? + std::string opponent; + { + WildEncounterReader reader(COLOR_RED); + reader.make_overlays(overlays); + VideoSnapshot screen = console.video().snapshot(); + opponent = reader.read_encounter(console.logger(), state.language, screen, state.opponent_species).name; + } + console.log("Opponent: " + (opponent.empty() ? std::string("(unread)") : opponent)); + + // Open the move list. + if (!move_cursor_to_option(console, context, BattleMenuOption::FIGHT)){ + console.log("Could not confirm the cursor is on FIGHT. Pressing A anyway.", COLOR_RED); + } + pbf_press_button(context, BUTTON_A, 200ms, 500ms); + context.wait_for_all_requests(); + + if (state.double_battle || !state.moves_read){ + VideoSnapshot screen = console.video().snapshot(); + state.moves = move_reader.read_moves(console.logger(), screen); + state.moves_read = !state.double_battle; + std::string log = "Moves:"; + for (const std::string& move : state.moves){ + log += " [" + (move.empty() ? std::string("-") : move) + "]"; + } + console.log(log); + } + const MoveSlots& moves = state.moves; + + size_t usable = 0; + std::array ranked = rank_moves(moves, attacker, database.species(opponent), usable); + + // An unusable move is skipped for a few turns, then tried again. + if (state.unusable_turns > 0 && --state.unusable_turns == 0){ + state.unusable_slot = -1; + } + + // The damaging moves, best first, without an unusable one. If a damaging + // move is unusable, any other move (even one that does nothing to this + // opponent) keeps the battle going until it can be used again. + std::vector candidates; + bool damaging_unusable = false; + for (size_t i = 0; i < usable; i++){ + if (ranked[i] == state.unusable_slot){ + damaging_unusable = true; + }else{ + candidates.push_back(ranked[i]); + } + } + if (damaging_unusable){ + add_other_moves(candidates, moves, state.unusable_slot); + } + + // Grudge: if the opponent faints from the move used now, that move loses + // all its PP. Use the next best attacking move instead. With only one, + // use something else for a turn (Grudge ends when the opponent moves + // again). The Grudge message can scroll by unseen, so against opponents + // known to use it, the best move is always kept back if there is another. + bool grudge_seen = state.grudge_active; + state.grudge_active = false; + if (grudge_seen || state.grudge_opponents.count(opponent) != 0){ + if (candidates.size() >= 2 && !damaging_unusable){ + console.log("Grudge: using " + moves[(size_t)candidates[1]] + " instead of " + moves[(size_t)candidates[0]] + "."); + std::swap(candidates[0], candidates[1]); + }else if (grudge_seen && candidates.size() == 1 && state.grudge_stalls < 2){ + std::vector others; + add_other_moves(others, moves, candidates[0]); + others.erase( + std::remove(others.begin(), others.end(), state.unusable_slot), + others.end() + ); + if (!others.empty()){ + state.grudge_stalls++; + console.log("Grudge, and only one attacking move: using another move this turn."); + others.push_back(candidates[0]); + candidates = others; + } + } + } + + // (By index: a move found unusable below adds candidates.) + for (size_t c = 0; c < candidates.size(); c++){ + int slot = candidates[c]; + const std::string& name = moves[(size_t)slot]; + if (!move_cursor_to_option(console, context, static_cast(slot))){ + console.log("Could not find the move cursor. Backing out to the battle menu.", COLOR_RED); + pbf_press_button(context, BUTTON_B, 200ms, 800ms); + return true; + } + BattleOutOfPpWatcher out_of_pp(COLOR_RED); + if (wait_until(console, context, 500ms, { out_of_pp }) == 0){ + console.log(name + " is out of PP.", COLOR_ORANGE); + continue; + } + console.log("Using " + name + " (slot " + std::to_string(slot + 1) + ")."); + pbf_press_button(context, BUTTON_A, 200ms, 0ms); + context.wait_for_all_requests(); + + // A move that can't be used right now (Disable, Taunt, Torment, ...) + // shows a message that waits for a button, then goes back to the + // move list. A move that is used starts the turn, whose first + // messages don't wait. + AdvanceBattleDialogWatcher cant_use(COLOR_RED); + if (wait_until(console, context, 1200ms, { cant_use }) == 0){ + console.log(name + " can't be used right now. Using another move for a few turns.", COLOR_ORANGE); + state.unusable_slot = slot; + state.unusable_turns = 3; + pbf_press_button(context, BUTTON_B, 200ms, 1000ms); + context.wait_for_all_requests(); + if (!damaging_unusable){ + damaging_unusable = true; + add_other_moves(candidates, moves, slot); + } + continue; + } + + // In a double battle, a move aimed at one Pokemon then asks for its + // target: the move list stays up and the target blinks. A confirms + // the one picked. (Moves that hit both foes go on right away.) + if (state.double_battle){ + BattleSelectionArrowWatcher choosing_target(COLOR_RED, &console.overlay(), BATTLE_MOVE_ARROW_BOX); + if (wait_until(console, context, 500ms, { choosing_target }) == 0){ + console.log("Confirming the target."); + pbf_press_button(context, BUTTON_A, 200ms, 1000ms); + context.wait_for_all_requests(); + } + } + + // A move that can't be chosen without a message stays on the list. + BattleSelectionArrowWatcher still_on_list(COLOR_RED, &console.overlay(), BATTLE_MOVE_ARROW_BOX); + if (wait_until(console, context, 1500ms, { still_on_list }) == 0){ + console.log(name + " can't be used right now. Trying the next move.", COLOR_ORANGE); + pbf_press_button(context, BUTTON_B, 200ms, 600ms); + context.wait_for_all_requests(); + continue; + } + return true; + } + pbf_press_button(context, BUTTON_B, 200ms, 600ms); + return false; +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.h new file mode 100644 index 0000000000..c9dba8f908 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.h @@ -0,0 +1,118 @@ +/* Battle Move Choice + * + * From: https://github.com/PokemonAutomation/ + * + * Pick the strongest move against the opponent and use it: by the moves' + * power, accuracy and type against the opponent's types, abilities and + * base stats. For programs that win trainer battles automatically. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BattleMoveChoice_H +#define PokemonAutomation_PokemonFRLG_BattleMoveChoice_H + +#include +#include +#include +#include "CommonFramework/Language.h" +#include "VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.h" + +namespace PokemonAutomation{ + +template class ControllerContext; + +namespace NintendoSwitch{ + +class ConsoleHandle; +class ProController; +using ProControllerContext = ControllerContext; + +namespace PokemonFRLG{ + + +// The four moves of a Pokemon as move slugs, top-left, top-right, +// bottom-left, bottom-right. Empty for an empty or unreadable slot. +using MoveSlots = std::array; + + +// Relative damage of a move against the opponent, for comparing the moves +// of one Pokemon against one opponent. 0 means "don't use". +// - attacker: our species, or nullptr if unknown (then STAB and the +// Attack / Sp. Atk balance are ignored). +// - defender: the opponent, or nullptr if unknown (then type matchups, +// immunities and its defenses are ignored). +double score_move( + const BattleMove& move, + const BattleSpecies* attacker, + const BattleSpecies* defender +); + +// The move slots (0 to 3) worth using against the defender, best first: +// the first `usable` entries. The rest are -1. (Unknown moves and moves +// that do no damage or have no effect are left out.) +std::array rank_moves( + const MoveSlots& moves, + const BattleSpecies* attacker, + const BattleSpecies* defender, + size_t& usable +); + + +// What use_best_move() keeps between turns. Call new_battle() at the start +// of each battle. +struct MoveChoiceState{ + Language language = Language::English; + + // Two Pokemon on each side. The menu then comes up for each of ours in + // turn, and their moves are read every time (the HP box readers only + // work in single battles). + bool double_battle = false; + + // Who the opponents can be (species slugs), to read them. + std::set opponent_species; + + // Opponents that know Grudge: against them, the best move is kept back + // if there is another attacking move. (If an opponent faints from a + // move right after using Grudge, that move loses all its PP.) + std::set grudge_opponents; + + // Set by the caller when it sees an opponent use Grudge: the next move + // is a different attacking move, or, with only one, another move (at + // most twice per battle). + bool grudge_active = false; + + // Single battles: our battling Pokemon's moves and species, read once + // and kept until forget_own_pokemon(). + bool moves_read = false; + MoveSlots moves; + bool species_read = false; + std::string own_species; + + // A move that couldn't be used (e.g. Disable lasts 2 to 5 turns). It is + // skipped for a few turns, then tried again. + int unusable_slot = -1; + int unusable_turns = 0; + int grudge_stalls = 0; + + void new_battle(); + + // Read the battling Pokemon's moves and species again next turn: after + // a switch, a new move or an evolution. + void forget_own_pokemon(); +}; + + +// At the battle menu: open FIGHT, pick the best move against the opponent +// and use it. Returns false (back at the battle menu) if none of the +// damaging moves can be used, e.g. none has PP left. +bool use_best_move( + ConsoleHandle& console, ProControllerContext& context, + MoveChoiceState& state +); + + + +} +} +} +#endif diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.cpp b/SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.cpp new file mode 100644 index 0000000000..aa42d5a35e --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.cpp @@ -0,0 +1,360 @@ +/* Battle Data + * + * From: https://github.com/PokemonAutomation/ + * + */ + +#include +#include +#include "Common/Cpp/Exceptions.h" +#include "Common/Cpp/Json/JsonArray.h" +#include "Common/Cpp/Json/JsonObject.h" +#include "Common/Cpp/Json/JsonValue.h" +#include "CommonFramework/GlobalAutoPaths.h" +#include "PokemonFRLG_BattleData.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + +using Pokemon::PokemonType; + + +bool is_special_type(PokemonType type){ + switch (type){ + case PokemonType::FIRE: + case PokemonType::WATER: + case PokemonType::GRASS: + case PokemonType::ELECTRIC: + case PokemonType::PSYCHIC: + case PokemonType::ICE: + case PokemonType::DRAGON: + case PokemonType::DARK: + return true; + default: + return false; + } +} + + +namespace{ + +struct TypeMatchup{ + PokemonType attack; + PokemonType defend; + double multiplier; +}; + +// gTypeEffectiveness in the decomp's src/battle_main.c. Pairs not listed +// are 1x. +const TypeMatchup TYPE_CHART[] = { + {PokemonType::NORMAL, PokemonType::ROCK, 0.5}, + {PokemonType::NORMAL, PokemonType::STEEL, 0.5}, + {PokemonType::NORMAL, PokemonType::GHOST, 0.0}, + {PokemonType::FIRE, PokemonType::FIRE, 0.5}, + {PokemonType::FIRE, PokemonType::WATER, 0.5}, + {PokemonType::FIRE, PokemonType::GRASS, 2.0}, + {PokemonType::FIRE, PokemonType::ICE, 2.0}, + {PokemonType::FIRE, PokemonType::BUG, 2.0}, + {PokemonType::FIRE, PokemonType::ROCK, 0.5}, + {PokemonType::FIRE, PokemonType::DRAGON, 0.5}, + {PokemonType::FIRE, PokemonType::STEEL, 2.0}, + {PokemonType::WATER, PokemonType::FIRE, 2.0}, + {PokemonType::WATER, PokemonType::WATER, 0.5}, + {PokemonType::WATER, PokemonType::GRASS, 0.5}, + {PokemonType::WATER, PokemonType::GROUND, 2.0}, + {PokemonType::WATER, PokemonType::ROCK, 2.0}, + {PokemonType::WATER, PokemonType::DRAGON, 0.5}, + {PokemonType::ELECTRIC, PokemonType::WATER, 2.0}, + {PokemonType::ELECTRIC, PokemonType::ELECTRIC, 0.5}, + {PokemonType::ELECTRIC, PokemonType::GRASS, 0.5}, + {PokemonType::ELECTRIC, PokemonType::GROUND, 0.0}, + {PokemonType::ELECTRIC, PokemonType::FLYING, 2.0}, + {PokemonType::ELECTRIC, PokemonType::DRAGON, 0.5}, + {PokemonType::GRASS, PokemonType::FIRE, 0.5}, + {PokemonType::GRASS, PokemonType::WATER, 2.0}, + {PokemonType::GRASS, PokemonType::GRASS, 0.5}, + {PokemonType::GRASS, PokemonType::POISON, 0.5}, + {PokemonType::GRASS, PokemonType::GROUND, 2.0}, + {PokemonType::GRASS, PokemonType::FLYING, 0.5}, + {PokemonType::GRASS, PokemonType::BUG, 0.5}, + {PokemonType::GRASS, PokemonType::ROCK, 2.0}, + {PokemonType::GRASS, PokemonType::DRAGON, 0.5}, + {PokemonType::GRASS, PokemonType::STEEL, 0.5}, + {PokemonType::ICE, PokemonType::WATER, 0.5}, + {PokemonType::ICE, PokemonType::GRASS, 2.0}, + {PokemonType::ICE, PokemonType::ICE, 0.5}, + {PokemonType::ICE, PokemonType::GROUND, 2.0}, + {PokemonType::ICE, PokemonType::FLYING, 2.0}, + {PokemonType::ICE, PokemonType::DRAGON, 2.0}, + {PokemonType::ICE, PokemonType::STEEL, 0.5}, + {PokemonType::ICE, PokemonType::FIRE, 0.5}, + {PokemonType::FIGHTING, PokemonType::NORMAL, 2.0}, + {PokemonType::FIGHTING, PokemonType::ICE, 2.0}, + {PokemonType::FIGHTING, PokemonType::POISON, 0.5}, + {PokemonType::FIGHTING, PokemonType::FLYING, 0.5}, + {PokemonType::FIGHTING, PokemonType::PSYCHIC, 0.5}, + {PokemonType::FIGHTING, PokemonType::BUG, 0.5}, + {PokemonType::FIGHTING, PokemonType::ROCK, 2.0}, + {PokemonType::FIGHTING, PokemonType::DARK, 2.0}, + {PokemonType::FIGHTING, PokemonType::STEEL, 2.0}, + {PokemonType::FIGHTING, PokemonType::GHOST, 0.0}, + {PokemonType::POISON, PokemonType::GRASS, 2.0}, + {PokemonType::POISON, PokemonType::POISON, 0.5}, + {PokemonType::POISON, PokemonType::GROUND, 0.5}, + {PokemonType::POISON, PokemonType::ROCK, 0.5}, + {PokemonType::POISON, PokemonType::GHOST, 0.5}, + {PokemonType::POISON, PokemonType::STEEL, 0.0}, + {PokemonType::GROUND, PokemonType::FIRE, 2.0}, + {PokemonType::GROUND, PokemonType::ELECTRIC, 2.0}, + {PokemonType::GROUND, PokemonType::GRASS, 0.5}, + {PokemonType::GROUND, PokemonType::POISON, 2.0}, + {PokemonType::GROUND, PokemonType::FLYING, 0.0}, + {PokemonType::GROUND, PokemonType::BUG, 0.5}, + {PokemonType::GROUND, PokemonType::ROCK, 2.0}, + {PokemonType::GROUND, PokemonType::STEEL, 2.0}, + {PokemonType::FLYING, PokemonType::ELECTRIC, 0.5}, + {PokemonType::FLYING, PokemonType::GRASS, 2.0}, + {PokemonType::FLYING, PokemonType::FIGHTING, 2.0}, + {PokemonType::FLYING, PokemonType::BUG, 2.0}, + {PokemonType::FLYING, PokemonType::ROCK, 0.5}, + {PokemonType::FLYING, PokemonType::STEEL, 0.5}, + {PokemonType::PSYCHIC, PokemonType::FIGHTING, 2.0}, + {PokemonType::PSYCHIC, PokemonType::POISON, 2.0}, + {PokemonType::PSYCHIC, PokemonType::PSYCHIC, 0.5}, + {PokemonType::PSYCHIC, PokemonType::DARK, 0.0}, + {PokemonType::PSYCHIC, PokemonType::STEEL, 0.5}, + {PokemonType::BUG, PokemonType::FIRE, 0.5}, + {PokemonType::BUG, PokemonType::GRASS, 2.0}, + {PokemonType::BUG, PokemonType::FIGHTING, 0.5}, + {PokemonType::BUG, PokemonType::POISON, 0.5}, + {PokemonType::BUG, PokemonType::FLYING, 0.5}, + {PokemonType::BUG, PokemonType::PSYCHIC, 2.0}, + {PokemonType::BUG, PokemonType::GHOST, 0.5}, + {PokemonType::BUG, PokemonType::DARK, 2.0}, + {PokemonType::BUG, PokemonType::STEEL, 0.5}, + {PokemonType::ROCK, PokemonType::FIRE, 2.0}, + {PokemonType::ROCK, PokemonType::ICE, 2.0}, + {PokemonType::ROCK, PokemonType::FIGHTING, 0.5}, + {PokemonType::ROCK, PokemonType::GROUND, 0.5}, + {PokemonType::ROCK, PokemonType::FLYING, 2.0}, + {PokemonType::ROCK, PokemonType::BUG, 2.0}, + {PokemonType::ROCK, PokemonType::STEEL, 0.5}, + {PokemonType::GHOST, PokemonType::NORMAL, 0.0}, + {PokemonType::GHOST, PokemonType::PSYCHIC, 2.0}, + {PokemonType::GHOST, PokemonType::DARK, 0.5}, + {PokemonType::GHOST, PokemonType::STEEL, 0.5}, + {PokemonType::GHOST, PokemonType::GHOST, 2.0}, + {PokemonType::DRAGON, PokemonType::DRAGON, 2.0}, + {PokemonType::DRAGON, PokemonType::STEEL, 0.5}, + {PokemonType::DARK, PokemonType::FIGHTING, 0.5}, + {PokemonType::DARK, PokemonType::PSYCHIC, 2.0}, + {PokemonType::DARK, PokemonType::GHOST, 2.0}, + {PokemonType::DARK, PokemonType::DARK, 0.5}, + {PokemonType::DARK, PokemonType::STEEL, 0.5}, + {PokemonType::STEEL, PokemonType::FIRE, 0.5}, + {PokemonType::STEEL, PokemonType::WATER, 0.5}, + {PokemonType::STEEL, PokemonType::ELECTRIC, 0.5}, + {PokemonType::STEEL, PokemonType::ICE, 2.0}, + {PokemonType::STEEL, PokemonType::ROCK, 2.0}, + {PokemonType::STEEL, PokemonType::STEEL, 0.5}, +}; + + +// How a move's effect (from the decomp, e.g. EFFECT_MULTI_HIT is +// "multi-hit") changes how its power counts. +MoveKind kind_of_effect(const std::string& effect){ + static const std::map KINDS{ + {"multi-hit", MoveKind::MULTI_HIT}, + {"double-hit", MoveKind::DOUBLE_HIT}, + {"twineedle", MoveKind::DOUBLE_HIT}, + {"triple-kick", MoveKind::TRIPLE_KICK}, + {"recharge", MoveKind::RECHARGE}, + {"razor-wind", MoveKind::TWO_TURN}, + {"skull-bash", MoveKind::TWO_TURN}, + {"sky-attack", MoveKind::TWO_TURN}, + {"solar-beam", MoveKind::TWO_TURN}, + {"semi-invulnerable", MoveKind::TWO_TURN}, + // Fixed or conditional damage, or not a reliable attack. + {"beat-up", MoveKind::AVOID}, + {"bide", MoveKind::AVOID}, + {"counter", MoveKind::AVOID}, + {"mirror-coat", MoveKind::AVOID}, + {"dragon-rage", MoveKind::AVOID}, + {"sonicboom", MoveKind::AVOID}, + {"level-damage", MoveKind::AVOID}, + {"psywave", MoveKind::AVOID}, + {"super-fang", MoveKind::AVOID}, + {"endeavor", MoveKind::AVOID}, + {"ohko", MoveKind::AVOID}, + {"explosion", MoveKind::AVOID}, + {"dream-eater", MoveKind::AVOID}, + {"fake-out", MoveKind::AVOID}, + {"false-swipe", MoveKind::AVOID}, + {"focus-punch", MoveKind::AVOID}, + {"future-sight", MoveKind::AVOID}, + {"present", MoveKind::AVOID}, + {"snore", MoveKind::AVOID}, + {"spit-up", MoveKind::AVOID}, + }; + auto iter = KINDS.find(effect); + return iter == KINDS.end() ? MoveKind::NORMAL : iter->second; +} + +// The decomp gives moves whose power varies a power of 1. A typical value +// for each, to compare them with other moves. +uint8_t typical_power(const std::string& effect, uint8_t power){ + static const std::map POWERS{ + {"low-kick", 60}, // By the target's weight. + {"flail", 40}, // Flail, Reversal: by the user's HP. + {"return", 70}, // By friendship. + {"frustration", 70}, + {"magnitude", 70}, // Random. + {"hidden-power", 50}, // By IVs. + }; + auto iter = POWERS.find(effect); + return iter == POWERS.end() ? power : iter->second; +} + +uint8_t immunity_of_ability(const std::string& ability){ + static const std::map IMMUNITIES{ + {"levitate", IMMUNE_GROUND}, + {"flash-fire", IMMUNE_FIRE}, + {"water-absorb", IMMUNE_WATER}, + {"volt-absorb", IMMUNE_ELECTRIC}, + {"wonder-guard", IMMUNE_WONDER_GUARD}, + }; + auto iter = IMMUNITIES.find(ability); + return iter == IMMUNITIES.end() ? 0 : iter->second; +} + +// BaseStats.json writes some slugs differently (e.g. "farfetch-d"), so +// species are matched without hyphens. +std::string without_hyphens(const std::string& slug){ + std::string ret; + for (char ch : slug){ + if (ch != '-'){ + ret += ch; + } + } + return ret; +} + +PokemonType read_type(const std::string& slug, const std::string& path){ + PokemonType type = Pokemon::POKEMON_TYPE_SLUGS().get_enum(slug, PokemonType::FAIRY); + if (type == PokemonType::FAIRY){ + throw FileException(nullptr, PA_CURRENT_FUNCTION, "Not a Gen 3 type: " + slug, path); + } + return type; +} + +uint8_t read_byte(const JsonObject& obj, const std::string& key, const std::string& path){ + int64_t value = obj.get_integer_throw(key, path); + if (value < 0 || value > 255){ + throw FileException(nullptr, PA_CURRENT_FUNCTION, "Value out of range: " + key, path); + } + return (uint8_t)value; +} + +} + + +double type_effectiveness(PokemonType attack, PokemonType defend){ + for (const TypeMatchup& item : TYPE_CHART){ + if (item.attack == attack && item.defend == defend){ + return item.multiplier; + } + } + return 1.0; +} + + +const BattleDatabase& BattleDatabase::instance(){ + static BattleDatabase database; + return database; +} + +BattleDatabase::BattleDatabase(){ + { + std::string path = RESOURCE_PATH() + "PokemonFRLG/BattleMoves.json"; + JsonValue json = load_json_file(path); + const JsonObject& root = json.to_object_throw(path); + for (const auto& item : root){ + const JsonObject& obj = item.second.to_object_throw(path); + const std::string& effect = obj.get_string_throw("effect", path); + BattleMove move; + move.slug = item.first; + move.type = read_type(obj.get_string_throw("type", path), path); + move.power = typical_power(effect, read_byte(obj, "power", path)); + move.accuracy = read_byte(obj, "accuracy", path); + move.pp = read_byte(obj, "pp", path); + move.kind = kind_of_effect(effect); + move.type_varies = effect == "hidden-power"; + m_moves.emplace(move.slug, std::move(move)); + } + } + + // Base stats: HP, Attack, Defense, Sp. Atk, Sp. Def, Speed. + std::map> base_stats; + { + std::string path = RESOURCE_PATH() + "PokemonFRLG/BaseStats.json"; + JsonValue json = load_json_file(path); + const JsonObject& root = json.to_object_throw(path); + for (const auto& item : root){ + const JsonArray& array = item.second.to_object_throw(path).get_array_throw("baseStats", path); + std::vector stats; + for (const JsonValue& stat : array){ + stats.emplace_back((uint8_t)stat.to_integer_throw(path)); + } + if (stats.size() != 6){ + throw FileException(nullptr, PA_CURRENT_FUNCTION, "Invalid length for base stats.", path); + } + base_stats.emplace(without_hyphens(item.first), std::move(stats)); + } + } + + { + std::string path = RESOURCE_PATH() + "PokemonFRLG/BattleSpecies.json"; + JsonValue json = load_json_file(path); + const JsonObject& root = json.to_object_throw(path); + for (const auto& item : root){ + const JsonObject& obj = item.second.to_object_throw(path); + auto stats = base_stats.find(without_hyphens(item.first)); + if (stats == base_stats.end()){ + throw FileException(nullptr, PA_CURRENT_FUNCTION, "No base stats for: " + item.first, path); + } + + BattleSpecies species; + species.slug = item.first; + const JsonArray& types = obj.get_array_throw("types", path); + if (types.size() != 2){ + throw FileException(nullptr, PA_CURRENT_FUNCTION, "Expected two types for: " + item.first, path); + } + species.type1 = read_type(types[0].to_string_throw(path), path); + species.type2 = read_type(types[1].to_string_throw(path), path); + species.base_attack = stats->second[1]; + species.base_defense = stats->second[2]; + species.base_sp_attack = stats->second[3]; + species.base_sp_defense = stats->second[4]; + for (const JsonValue& ability : obj.get_array_throw("abilities", path)){ + species.immunities |= immunity_of_ability(ability.to_string_throw(path)); + } + m_species.emplace(species.slug, std::move(species)); + } + } +} + +const BattleMove* BattleDatabase::move(const std::string& slug) const{ + auto iter = m_moves.find(slug); + return iter == m_moves.end() ? nullptr : &iter->second; +} +const BattleSpecies* BattleDatabase::species(const std::string& slug) const{ + auto iter = m_species.find(slug); + return iter == m_species.end() ? nullptr : &iter->second; +} + + + +} +} +} diff --git a/SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.h b/SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.h new file mode 100644 index 0000000000..1be0e20b28 --- /dev/null +++ b/SerialPrograms/Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.h @@ -0,0 +1,107 @@ +/* Battle Data + * + * From: https://github.com/PokemonAutomation/ + * + * Gen 3 move and species data for choosing moves in battle, loaded from + * the Packages repo: + * - PokemonFRLG/BattleMoves.json: type, power, accuracy, PP and effect + * of each move. + * - PokemonFRLG/BattleSpecies.json: types and abilities of each species. + * - PokemonFRLG/BaseStats.json: base stats of each species. + * (All from the pokefirered decomp.) Plus the Gen 3 type chart. + * + */ + +#ifndef PokemonAutomation_PokemonFRLG_BattleData_H +#define PokemonAutomation_PokemonFRLG_BattleData_H + +#include +#include +#include +#include "Pokemon/Pokemon_Types.h" + +namespace PokemonAutomation{ +namespace NintendoSwitch{ +namespace PokemonFRLG{ + + +// In Gen 3 a move's type decides whether it uses Attack or Sp. Atk. +bool is_special_type(Pokemon::PokemonType type); + +// The Gen 3 type chart: the damage multiplier of an attack of one type on a +// Pokemon of another (0, 0.5, 1 or 2). NONE is the "???" type of Curse. +double type_effectiveness(Pokemon::PokemonType attack, Pokemon::PokemonType defend); + + +// How a move's power should be counted when comparing moves. +enum class MoveKind : uint8_t{ + NORMAL, + MULTI_HIT, // 2 to 5 hits, about 3 on average. + DOUBLE_HIT, // Always 2 hits. + TRIPLE_KICK, // Up to 3 hits of rising power. + RECHARGE, // Hyper Beam: loses the next turn. + TWO_TURN, // Charges or goes semi-invulnerable for a turn first. + AVOID, // Not worth choosing: fixed or conditional damage, OHKO, + // self-KO, False Swipe (can't finish a Pokemon), etc. +}; + +struct BattleMove{ + std::string slug; + Pokemon::PokemonType type = Pokemon::PokemonType::NONE; + // 0 for status moves. For moves whose power varies (Return, Low Kick, + // Magnitude, ...), a typical value. + uint8_t power = 0; + uint8_t accuracy = 0; // 0 for moves that never miss. + uint8_t pp = 0; + MoveKind kind = MoveKind::NORMAL; + bool type_varies = false; // Hidden Power: the type depends on IVs. +}; + +// Abilities that make a species take no damage from some moves. +enum SpeciesImmunity : uint8_t{ + IMMUNE_GROUND = 1 << 0, // Levitate + IMMUNE_FIRE = 1 << 1, // Flash Fire + IMMUNE_WATER = 1 << 2, // Water Absorb + IMMUNE_ELECTRIC = 1 << 3, // Volt Absorb + IMMUNE_WONDER_GUARD = 1 << 4, // Only super effective moves hit. +}; + +struct BattleSpecies{ + std::string slug; + Pokemon::PokemonType type1 = Pokemon::PokemonType::NONE; + Pokemon::PokemonType type2 = Pokemon::PokemonType::NONE; // Same as type1 if single-typed. + uint8_t base_attack = 0; + uint8_t base_defense = 0; + uint8_t base_sp_attack = 0; + uint8_t base_sp_defense = 0; + // SpeciesImmunity flags. If any of the species' possible abilities gives + // an immunity, the species is treated as having it. + uint8_t immunities = 0; +}; + + +class BattleDatabase{ +public: + static const BattleDatabase& instance(); + + // By slug, e.g. "rock-slide" or "machamp". nullptr if unknown. + const BattleMove* move(const std::string& slug) const; + const BattleSpecies* species(const std::string& slug) const; + + const std::map& moves() const{ + return m_moves; + } + +private: + BattleDatabase(); + + std::map m_moves; + std::map m_species; +}; + + + +} +} +} +#endif diff --git a/SerialPrograms/cmake/SourceFiles.cmake b/SerialPrograms/cmake/SourceFiles.cmake index e3a854eb06..73a20e7092 100644 --- a/SerialPrograms/cmake/SourceFiles.cmake +++ b/SerialPrograms/cmake/SourceFiles.cmake @@ -1733,6 +1733,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Inference/Menus/PokemonFRLG_TrainerCardDetector.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleLevelUpReader.cpp Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleLevelUpReader.h + Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.cpp + Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleMoveReader.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.cpp Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattlePokemonDetector.h Source/VideoGames/PokemonFRLG/Inference/PokemonFRLG_BattleSelectionArrowDetector.cpp @@ -1793,6 +1795,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/Farming/PokemonFRLG_PickupFarmer.h Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMenuNavigation.cpp Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMenuNavigation.h + Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.cpp + Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_BattleMoveChoice.h Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_SafariOptimalAction.cpp Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_SafariOptimalAction.h Source/VideoGames/PokemonFRLG/Programs/PokemonFRLG_StartMenuNavigation.cpp @@ -1861,6 +1865,8 @@ file(GLOB LIBRARY_SOURCES Source/VideoGames/PokemonFRLG/Programs/TestPrograms/PokemonFRLG_SoundListener.h Source/VideoGames/PokemonFRLG/Programs/TestPrograms/PokemonFRLG_TestPartyInference.cpp Source/VideoGames/PokemonFRLG/Programs/TestPrograms/PokemonFRLG_TestPartyInference.h + Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.cpp + Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_BattleData.h Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_PokemonSprites.cpp Source/VideoGames/PokemonFRLG/Resources/PokemonFRLG_PokemonSprites.h Source/VideoGames/PokemonHome/Inference/PokemonHome_AlphaDetector.cpp