Verify random battle and capture routines against the original engine
Checks / web (push) Canceled after 0s
Checks / web (push) Canceled after 0s
This commit is contained in:
1 parent
be7575a4d0
commit
00972bad10
9 files changed
+978
-74
No files matched your search
+81
-1
@@ -1,6 +1,6 @@
|
||||
# Recovered Claude session
|
||||
|
||||
Latest continuation: see **Battle items, hBattleTurn and the stats screen: 2026-09-30**
|
||||
Latest continuation: see **Controlled capture comparisons: 2026-09-30**
|
||||
at the end of this file. Earlier sections are historical snapshots.
|
||||
|
||||
Recovered on 2026-09-23 from the local Claude Code transcript
|
||||
@@ -607,3 +607,83 @@ without it); 97 Chromium/WebKit browser tests passed, 19 skipped
|
||||
intentionally; native and reference builds; reference, release and
|
||||
vendor checks; `git diff --check`. Committed and pushed to `main` as
|
||||
`b13e09e`.
|
||||
|
||||
## Controlled random battle comparisons: 2026-09-30
|
||||
|
||||
Resumed from `be7575a` with a clean working tree. The user requested a bounded
|
||||
increment suitable for a limited session. Continued PLAN section 2 with
|
||||
accuracy, criticals and damage variation; capture stays as the next item.
|
||||
|
||||
- `tests/reference-random.spec.ts` runs the original, unpatched
|
||||
`BattleCommand_Critical`, `BattleCommand_CheckHit` and
|
||||
`BattleCommand_DamageVariation` in the reference emulator. The native
|
||||
commands receive the same ten-byte Link RNG stream. Results include the
|
||||
final RNG stream/cursor, so extra or missing draws are detected too.
|
||||
- Per browser: 2,560 critical cases (all random bytes at all five reachable
|
||||
stages and held-item exceptions), 2,914 accuracy cases (all stage pairs,
|
||||
Foresight, BrightPowder, bypasses, Dream Eater/substitute and Jump Kick
|
||||
miss damage), and 2,149 variation cases (0/1, rounding, 16-bit boundaries,
|
||||
rejected draws and RNG stream regeneration).
|
||||
- Shared ROM input and symbol helpers moved from `reference-parity.spec.ts`
|
||||
into `tests/reference-fixture.ts`. No ROM bytes or extracted assets added.
|
||||
- Deliberately changing critical `<` to `<=`, accuracy `>=` to `>`, and the
|
||||
damage divisor from 255 to 256 each made its comparison fail. All three
|
||||
mutations were reverted; no production gameplay change was needed.
|
||||
|
||||
Boundary: these compare isolated commands with controlled random inputs.
|
||||
They do not compare a whole battle, the hardware-timed non-Link RNG, or the
|
||||
Protect text path. Lock-On/Fly/Dig remain refused. This does not enable Link
|
||||
battles or later maps.
|
||||
|
||||
Checks: 337 unit tests passed with the local ROM; 131 passed and 206
|
||||
skipped with an absent ROM. All 103 Chromium/WebKit browser tests passed,
|
||||
with the existing 19 intentional WebKit skips. Native and reference builds,
|
||||
reference, vendor and release checks, and `git diff --check` passed. No CI
|
||||
or physical-device run. This increment was initially left uncommitted and
|
||||
is included in the subsequent capture-comparison delivery below.
|
||||
|
||||
Next: controlled-input capture comparisons (`PokeBallEffect` and
|
||||
`GetPokeBallWobble`), then the party/bag menus outside battle, MOVE PKMN W/O
|
||||
MAIL and evolution. Keep section 2's capture checklist open until verified.
|
||||
|
||||
|
||||
## Controlled capture comparisons: 2026-09-30
|
||||
|
||||
Continued PLAN section 2 from the existing uncommitted accuracy, critical and
|
||||
damage-variation comparisons. Preserved that work and completed its next
|
||||
capture-comparison item.
|
||||
|
||||
- `tests/reference-capture.spec.ts` compares the native capture decision with
|
||||
the calculation inside `PokeBallEffect`, then its shake loop with
|
||||
`GetPokeBallWobble`. Per browser: 3,220 capture cases and 7,424 shake cases,
|
||||
including supported ball multipliers, all catch-rate bytes, HP scaling and
|
||||
overflow, status bonuses, equality boundaries, every random byte at each
|
||||
wobble-table entry, every escape count and guaranteed catches. Final rate,
|
||||
caught/escaped outcome, shake count and random-draw count agree.
|
||||
- Capture uses hardware `Random`, not `BattleRandom`. The private in-page ROM
|
||||
copy replaces `Random` with a supplied-byte reader; the fixture enters
|
||||
after the UI setup and inserts a return after `wWildMon` is written.
|
||||
Catch arithmetic, multipliers and `GetPokeBallWobble` remain unmodified.
|
||||
- Extracted `rollCapture` and `ballWobbles` as private production helpers
|
||||
called by `pokeBallEffect`, without changing gameplay behavior. Added
|
||||
maximum HP 683 beside 342 in the synthetic divide-by-zero regression.
|
||||
- Deliberately changing success `<=` to `<`, formula floor to ceiling, and
|
||||
shake `>=` to `>` each failed the comparisons. Mutations were reverted.
|
||||
|
||||
Boundary: isolated capture decision/shakes with supplied random bytes, not
|
||||
hardware RNG timing, animation, caught-mon reloading, party/PC writes or a
|
||||
whole battle. No actual item has `HELD_CATCH_CHANCE`; that effect remains
|
||||
covered by pure vectors. Native division-by-zero refusal remains in place;
|
||||
the emulator fixture omits the hanging HP inputs. No additional balls or
|
||||
maps are enabled.
|
||||
|
||||
Checks: 337 unit tests passed with the local ROM; 131 passed and 206 skipped
|
||||
with an absent ROM. All 107 Chromium/WebKit browser tests passed, with the
|
||||
existing 19 intentional WebKit skips. The four new capture tests skip cleanly
|
||||
without a ROM. Native and reference builds, reference, vendor and release
|
||||
checks, and `git diff --check` passed. No CI or physical-device run.
|
||||
The accuracy, critical, damage-variation and capture comparisons are delivered
|
||||
together, preserving the previously uncommitted work.
|
||||
|
||||
Next: party and bag menus outside battle, MOVE PKMN W/O MAIL and evolution.
|
||||
PLAN section 2 is complete within its recorded acceptance boundaries.
|
||||
Reference in new issue
Block a user