What it does

AI Trainers for Pokémon Emerald is a safe foundation for giving selected NPC trainers externally assisted battle decisions without replacing the game engine.

This Phase 1 prototype adds a dedicated externalAi trainer setting and enables it only for Youngster Calvin on Route 102. The game always computes its normal trainer-AI move and target first. A test-only mock can replace that choice only when it is a currently legal, direct opponent-targeting move; invalid, unavailable, self-targeting, unsupported, or absent responses keep the original vanilla decision.

Why this matters

External AI should not be able to break battle rules, stall a turn, force an illegal move, or change an unrelated trainer. The ROM remains authoritative for legality and has a deterministic fallback whenever no external response exists.

Demo and verification

  • Seven focused battle tests cover accepted legal selection plus absent, zero-PP, out-of-range, empty-slot, self-targeting, and non-opted-in fallbacks.
  • A normal ROM was built and tested in mGBA. Youngster Calvin's Route 102 battle proceeds normally with no external service, script, or UI required.
  • The implementation is documented with a specification, flow analysis, test plan, and verification evidence in the repository.

Built with Codex

I used Codex to inspect the existing battle-AI control flow, design the safe hook, write the phase specification and tests, resolve GCC 14 build issues, review the implementation, and prepare the verification evidence.

How to run

  1. Clone this repository and switch to hackathon-ai-trainer.
  2. Follow the project build instructions to build pokeemerald.gba.
  3. Run make -j"$(nproc)" check TESTS='External AI' for the focused tests.
  4. Open the ROM in mGBA and battle Youngster Calvin on Route 102.

Current scope and next steps

This submission intentionally stops before the mGBA mailbox, local service, and live-model call. The next phases create an engine-owned legal-action snapshot, an mGBA bridge, and a deterministic local agent before adding a model adapter.

Built With

  • c
  • codex
  • devkitarm
  • mgba
  • pokeemerald-expansion
Share this project:

Updates