Port the Smart AI effect handlers (#28)

Translate every AI_Smart_EffectHandlers entry, so trainers with the Smart layer are no longer refused. The AI's type checks keep the CheckTypeMatchup bug: they read the move type and Foresight flag through hBattleTurn, and Conversion2's write to the player's move type persists.

The reference emulator runs the unmodified AI_Smart routine over 6,024 states per browser, comparing scores, Random consumption, hBattleTurn and the player's move type. Validated with 579 unit tests, 151 browser tests, native/reference builds and reference/vendor/release checks. Kurt's balls, Park and Safari balls and special battle types remain on #28.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sébastien QUEROLandClaude Opus 5.5 committed 2026-10-03 15:30:32 +02:00
1 parent 32d736ecae
commit 77704fe848
11 files changed
+682 -71

No files matched your search

+26
View File
@@ -1224,3 +1224,29 @@ move list or loop indefinitely. Johto badge stat boosts are still absent;
the new badge option implements obedience only. Do not claim the battle
engine or the full card is complete. Delivery is tracked by the commits
referencing card #28; its commit list includes the recovered groups above.
## Smart AI handlers: 2026-10-03
Codex resumed card #28 after `32d736e` and stopped at its usage limit at
13:21 UTC with an uncommitted Smart AI translation (`smart-ai.ts`), partial
battle wiring and a failing emulator spec. Claude Code took it over.
- The spec showed 35 of 6,024 states differing, in five handlers. Encore,
Roar/Whirlwind, Baton Pass and Perish Song came from `CheckTypeMatchup`
ignoring the type in `a`: it reads the move type and Foresight flag through
`hBattleTurn`. The AI now tracks the turn and both move structs' types;
`checkPlayerMoveTypeMatchups` takes the type and flag. Conversion2's write
to the player's move type persists in the battle.
- Psych Up sums `NUM_LEVEL_STATS` (8) bytes. The eighth is only ever reset to
7 or copied, so the 7-entry sum is equivalent; the spec now writes it as 7.
- The spec randomizes the starting turn and the player's move type and also
compares them afterwards. It passes 6,024 states per browser; a one-off
run with another seed passed 18,072 per browser.
Validation: 579 unit tests passed (3 skipped); without the ROM 138 passed,
444 skipped. Browser suite: 151 passed, 19 intentional skips. Both builds,
reference/release/vendor checks and `git diff --check` passed. No CI or
physical-device validation.
Next on #28: Kurt's balls, Park and Safari balls, and special battle types.
Other boundaries listed in the previous section are unchanged.