Merge feat/damage-reward (reviewed: APPROVE-WITH-NOTES): pay the fly for damage its own attacks deal, adapter pokered-unique8-v8
This commit is contained in:
commit
790347af7d
39 changed files with 1738 additions and 108 deletions
BIN
apps/stage/mockups/row68-ticker-hits.png
Normal file
BIN
apps/stage/mockups/row68-ticker-hits.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
BIN
apps/stage/mockups/row68-ticker-ko.png
Normal file
BIN
apps/stage/mockups/row68-ticker-ko.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 52 KiB |
|
|
@ -698,6 +698,24 @@ export function App() {
|
|||
ingest.commit(hot.lastSnapshotMs, true);
|
||||
return useStage.getState().chat.length;
|
||||
},
|
||||
/**
|
||||
* Feed reward events into the ticker by hand, `stepMs` of feed time apart, for the ticker
|
||||
* mockups (a battle's hits, a KO), and settle the dwell gate five seconds after the last.
|
||||
* The events go through the same `TickerQueue.push` a snapshot's do.
|
||||
*/
|
||||
ticker: (events, stepMs = 7000) => {
|
||||
let at = hot.lastSnapshotMs;
|
||||
for (const [index, item] of events.entries()) {
|
||||
at = hot.lastSnapshotMs + index * stepMs;
|
||||
ingest.queue().push(
|
||||
{ id: 900_000 + index, wallMs: 0, brainMs: 0, kind: 'reward', label: item.label, value: item.value },
|
||||
at,
|
||||
);
|
||||
}
|
||||
at += 5000;
|
||||
ingest.commit(at, true);
|
||||
return useStage.getState().ticker.map((row) => `${row.label} ${String(row.amount ?? '')}`);
|
||||
},
|
||||
/**
|
||||
* Put a notice on the recovery splash by hand, the same way `fire` drives a moment: for the
|
||||
* splash mockups and e2e assertions. The raw object goes through the same validation as a
|
||||
|
|
@ -790,6 +808,8 @@ declare global {
|
|||
fire: (type: MomentType, label?: string, detail?: string) => number | null;
|
||||
/** Replace the held feed's chat ring by hand; returns how many lines the panel accepted. */
|
||||
chat: (lines: readonly { by: string; text: string; bot?: boolean }[]) => number;
|
||||
/** Push reward events into the ticker by hand; returns the rows shown. */
|
||||
ticker: (events: readonly { label: string; value: number }[], stepMs?: number) => string[];
|
||||
/** Show a recovery notice by hand (validated like a polled one); null clears it. */
|
||||
recovery: (notice: unknown, nowS?: number) => RecoveryView | null;
|
||||
fly: () => {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,11 @@ export const pokemonRed: GameConfig = {
|
|||
badge: { label: 'gym badge', tier: 'moment', dedupeMs: 0 },
|
||||
},
|
||||
|
||||
// The fly's own hits (adapter `damage`): several a battle, no protocol kind, so one row per
|
||||
// battle that counts up. 45 s covers the slowest turn seen (about 7 s from press to payout)
|
||||
// several times over and is far shorter than the gap between two battles.
|
||||
hitCopy: { label: 'damage dealt', gapMs: 45_000, tier: 'quiet', koTier: 'notable' },
|
||||
|
||||
counters: [
|
||||
{ field: 'badges', label: 'badges', outOf: 8 },
|
||||
{ field: 'uniqueLocations', label: 'places' },
|
||||
|
|
|
|||
|
|
@ -29,6 +29,21 @@ export interface RewardCopy {
|
|||
collapsedNoun?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy and window for the adapter's per-hit reward, which the protocol has no `rewardKind` for
|
||||
* (Pokémon Red's `damage`, `HIT #<species> FOR <n> HP[ KO]`). Hits are folded stage-side into one
|
||||
* row per battle instead of one row per hit.
|
||||
*/
|
||||
export interface HitCopy {
|
||||
/** Row text. Constant; the feed's label is only read for the KO suffix. */
|
||||
label: string;
|
||||
/** A row is joined by a hit up to this long after the previous hit folded into it. */
|
||||
gapMs: number;
|
||||
/** Tier of the row; a KO raises it to `koTier`. */
|
||||
tier: RewardTier;
|
||||
koTier: RewardTier;
|
||||
}
|
||||
|
||||
/** A counter shown in the progress row beside the milestone ladder. */
|
||||
export interface GameCounter {
|
||||
/** Which `FeedGame` field to read. */
|
||||
|
|
@ -64,6 +79,8 @@ export interface GameConfig {
|
|||
modeLabels: Record<GameMode, string>;
|
||||
/** Human copy and presentation tier for each reward kind. */
|
||||
rewardCopy: Record<RewardKind, RewardCopy>;
|
||||
/** How a reward event with no `rewardKind` that reads as a hit is rolled up. Absent: never. */
|
||||
hitCopy?: HitCopy;
|
||||
/**
|
||||
* Counters shown on the progress cluster's footer line (`ProgressCluster`), e.g.
|
||||
* "3/8 badges · 214 places". Per-game *data*, not copy: the values come
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ export const DEFAULT_TICKER_OPTIONS = {
|
|||
*/
|
||||
const HIDDEN_KINDS: ReadonlySet<FeedEventKind> = new Set<FeedEventKind>(['checkpoint', 'viewer']);
|
||||
|
||||
/** The adapter's hit label: `HIT #<species> FOR <n> HP` with ` KO` when the hit felled a trainer's Pokémon. */
|
||||
const HIT_LABEL = /^HIT #\d+ FOR \d+ HP( KO)?$/;
|
||||
|
||||
export class TickerQueue {
|
||||
private readonly visibleRows: number;
|
||||
private readonly minDwellMs: number;
|
||||
|
|
@ -77,6 +80,8 @@ export class TickerQueue {
|
|||
private visible: TickerItem[] = [];
|
||||
private pending: TickerItem[] = [];
|
||||
private lastPromotionMs = Number.NEGATIVE_INFINITY;
|
||||
/** Feed time of the last hit folded into each hit row, by the row. */
|
||||
private readonly lastHitMs = new WeakMap<TickerItem, number>();
|
||||
/** Bumped whenever the visible list changes, so the store can push to React on change only. */
|
||||
private revision = 0;
|
||||
|
||||
|
|
@ -106,10 +111,11 @@ export class TickerQueue {
|
|||
push(event: FeedEvent, nowMs: number): boolean {
|
||||
if (HIDDEN_KINDS.has(event.kind)) return false;
|
||||
|
||||
const tier = this.tierOf(event);
|
||||
const label = this.labelOf(event);
|
||||
const hit = this.hitOf(event);
|
||||
const tier = hit ? this.hitTier(hit.ko) : this.tierOf(event);
|
||||
const label = hit ? `${this.game.hitCopy?.label ?? event.label}${hit.ko ? ' KO' : ''}` : this.labelOf(event);
|
||||
|
||||
const folded = this.fold(event, nowMs);
|
||||
const folded = hit ? this.foldHit(event, hit.ko, nowMs) : this.fold(event, nowMs);
|
||||
if (folded) return true;
|
||||
|
||||
const item: TickerItem = {
|
||||
|
|
@ -125,6 +131,8 @@ export class TickerQueue {
|
|||
...(event.by === undefined ? {} : { by: event.by }),
|
||||
};
|
||||
|
||||
if (hit) this.lastHitMs.set(item, nowMs);
|
||||
|
||||
if (tier === 'moment') {
|
||||
// Jump the gate: the badge is the reason anyone is watching.
|
||||
this.promote(item, nowMs);
|
||||
|
|
@ -176,6 +184,42 @@ export class TickerQueue {
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Is this a hit the game rolls up? Only a reward with no `rewardKind` and the adapter's own label. */
|
||||
private hitOf(event: FeedEvent): { ko: boolean } | null {
|
||||
if (!this.game.hitCopy || event.kind !== 'reward' || event.rewardKind) return null;
|
||||
const match = HIT_LABEL.exec(event.label);
|
||||
return match ? { ko: match[1] !== undefined } : null;
|
||||
}
|
||||
|
||||
private hitTier(ko: boolean): TickerTier {
|
||||
const copy = this.game.hitCopy;
|
||||
return copy ? (ko ? copy.koTier : copy.tier) : 'quiet';
|
||||
}
|
||||
|
||||
/**
|
||||
* Fold a hit into the battle's row: the newest hit row whose last hit is within `gapMs`. The
|
||||
* window slides with each hit (unlike `fold`'s, which is from creation) because a battle has
|
||||
* no fixed length; a row that has left the panel is not resurrected, the next hit starts one.
|
||||
* The row shows the summed reward, a `x<n>` count and a KO once any hit in it felled a Pokémon.
|
||||
*/
|
||||
private foldHit(event: FeedEvent, ko: boolean, nowMs: number): boolean {
|
||||
const copy = this.game.hitCopy;
|
||||
if (!copy) return false;
|
||||
for (const item of [...this.visible, ...this.pending]) {
|
||||
const last = this.lastHitMs.get(item);
|
||||
if (last === undefined || nowMs - last > copy.gapMs) continue;
|
||||
item.count += 1;
|
||||
if (event.value !== undefined) item.amount = (item.amount ?? 0) + event.value;
|
||||
const knocked = ko || item.label.endsWith(' KO');
|
||||
item.label = `${copy.label} x${item.count}${knocked ? ' KO' : ''}`;
|
||||
if (knocked) item.tier = copy.koTier;
|
||||
this.lastHitMs.set(item, nowMs);
|
||||
this.revision += 1;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private tierOf(event: FeedEvent): TickerTier {
|
||||
if (event.kind === 'reward' && event.rewardKind) {
|
||||
return this.game.rewardCopy[event.rewardKind]?.tier ?? 'quiet';
|
||||
|
|
|
|||
|
|
@ -147,3 +147,41 @@ test('the platformer config paces the same way with different copy', async () =>
|
|||
queue.push(reward('explore'), 100);
|
||||
assert.equal(queue.items()[0]?.label, '2 new ground');
|
||||
});
|
||||
|
||||
function hit(hp: number, value: number, ko = false): FeedEvent {
|
||||
return event('reward', `HIT #59 FOR ${hp} HP${ko ? ' KO' : ''}`, { value });
|
||||
}
|
||||
|
||||
test('a battle\'s hits fold into one damage row that sums and counts', () => {
|
||||
const queue = new TickerQueue(pokemonRed, { minDwellMs: 0 });
|
||||
queue.push(hit(10, 0.06), 0);
|
||||
queue.push(hit(9, 0.05), 7_000);
|
||||
queue.push(hit(4, 0.03), 15_000);
|
||||
assert.equal(queue.items().length, 1);
|
||||
const row = queue.items()[0];
|
||||
assert.equal(row?.label, 'damage dealt x3');
|
||||
assert.equal(row?.count, 3);
|
||||
assert.ok(Math.abs((row?.amount ?? 0) - 0.14) < 1e-9);
|
||||
assert.equal(row?.tier, 'quiet');
|
||||
});
|
||||
|
||||
test('a KO marks the row and raises its tier; the window slides, then a new battle is a new row', () => {
|
||||
const queue = new TickerQueue(pokemonRed, { minDwellMs: 0 });
|
||||
queue.push(hit(10, 0.06), 0);
|
||||
queue.push(hit(5, 0.08, true), 30_000);
|
||||
assert.equal(queue.items()[0]?.label, 'damage dealt x2 KO');
|
||||
assert.equal(queue.items()[0]?.tier, 'notable');
|
||||
queue.push(hit(3, 0.02), 70_000);
|
||||
assert.equal(queue.items().length, 1, 'still inside 45 s of the last hit');
|
||||
queue.push(hit(3, 0.02), 200_000);
|
||||
assert.equal(queue.items().length, 2, 'a later battle gets its own row');
|
||||
assert.equal(queue.items()[0]?.label, 'damage dealt');
|
||||
});
|
||||
|
||||
test('a hit is not confused with other rewards, and a lone KO says so', () => {
|
||||
const queue = new TickerQueue(pokemonRed, { minDwellMs: 0 });
|
||||
queue.push(hit(31, 0.25, true), 0);
|
||||
assert.equal(queue.items()[0]?.label, 'damage dealt KO');
|
||||
queue.push(event('reward', 'NEW MAP', { value: 0.1 }), 10);
|
||||
assert.equal(queue.items().length, 2, 'an unrelated no-kind reward keeps its own row');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -93,6 +93,31 @@ const CHAT_WRAP: { by: string; text: string; bot?: boolean }[] = [
|
|||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* The ticker in a battle (row 68): the fly's hits arrive as `HIT #<species> FOR <n> HP` rewards and
|
||||
* fold into one "damage dealt" row. Injected by hand through `window.__stage.ticker`, seven feed
|
||||
* seconds apart, because no fixture holds a battle recorded on adapter v8.
|
||||
*/
|
||||
const TICKER_SHOTS: { name: string; events: { label: string; value: number }[] }[] = [
|
||||
{
|
||||
name: 'row68-ticker-hits',
|
||||
events: [
|
||||
{ label: 'HIT #59 FOR 10 HP', value: 0.07 },
|
||||
{ label: 'HIT #59 FOR 9 HP', value: 0.06 },
|
||||
{ label: 'HIT #59 FOR 4 HP', value: 0.03 },
|
||||
{ label: 'HIT #59 FOR 4 HP', value: 0.03 },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'row68-ticker-ko',
|
||||
events: [
|
||||
{ label: 'HIT #59 FOR 10 HP', value: 0.07 },
|
||||
{ label: 'HIT #59 FOR 9 HP', value: 0.06 },
|
||||
{ label: 'HIT #59 FOR 12 HP KO', value: 0.13 },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const STILLS: { name: string; fixture: string; t: number; tab?: Tab; chat?: typeof CHAT_WRAP }[] = [
|
||||
{ name: 'steady-t1-senses', fixture: 'steady', t: 95, tab: 'senses' },
|
||||
{ name: 'steady-t1-connectome', fixture: 'steady', t: 95, tab: 'connectome' },
|
||||
|
|
@ -294,6 +319,18 @@ async function main(): Promise<void> {
|
|||
console.log(` ${path} (${String(state?.moment)} ${String(state?.momentPhase)}, ${String(state?.particles)} particles, tab ${String(state?.tab)})`);
|
||||
}
|
||||
|
||||
for (const shot of TICKER_SHOTS) {
|
||||
if (!wanted(shot.name)) continue;
|
||||
await page.goto(url(baseUrl, { fixture: 'steady', t: 95, tab: 'senses' }));
|
||||
await settle(page);
|
||||
const rows = await page.evaluate((events) => window.__stage?.ticker(events) ?? [], shot.events);
|
||||
await page.waitForTimeout(500);
|
||||
const path = resolve(outDir, `${shot.name}.png`);
|
||||
await page.screenshot({ path, clip: FRAME });
|
||||
written.push(path);
|
||||
console.log(` ${path} (${rows.join(' | ')})`);
|
||||
}
|
||||
|
||||
for (const shot of RECOVERY_SHOTS) {
|
||||
if (!wanted(shot.name)) continue;
|
||||
await page.goto(url(baseUrl, { fixture: 'steady', t: 95, tab: 'senses' }));
|
||||
|
|
|
|||
|
|
@ -89,8 +89,9 @@ decoder preset to use.
|
|||
disassembly at commit 0cd19d3 (`symbols.rs`), gates rewards on a playable state, baselines already
|
||||
achieved flags on the first sample so a restore never replays them, and pays only positive
|
||||
rewards: story flags, exploration coverage (capped per map), new areas, Pokédex entries, trainer
|
||||
flags, decaying wild wins, badges, exits found outdoors, catches, conversations indoors and items
|
||||
picked up (`docs/rewards-learning.md`). Version `pokered-unique8-v7`; a deploy that names the
|
||||
flags, decaying wild wins, badges, exits found outdoors, catches, conversations indoors, items
|
||||
picked up and the HP the fly's own attacks remove in battle (`docs/rewards-learning.md`).
|
||||
Version `pokered-unique8-v8`; a deploy that names the
|
||||
previous version in `FLY_ACCEPT_ADAPTERS` migrates its checkpoints instead of refusing them.
|
||||
- Ratchet (`ratchet.rs`): a 38-rung ladder (boot, bedroom, Pallet Town, Oak's lab, starter, parcel,
|
||||
Pokédex, each town, each badge, the Elite Four, Champion). On first reaching a higher rung in a
|
||||
|
|
|
|||
|
|
@ -398,6 +398,19 @@ on-screen ticker cannot disagree with what the sim did.
|
|||
slot from before a `v6`-era pickup cannot pay for it (`docs/rewards-learning.md`, "The seed").
|
||||
`STATE_VERSION` stays 4.
|
||||
|
||||
**`v7` -> `v8`** (2026-09-29, the damage reward). `pokered-unique8-v8`'s `migrates_from()` is
|
||||
`["pokered-unique8-v7", "pokered-unique8-v6"]`: the live run is `v7`, and `v6` still composes,
|
||||
because `v7`'s own step (the item seed on the first sample without `items:seeded`) is still in
|
||||
this build and the damage state starts empty either way. The deploy that ships it sets
|
||||
`FLY_ACCEPT_ADAPTERS=pokered-unique8-v7`; naming `v7` does not admit a `v6` checkpoint, which
|
||||
needs its own id. One optional field is added, `damageCounts` (the wild keys that have paid
|
||||
damage), and one optional object inside a battle in flight, `battle.damage` (the per-battle
|
||||
marks and what the battle has paid). A `v7` state has neither and restores with no wild key paid
|
||||
and, if the checkpoint was taken mid-battle, every enemy Pokémon marked at the HP it has when
|
||||
first read, so nothing it lost before the restore is paid. `STATE_VERSION` stays 4. The
|
||||
compatibility string moves in segment 1 only: `.../pokered-unique8-v7/...` becomes
|
||||
`.../pokered-unique8-v8/...`, every other segment byte-identical.
|
||||
|
||||
- **Restarting a run from an earlier rung** (2026-09-22). `FLY_RESET_STATE=1` throws the run away;
|
||||
`infra/bin/fly-reset-to-milestone <N>` keeps it and rewinds it. It archives both stores to a
|
||||
dated directory, rewrites `milestone-<N>.checkpoint` with the ratchet's `attempts` and
|
||||
|
|
|
|||
|
|
@ -155,6 +155,21 @@ which neither `gen_symbols.py` nor `resolve_wram.py` resolves, and a hand-writte
|
|||
thing those tools exist to refuse. "The fly had the joypad and was standing still on the frame
|
||||
before the box opened, and the box is about the thing it faces" is the same fact read out of WRAM.
|
||||
|
||||
### The damage reward's reads (2026-09-29)
|
||||
|
||||
**New 2026-09-29** (`damage`, `docs/rewards-learning.md`, "Damage rewards"). The two WRAM names were
|
||||
resolved by `services/flysim/tools/resolve_wram.py` from `ram/wram.asm` at the pinned commit and
|
||||
are bracketed by addresses `symbols.rs` already carried. The HRAM byte is the second hand-counted
|
||||
HRAM address in the crate, after row 63's `hJoyLast`, and is held to the same standard: counted
|
||||
from that pinned anchor and checked against the section's end, then pinned on the cartridge.
|
||||
|
||||
| what | symbol | address | notes | verified |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| whose side is acting | `hWhoseTurn` | `$FFF3` | "0 on player's turn, 1 on enemy's turn" (`ram/hram.asm`). Counted from `hJoyLast` (`$FFB1`) with each `UNION` at its largest member; the nine bytes after it end at `$FFFE`, the end of HRAM. `ExecutePlayerMove` writes 0 before the fly's move and `MainInBattleLoop` 1 before the enemy's; `HandlePoisonBurnLeechSeed` picks whose HP to cut by it. MEM-01's memory image captures HRAM, so the session runtime reads the same byte. | survey (`tests/rom_damage.rs`, the row 67 state: every enemy HP drop with 0, every own HP drop with 1) |
|
||||
| the move executing | `wPlayerMoveNum` | `$cfd2` | the first of the six move bytes `ExecutePlayerMove` loads; `STRUGGLE` (`$a5`) for a Pokémon with no PP. Bracketed by `wWalkCounter` and `wEnemyMonSpecies`. | survey (BUBBLE `$91` and TACKLE `$21` read on the frames their hits landed) |
|
||||
| which enemy slot is out | `wEnemyMonPartyPos` | `$cfe8` | `battle_struct`'s third field (`macros/ram.asm`: Species, HP, PartyPos, aliasing BoxLevel); `$ff` until a trainer's first send-out, then the 0-based party slot. Bracketed by `wEnemyMonHP` and `wEnemyMonStatus`. | trace (`pokemon_red/tests.rs`), survey |
|
||||
| (stale) the enemy | `wEnemyMonSpecies` ... `wEnemyMonMaxHP` | as above | **not cleared between battles**: `InitBattleVariables` leaves `wEnemyMon` alone, and a trainer battle sets `wIsInBattle` a whole transition before `LoadEnemyMonData`. The first samples of a battle can hold the last battle's Pokémon at the HP it finished on; the damage rule marks a target only once it reads full. | disassembly, trace |
|
||||
|
||||
### Battle menu and cursor, own turn against forced switch
|
||||
|
||||
`HandleMenuInput` is shared by every menu in the game, so which menu is up is read from where it
|
||||
|
|
|
|||
|
|
@ -178,8 +178,9 @@ achievements.
|
|||
| Badge | +3 | each newly set badge bit |
|
||||
|
||||
That is the prototype's catalog as it shipped, kept here as history. The live one is
|
||||
`docs/rewards-learning.md`: `pokered-unique8-v7` adds `boundary` (v5), `catch` (v6), and `talk` and
|
||||
`item` with no `boundary` payout indoors (v7, the operator's decision of 2026-09-23).
|
||||
`docs/rewards-learning.md`: `pokered-unique8-v8` adds `boundary` (v5), `catch` (v6), `talk` and
|
||||
`item` with no `boundary` payout indoors (v7, the operator's decision of 2026-09-23), and `damage`
|
||||
(v8, the operator's decision of 2026-09-29).
|
||||
|
||||
Every value is positive; there were no loss or blackout penalties. Values in a frame summed into
|
||||
`R`, then `m = tanh(R)`. PAM stimulation ran 80 to 400 ms depending on reward kind, with
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# Rewards and learning
|
||||
|
||||
The live reward catalog of the Pokémon Red adapter, `pokered-unique8-v7`. The code of record is
|
||||
The live reward catalog of the Pokémon Red adapter, `pokered-unique8-v8`. The code of record is
|
||||
`services/flysim/crates/flybrain-gb/src/pokemon_red/` (`catalog.rs` holds the values, `mod.rs` the
|
||||
gates and the rules); this page says what each rule pays for and why it is allowed to. The
|
||||
prototype's own `docs/rewards-learning.md` in `fly-plays-pokemon` is where the first seven rules
|
||||
|
|
@ -27,6 +27,7 @@ change what the fly can do.
|
|||
| `catch` | `wildwin` | +0.30, +0.10 | 150 ms | A wild Pokémon kept by a ball: +0.30 for a species this run had never owned, +0.10 for a repeat; at most three payouts per species for the lifetime of the ledger |
|
||||
| `talk` | `explore` | +0.10 | 100 ms | A conversation the fly opened with a person or a sign **indoors**, paid when its box closes; once per `(map, sprite slot or sign text id)` for the lifetime of the ledger |
|
||||
| `item` | `explore` | +0.15 | 120 ms | An item ball or a hidden item picked up, on any map; once per item for the lifetime of the ledger |
|
||||
| `damage` | -- | +0.20 per whole Pokémon, in proportion; +0.05 knockout | 80 ms | HP the fly's own attack removed from the enemy (since v8): its share of the target's max HP, below the lowest HP that target has shown this battle; +0.05 when the hit knocks out a trainer's Pokémon; at most 0.50 a battle; a wild battle at 1, 1/2, 1/3 for its first three per `(map, species, level)`, then nothing |
|
||||
|
||||
Every value is positive: there are no loss or blackout penalties, and `catalog::rule("blackout")`
|
||||
is `None` by test. The values in one frame sum into `R`, and the network reinforces once with
|
||||
|
|
@ -34,7 +35,8 @@ is `None` by test. The values in one frame sum into `R`, and the network reinfor
|
|||
|
||||
The feed-kind column is `RewardKind::from_adapter` in `services/flysim/crates/flysim/src/snapshot.rs`:
|
||||
`docs/feed-protocol.md` publishes seven counters, and an adapter kind that has no counter of its
|
||||
own shares the nearest one. It still reaches the page as an event with its own label.
|
||||
own shares the nearest one. It still reaches the page as an event with its own label. `damage` is
|
||||
the one Pokémon kind with no counter at all ("Damage rewards" below says why).
|
||||
|
||||
Two consequences of that sharing are worth stating rather than discovering. `catch` publishes on
|
||||
`wildwin` because a catch is a wild battle the fly won by keeping the Pokémon, and *not* on
|
||||
|
|
@ -177,6 +179,87 @@ half, 0.10, once, keyed under the building's id as it always was; walking out pa
|
|||
person, far below a badge. Everything is once per thing for the lifetime of the ledger, so no
|
||||
building can be farmed.
|
||||
|
||||
## Damage rewards
|
||||
|
||||
The operator's decision of 2026-09-29, chosen over a pad rule that would have withheld a stat move
|
||||
once it had been used: pay the fly for the HP its own attack removes from the Pokémon it is
|
||||
fighting. It is a catalog change, an operator decision like the catch and engagement rewards, not a
|
||||
loop-review fix. It answers row 67 (`infra/docs/macros-traps.md`): the live fly lost the Pewter
|
||||
Gym's Jr. Trainer 29 times running, choosing TAIL WHIP 155 times, BUBBLE 23 and TACKLE 0, and
|
||||
nothing in the catalog paid for anything that happened inside a battle it did not win. The pad
|
||||
offered every move; the readout's favourite was the one move that cannot win. The code is
|
||||
`pokemon_red/damage.rs`.
|
||||
|
||||
**What counts as the fly's attack.** A drop in `wEnemyMonHP` on a sample where `hWhoseTurn`
|
||||
(`$FFF3`) reads 0 and `wPlayerMoveNum` is not `STRUGGLE`. At the pinned commit
|
||||
(`engine/battle/core.asm`), `ApplyDamageToEnemyPokemon` subtracts the damage inside
|
||||
`ExecutePlayerMove`, with `hWhoseTurn` 0, once per hit of a multi-hit move. Everything else that
|
||||
lowers the enemy's HP lands with it 1: the enemy's poison and burn ticks and a Leech Seed on the
|
||||
enemy (`HandlePoisonBurnLeechSeed` picks whose HP to cut *by* `hWhoseTurn`), its recoil, its
|
||||
confusion self-hit, its own Explosion or Self-Destruct, and the HP it pays for a Substitute. A
|
||||
Leech Seed on the fly heals the enemy, and HP going up never pays. Damage into an enemy Substitute
|
||||
never touches `wEnemyMonHP`. `STRUGGLE` is the move the cartridge executes for a Pokémon with no
|
||||
PP; the fly chose FIGHT, not the move, so it pays nothing (winning still pays what winning pays).
|
||||
`tests/rom_damage.rs` pins the address on the cartridge from the live row 67 state: every drop of
|
||||
the enemy's HP lands with `hWhoseTurn` 0 and every drop of the fly's own with 1.
|
||||
|
||||
**How much.** 0.20 per whole enemy Pokémon's max HP, paid in proportion on the sample the HP
|
||||
drops -- BUBBLE for 10 of Diglett's 24 is 0.083, TACKLE for 4 of Sandshrew's 33 is 0.024. The hit
|
||||
that knocks out a trainer's Pokémon adds 0.05 on the same event. At most **0.50 a battle**, which is
|
||||
the `trainer` rule's own value: a battle's worth of damage is worth what winning it is, and the
|
||||
Jr. Trainer's two Pokémon reach it exactly (2 x (0.20 + 0.05)). A wild knockout adds nothing here
|
||||
because the `battle` rule already pays it, on the way out of the battle. Next to the rest of the
|
||||
catalog: a wild battle's damage (0.20) is twice its knockout (0.10) and equal to a new area (0.20);
|
||||
a trainer battle's (0.50) is the trainer's flag; a gym's is a sixth of the badge (3.0).
|
||||
|
||||
**What cannot be farmed.**
|
||||
|
||||
- *Heal.* Each target keeps the lowest HP it has shown this battle, and only HP below that pays. A
|
||||
Potion, Recover, Rest or a drain lifts the HP; the same HP is not paid twice.
|
||||
- *Switch.* A target is `(wEnemyMonPartyPos, species, level)`, so a trainer's Pokémon that goes out
|
||||
and comes back keeps its mark, and two Weedles of one level are two targets.
|
||||
- *A stale enemy.* `InitBattleVariables` does not clear `wEnemyMon`, and a trainer battle sets
|
||||
`wIsInBattle` a whole transition before `LoadEnemyMonData` runs, so the first samples of a
|
||||
battle can hold the last battle's Pokémon at the HP it finished on -- in the row 67 ring, the
|
||||
same trainer's Diglett in the same slot. A target is marked the first time it reads full HP,
|
||||
which is how every enemy Pokémon enters a battle in this game, so the stale one neither pays nor
|
||||
hides the real one's first hit.
|
||||
- *The battle.* 0.50 at most, whatever the party size.
|
||||
- *Wild Pokémon.* A wild battle pays at the wild-KO rule's scale, 1, 1/2, 1/3, for its first three
|
||||
battles per `(map, species, level)` that paid any damage (`damageCounts`), then nothing; attacking
|
||||
a wild Pokémon and running from it counts. A rollback blocks every key that has paid, the way it
|
||||
blocks a paid wild KO or catch.
|
||||
- *Trainers* keep no lifetime ledger. A trainer is fought again only after the fly has lost to it
|
||||
(or after a rollback), and each of those battles is bounded by the cap. In the row 67 ring that
|
||||
is the point: every lost battle pays for the hits that landed, and the hits that land are the
|
||||
moves that win.
|
||||
|
||||
**Feed.** `damage` publishes on no counter (`RewardKind::from_adapter` is `None`). Every other
|
||||
Pokémon kind shares the nearest counter, and the nearest here is `wildwin`, but the stage folds
|
||||
that row into "N wild wins": false of a trainer battle, and false of a battle the fly goes on to
|
||||
lose. A hit reaches the page as a reward event with its own label, `HIT #<species> FOR <n> HP`
|
||||
(`... KO` for a knockout; the species is the cartridge's internal index, as `CAUGHT #<species>` is),
|
||||
and the event log, `/status` and the checkpoint carry it; it is only left out of
|
||||
`game.rewardCounts` and the ticker's per-kind copy, the way the platformer's `started` and `clear`
|
||||
are. No feed kind was added. The stage rolls the hits up itself (`apps/stage/src/lib/ticker.ts`,
|
||||
`hitCopy` in the game config): a reward with no `rewardKind` and that label folds into one
|
||||
"damage dealt x<n>" row with the summed value, ` KO` once a hit in it felled a Pokémon, joined by
|
||||
each hit within 45 s of the last; a later battle starts a new row (`apps/stage/mockups/row68-ticker-*.png`).
|
||||
|
||||
**Learning.** A payout reinforces the recent spike history with `m = tanh(R)` over a 5 s
|
||||
eligibility trace ([plasticity](plasticity.md)). Measured on the cartridge from the row 67 state
|
||||
(`tests/rom_damage.rs`), the HP drops 176 frames (2.9 s) after the `MOVE n` press when the fly
|
||||
moves first and about 420 frames (7 s) when the Jr. Trainer's Pokémon does -- its attack and text
|
||||
come first. So the choice's trace is at a half to a quarter when its hit is paid, and the previous
|
||||
turn's choice, one turn (about 7.5 s) earlier still, at a tenth to a twentieth. That ratio is the
|
||||
whole mechanism: nothing tells the readout which move to press. A hit is small (0.02 to 0.10), so what it can move per battle is small too; whether
|
||||
the brain learns the attacking move inside a few brain hours is a measurement, not a promise, and
|
||||
the first one is `infra/docs/macros-traps.md`, row 68.
|
||||
|
||||
**Migration.** `v7` -> `v8` adds `damageCounts` and, inside a battle in flight, `battle.damage`;
|
||||
both are optional and a `v7` state restores with no wild key paid and its battle's Pokémon marked
|
||||
where they stand. See `docs/design/flysim.md`, "Restoring across an adapter version".
|
||||
|
||||
## Gates
|
||||
|
||||
Semantic rewards are enabled for exactly one cartridge, the SHA-256 in `SUPPORTED_ROM`. Any other
|
||||
|
|
@ -276,6 +359,15 @@ body picks the macro; the descending neurons press the buttons.**
|
|||
|
||||
## Honesty
|
||||
|
||||
The catalog now includes damage (v8). It is the first rule that pays for something inside a battle
|
||||
the fly may still lose, and the closest the catalog has come to grading a *choice*: the moves are
|
||||
all on the pad, and the one that lands pays. It is still a reward read out of WRAM after the frame,
|
||||
not a press: nothing in the adapter picks a move, removes one from the pad or tells the readout
|
||||
which is good, and a move pays only if the cartridge says it took HP off the enemy. The pad rule
|
||||
the operator declined (withholding a stat move once used) would have been the doctrine change; this
|
||||
one leaves the pad exactly as the scene deals it. It is also bounded on purpose: at most what winning
|
||||
pays, per battle, and a wild Pokémon only three times.
|
||||
|
||||
The catalog now includes conversations and items (v7). Paying for a conversation is the closest
|
||||
the catalog has come to paying for a *button*: A is what opens one. It is still a reward, not a
|
||||
press. Nothing in the adapter presses A, chooses when, or tells the fly who is there; the payout is
|
||||
|
|
|
|||
|
|
@ -931,3 +931,15 @@ median; a two-fly transition near 10 to 12 ms at the median in every execution m
|
|||
store is now the shared `flysim-store` crate; FLYSIM01 gains an optional `reinforcements`
|
||||
field, downgrade-safe both ways). A PII guard scans lint, tag-release and pushes. Reviews: all
|
||||
APPROVE-WITH-NOTES.
|
||||
|
||||
- 2026-09-29 (unreleased, the operator's decision, row 68): the fly is paid for the HP its own
|
||||
attack removes in battle, the catalog's answer to row 67 (the Pewter Gym's Jr. Trainer lost on
|
||||
repeat with TAIL WHIP six turns in seven). New kind `damage`: 0.20 per whole enemy Pokémon, in
|
||||
proportion, +0.05 when it knocks out a trainer's Pokémon, at most 0.50 a battle; a wild battle at
|
||||
1, 1/2, 1/3 per map/species/level. Only a drop on the fly's own turn (`hWhoseTurn` 0) by a move it
|
||||
chose (not Struggle); a heal is never paid twice; no feed counter (a hit is not a "wild win").
|
||||
Adapter `pokered-unique8-v8`; a deploy with FLY_ACCEPT_ADAPTERS=pokered-unique8-v7 migrates the
|
||||
run (v6 still migrates when named). Survey, 3 starts x 120 brain minutes from the row 67
|
||||
checkpoint: v8 beat the trainer in 2 of 3 (one run also won the Boulder Badge), v7 in 0 of 3, but
|
||||
the move choice did not shift more under v8 than v7 (BUBBLE ~15% -> ~20% in both): no learned
|
||||
preference is shown inside two hours (`infra/docs/macros-traps.md` row 68).
|
||||
|
|
|
|||
|
|
@ -322,8 +322,9 @@ if [ -n "$RELEASE_TARBALL" ]; then
|
|||
#
|
||||
# FLY_ACCEPT_ADAPTERS is the *other* override, and the opposite one: it keeps
|
||||
# the run. It names adapter version strings whose checkpoints the new build
|
||||
# may migrate — e.g. FLY_ACCEPT_ADAPTERS=pokered-unique8-v6 for the deploy
|
||||
# that adds the engagement rewards (v7; v5 -> v6 was the catch reward's).
|
||||
# may migrate — e.g. FLY_ACCEPT_ADAPTERS=pokered-unique8-v7 for the deploy
|
||||
# that adds the damage reward (v8; v6 -> v7 was the engagement rewards', v5 -> v6
|
||||
# the catch reward's).
|
||||
# It only applies when the adapter segment is the
|
||||
# ONLY difference between the two strings and the new build's adapter says it
|
||||
# can read that one; a dataset, kernel, emulator or state-format change is
|
||||
|
|
@ -377,7 +378,7 @@ The difference is usually an adapter/ladder or dataset version bump. Three ways
|
|||
* deploy a build whose string matches (check out the commit the running release was built from), or
|
||||
* if the ADAPTER VERSION is the only segment that differs and the new build documents a
|
||||
migration from the old one, re-run with FLY_ACCEPT_ADAPTERS set to the adapter id in the live
|
||||
string (e.g. FLY_ACCEPT_ADAPTERS=pokered-unique8-v6). The run is kept; flysim applies the same
|
||||
string (e.g. FLY_ACCEPT_ADAPTERS=pokered-unique8-v7). The run is kept; flysim applies the same
|
||||
rule at restore. See docs/design/flysim.md, \"Restoring across an adapter version\", or
|
||||
* accept losing everything the brain has learned and re-run with FLY_RESET_STATE=1, which
|
||||
archives ${state_dir}'s checkpoints to ${state_dir}.<timestamp> (kept, not deleted) and
|
||||
|
|
|
|||
|
|
@ -3552,3 +3552,43 @@ starting state, as row 66's did: four rung-9 checkpoints with one ball each.
|
|||
after the keyboard because its frames after the catch differ from a69a258's (the keyboard took
|
||||
28 brain seconds instead of `NEXT`'s few), not because anything waited: 635 macros started, 633
|
||||
done, one refusal and one timeout, against 803, 802, one and one.
|
||||
|
||||
## 2026-09-29, row 68: the damage reward, the catalog's answer to row 67
|
||||
|
||||
Row 67 (the Pewter Gym's Jr. Trainer lost on repeat, TAIL WHIP 155 / BUBBLE 23 / TACKLE 0) is a
|
||||
readout choice, not a pad fault. The operator chose a catalog change over a pad rule: `damage`,
|
||||
adapter `pokered-unique8-v8` (`docs/rewards-learning.md`, "Damage rewards"). It pays for the HP the
|
||||
fly's own attack removes; it does not touch the pad.
|
||||
|
||||
### The survey
|
||||
|
||||
The real brain, macros mode, from the row 67 checkpoint, 120 brain minutes per arm, `v7` (main)
|
||||
against `v8` (the rule), on the stream's own frame (`LegacyFrame`). The palette seed turned out not
|
||||
to diversify a run (seeds 1, 2 and 3 were identical per arm), so the three pairs are three starts:
|
||||
the checkpoint as it is, and the checkpoint with the game run 7 and 19 frames ahead of the brain.
|
||||
Each pair is identical until the first damage payout.
|
||||
|
||||
| start | arm | trainer battles | won | BUBBLE share, first 40 / last 40 min | damage paid | rung |
|
||||
| --- | --- | ---: | ---: | --- | ---: | --- |
|
||||
| +0 | v7 | 68 | 0 | 14% / 17% | -- | 10 |
|
||||
| +0 | v8 | 58 | 3 (Jr. Trainer at 101 min, Brock at 107, a Route 3 trainer at 112) | 15% / 20% | 6.01 | **11, BOULDER BADGE** |
|
||||
| +7 | v7 | 65 | 0 | 16% / 21% | -- | 10 |
|
||||
| +7 | v8 | 67 | 0 | 14% / 14% | 3.41 | 10 |
|
||||
| +19 | v7 | 60 | 0 | 15% / 24% | -- | 10 |
|
||||
| +19 | v8 | 59 | 1 (Jr. Trainer at 119.6 min) | 16% / 22% | 6.74 | 10 |
|
||||
|
||||
TACKLE stayed at 0 to 2 choices a run in every arm.
|
||||
|
||||
**What it shows.** The rule fires where it should: every `v8` arm was paid for BUBBLE's hits and
|
||||
nothing for TAIL WHIP's, 3.4 to 6.7 over two hours, capped per battle. `v8` beat the trainer in 2
|
||||
of 3 starts and `v7` in 0 of 3 (and the live run 0 of 29). **What it does not show** is the
|
||||
mechanism the rule is for: the move choice did not move more under `v8` than under `v7`. BUBBLE
|
||||
drifted from about 15% to about 20% in both arms, and TAIL WHIP stayed near 80% everywhere. So
|
||||
inside two brain hours the wins are not explained by a learned preference; a paid hit also changes
|
||||
the brain's activity (the PAM stimulation) and the trajectory, and three starts cannot tell a small
|
||||
real effect from luck. Learning is too slow to show in this window, or not happening, and the
|
||||
survey cannot say which.
|
||||
|
||||
**Status: shipped as the operator decided, not a fix.** The trap is still possible under it: one of
|
||||
three `v8` starts never won. Row 67's watchdog check 10 (`unwon-battles`, on its branch) is the
|
||||
detector, and the pad rule the operator declined is the lever that still exists.
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ pct exec $CTID -- /opt/fly/bin/fly-reset-to-milestone $N
|
|||
# (a) the running release already wrote that checkpoint -> nothing to deploy, skip to 5.
|
||||
# (b) the new build bumps the ADAPTER VERSION and nothing else -> name the checkpoint's
|
||||
# adapter so the gate and flysim both migrate instead of refusing:
|
||||
FLY_ACCEPT_ADAPTERS=pokered-unique8-v6 infra/05-deploy.sh <release-env> <release-tarball>
|
||||
FLY_ACCEPT_ADAPTERS=pokered-unique8-v7 infra/05-deploy.sh <release-env> <release-tarball>
|
||||
# The gate logs "the adapter version is the only difference, and it is named; the run is KEPT
|
||||
# and migrated", and writes FLY_ACCEPT_ADAPTERS into /etc/fly/fly.env so flysim applies the
|
||||
# same rule at restore. Anything else about the string differing is still a refusal.
|
||||
|
|
|
|||
10
infra/env/example.env
vendored
10
infra/env/example.env
vendored
|
|
@ -340,9 +340,13 @@ FLY_FEED_VIA=direct
|
|||
# two strings AND the new build's adapter declares a migration from that one. A
|
||||
# dataset, kernel, plasticity, emulator or state-format difference is still a
|
||||
# refusal. Set it for the one deploy that needs it and leave it out afterwards;
|
||||
# 05-deploy writes it into /etc/fly/fly.env only while it is set. The v0.6.0
|
||||
# deploy (pokered-unique8-v7, the engagement rewards) is the one that needs:
|
||||
# FLY_ACCEPT_ADAPTERS=pokered-unique8-v6
|
||||
# 05-deploy writes it into /etc/fly/fly.env only while it is set. The deploy
|
||||
# of pokered-unique8-v8 (the damage reward) over the live v7 run needs:
|
||||
# FLY_ACCEPT_ADAPTERS=pokered-unique8-v7
|
||||
# and, to keep the milestone archives written before v0.6.0 restorable as
|
||||
# fallbacks and fly-reset-to-milestone targets, also names v6 (v8 reads both):
|
||||
# FLY_ACCEPT_ADAPTERS=pokered-unique8-v7,pokered-unique8-v6
|
||||
# (v0.6.0's, pokered-unique8-v7 over v6, needed pokered-unique8-v6.)
|
||||
|
||||
# --- push mode --------------------------------------------------------------
|
||||
# local: flypush.service stays disabled, everything else identical to prod.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ pub fn example_composition() -> LegacyComposition {
|
|||
byte_length: 1_048_576,
|
||||
format: "gb-rom".to_owned(),
|
||||
},
|
||||
adapter: "pokered-unique8-v7".to_owned(),
|
||||
adapter: "pokered-unique8-v8".to_owned(),
|
||||
symbol_provenance: pokered.to_owned(),
|
||||
mode: "macros".to_owned(),
|
||||
macro_channels: decoder_vector("macros")["macroChannels"]
|
||||
|
|
@ -71,7 +71,7 @@ pub fn example_composition() -> LegacyComposition {
|
|||
audio_sample_rate: 48_000,
|
||||
},
|
||||
flysim_compatibility: format!(
|
||||
"{}/pokered-unique8-v7/{}/{}/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:{pokered}/statefmt:199616-x86_64-unknown-linux-gnu",
|
||||
"{}/pokered-unique8-v8/{}/{}/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:{pokered}/statefmt:199616-x86_64-unknown-linux-gnu",
|
||||
gameboy::KERNEL_VERSION,
|
||||
gameboy::FAFB_V783_FINGERPRINT,
|
||||
gameboy::PLASTICITY_VERSION,
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -560,9 +560,9 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"digest": "44916db0a0846d3338f50d4f24d9d4e0214fa239af7d15e4174213cd93b07e28",
|
||||
"digest": "d37ccb40162ecb42172609623d53791804571fee1b66a1f4ab8183a9a68852ea",
|
||||
"recipeLines": [
|
||||
"fly-session/composition-v1",
|
||||
"session=<sessionId>",
|
||||
|
|
|
|||
|
|
@ -5202,7 +5202,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5243,7 +5243,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "the profile AssetRef digest is the legacy profile's"
|
||||
},
|
||||
|
|
@ -5267,7 +5267,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "raw",
|
||||
"macroChannels": [
|
||||
|
|
@ -5308,7 +5308,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "raw mode deals no macro channels"
|
||||
},
|
||||
|
|
@ -5332,7 +5332,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": []
|
||||
|
|
@ -5368,7 +5368,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "macros mode needs its channels"
|
||||
},
|
||||
|
|
@ -5392,7 +5392,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5433,7 +5433,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "the executor extension is pokered-macros-v1"
|
||||
},
|
||||
|
|
@ -5457,7 +5457,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5498,7 +5498,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "exact",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "the legacy composition declares legacy-transient-reset"
|
||||
},
|
||||
|
|
@ -5522,7 +5522,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5563,7 +5563,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "the rollback policy needs gameboy-slots-v1"
|
||||
},
|
||||
|
|
@ -5587,7 +5587,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5628,7 +5628,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "one Game Boy frame is 8572265625/512 ns, not 1/60 s"
|
||||
},
|
||||
|
|
@ -5652,7 +5652,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5693,7 +5693,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v6/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "the FLYSIM01 string and the declaration describe the same fly"
|
||||
},
|
||||
|
|
@ -5717,7 +5717,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -5758,7 +5758,7 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSESS1",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"reason": "FLYSIM01 stays until RETIRE-01"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3337,7 +3337,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "macros",
|
||||
"macroChannels": [
|
||||
|
|
@ -3405,11 +3405,11 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"note": "placeholder ROM digest; real macros-mode decoder digest and channels",
|
||||
"canonical": "{\"checkpointFormatOfRecord\":\"FLYSIM01\",\"compositionId\":\"pokered-live\",\"decoderConfigDigest\":\"82b6601f0390b742a67eca44ef935b49e16a73315db70f5644f1cbd21f7c8a52\",\"environment\":{\"audio\":{\"channels\":2,\"sampleRate\":48000},\"controllerSchema\":{\"digest\":\"1bde5fa114b99824ad608fba4ea85706cb0cebc6123a778dc1e5f89791d2a05e\",\"id\":\"gameboy-joypad-v1\",\"version\":1},\"extensions\":[\"gameboy-slots-v1\"],\"inspectionSchema\":{\"digest\":\"d6cb62248bfdac2ffdf00290ffbebf9a101b1fe28f7be766d24db28ede8da3e6\",\"id\":\"gameboy-memory-inspection-v1\",\"version\":1},\"setupFrames\":1,\"slots\":[\"best\"],\"stepDuration\":{\"denominator\":\"512\",\"numerator\":\"8572265625\"}},\"episodePolicy\":\"legacy-ratchet-rollback-v1\",\"executor\":{\"adapter\":\"pokered-unique8-v7\",\"id\":\"pokered-macros-v1\",\"macroChannels\":[\"macro_go_objective\",\"macro_go_out\",\"macro_go_warp\",\"macro_go_route\",\"macro_go_item\",\"macro_go_npc\",\"macro_go_frontier\",\"macro_go_shop\",\"macro_go_heal\",\"macro_talk\",\"macro_menu\",\"macro_next\",\"macro_yes\",\"macro_no\",\"macro_close\",\"macro_confirm\",\"macro_back\",\"macro_move_1\",\"macro_move_2\",\"macro_move_3\",\"macro_move_4\",\"macro_switch\",\"macro_item\",\"macro_throw_ball\",\"macro_run\",\"macro_buy_potion\",\"macro_buy_ball\",\"macro_buy_antidote\",\"macro_buy_repel\",\"macro_heal\",\"macro_leave\"],\"mode\":\"macros\",\"rom\":{\"byteLength\":\"1048576\",\"digest\":\"c840ea493f9bf41505f26cf5b1db26815dd588e7ec91d5fd6f1ad4d363dc4f20\",\"format\":\"gb-rom\",\"id\":\"pokered-rom\"},\"symbolProvenance\":\"0cd19d3b877b7dc66d12c7050bed9a7f38154d4b\"},\"flysimCompatibility\":\"lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu\",\"profile\":{\"byteLength\":\"1137\",\"digest\":\"41e5d1ac62ab23f1b2d7252d52faac08b269c85e6b4c9ed7a370c74032c60878\",\"format\":\"fly-profile-v1\",\"id\":\"gameboy-legacy-fafb-v783-v1\"},\"restore\":\"legacy-transient-reset\",\"scheduler\":\"lockstep-v1\"}",
|
||||
"digest": "44916db0a0846d3338f50d4f24d9d4e0214fa239af7d15e4174213cd93b07e28"
|
||||
"canonical": "{\"checkpointFormatOfRecord\":\"FLYSIM01\",\"compositionId\":\"pokered-live\",\"decoderConfigDigest\":\"82b6601f0390b742a67eca44ef935b49e16a73315db70f5644f1cbd21f7c8a52\",\"environment\":{\"audio\":{\"channels\":2,\"sampleRate\":48000},\"controllerSchema\":{\"digest\":\"1bde5fa114b99824ad608fba4ea85706cb0cebc6123a778dc1e5f89791d2a05e\",\"id\":\"gameboy-joypad-v1\",\"version\":1},\"extensions\":[\"gameboy-slots-v1\"],\"inspectionSchema\":{\"digest\":\"d6cb62248bfdac2ffdf00290ffbebf9a101b1fe28f7be766d24db28ede8da3e6\",\"id\":\"gameboy-memory-inspection-v1\",\"version\":1},\"setupFrames\":1,\"slots\":[\"best\"],\"stepDuration\":{\"denominator\":\"512\",\"numerator\":\"8572265625\"}},\"episodePolicy\":\"legacy-ratchet-rollback-v1\",\"executor\":{\"adapter\":\"pokered-unique8-v8\",\"id\":\"pokered-macros-v1\",\"macroChannels\":[\"macro_go_objective\",\"macro_go_out\",\"macro_go_warp\",\"macro_go_route\",\"macro_go_item\",\"macro_go_npc\",\"macro_go_frontier\",\"macro_go_shop\",\"macro_go_heal\",\"macro_talk\",\"macro_menu\",\"macro_next\",\"macro_yes\",\"macro_no\",\"macro_close\",\"macro_confirm\",\"macro_back\",\"macro_move_1\",\"macro_move_2\",\"macro_move_3\",\"macro_move_4\",\"macro_switch\",\"macro_item\",\"macro_throw_ball\",\"macro_run\",\"macro_buy_potion\",\"macro_buy_ball\",\"macro_buy_antidote\",\"macro_buy_repel\",\"macro_heal\",\"macro_leave\"],\"mode\":\"macros\",\"rom\":{\"byteLength\":\"1048576\",\"digest\":\"c840ea493f9bf41505f26cf5b1db26815dd588e7ec91d5fd6f1ad4d363dc4f20\",\"format\":\"gb-rom\",\"id\":\"pokered-rom\"},\"symbolProvenance\":\"0cd19d3b877b7dc66d12c7050bed9a7f38154d4b\"},\"flysimCompatibility\":\"lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu\",\"profile\":{\"byteLength\":\"1137\",\"digest\":\"41e5d1ac62ab23f1b2d7252d52faac08b269c85e6b4c9ed7a370c74032c60878\",\"format\":\"fly-profile-v1\",\"id\":\"gameboy-legacy-fafb-v783-v1\"},\"restore\":\"legacy-transient-reset\",\"scheduler\":\"lockstep-v1\"}",
|
||||
"digest": "d37ccb40162ecb42172609623d53791804571fee1b66a1f4ab8183a9a68852ea"
|
||||
},
|
||||
{
|
||||
"name": "an example legacy composition in raw mode",
|
||||
|
|
@ -3431,7 +3431,7 @@
|
|||
"byteLength": "1048576",
|
||||
"format": "gb-rom"
|
||||
},
|
||||
"adapter": "pokered-unique8-v7",
|
||||
"adapter": "pokered-unique8-v8",
|
||||
"symbolProvenance": "0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
"mode": "raw",
|
||||
"macroChannels": []
|
||||
|
|
@ -3467,11 +3467,11 @@
|
|||
"episodePolicy": "legacy-ratchet-rollback-v1",
|
||||
"restore": "legacy-transient-reset",
|
||||
"checkpointFormatOfRecord": "FLYSIM01",
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
"flysimCompatibility": "lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu"
|
||||
},
|
||||
"note": "",
|
||||
"canonical": "{\"checkpointFormatOfRecord\":\"FLYSIM01\",\"compositionId\":\"pokered-live\",\"decoderConfigDigest\":\"6234e4a0363cfe82b8d515943c4f645a3960eda8fa5bf9465009061f80d50812\",\"environment\":{\"audio\":{\"channels\":2,\"sampleRate\":48000},\"controllerSchema\":{\"digest\":\"1bde5fa114b99824ad608fba4ea85706cb0cebc6123a778dc1e5f89791d2a05e\",\"id\":\"gameboy-joypad-v1\",\"version\":1},\"extensions\":[\"gameboy-slots-v1\"],\"inspectionSchema\":{\"digest\":\"d6cb62248bfdac2ffdf00290ffbebf9a101b1fe28f7be766d24db28ede8da3e6\",\"id\":\"gameboy-memory-inspection-v1\",\"version\":1},\"setupFrames\":1,\"slots\":[\"best\"],\"stepDuration\":{\"denominator\":\"512\",\"numerator\":\"8572265625\"}},\"episodePolicy\":\"legacy-ratchet-rollback-v1\",\"executor\":{\"adapter\":\"pokered-unique8-v7\",\"id\":\"pokered-macros-v1\",\"macroChannels\":[],\"mode\":\"raw\",\"rom\":{\"byteLength\":\"1048576\",\"digest\":\"c840ea493f9bf41505f26cf5b1db26815dd588e7ec91d5fd6f1ad4d363dc4f20\",\"format\":\"gb-rom\",\"id\":\"pokered-rom\"},\"symbolProvenance\":\"0cd19d3b877b7dc66d12c7050bed9a7f38154d4b\"},\"flysimCompatibility\":\"lif-1ms-f64-v2/pokered-unique8-v7/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu\",\"profile\":{\"byteLength\":\"1137\",\"digest\":\"41e5d1ac62ab23f1b2d7252d52faac08b269c85e6b4c9ed7a370c74032c60878\",\"format\":\"fly-profile-v1\",\"id\":\"gameboy-legacy-fafb-v783-v1\"},\"restore\":\"legacy-transient-reset\",\"scheduler\":\"lockstep-v1\"}",
|
||||
"digest": "568eceeb052ebf4fbd0c10661e227783cecc8ac7fee75ae6ba84335c684bfb7c"
|
||||
"canonical": "{\"checkpointFormatOfRecord\":\"FLYSIM01\",\"compositionId\":\"pokered-live\",\"decoderConfigDigest\":\"6234e4a0363cfe82b8d515943c4f645a3960eda8fa5bf9465009061f80d50812\",\"environment\":{\"audio\":{\"channels\":2,\"sampleRate\":48000},\"controllerSchema\":{\"digest\":\"1bde5fa114b99824ad608fba4ea85706cb0cebc6123a778dc1e5f89791d2a05e\",\"id\":\"gameboy-joypad-v1\",\"version\":1},\"extensions\":[\"gameboy-slots-v1\"],\"inspectionSchema\":{\"digest\":\"d6cb62248bfdac2ffdf00290ffbebf9a101b1fe28f7be766d24db28ede8da3e6\",\"id\":\"gameboy-memory-inspection-v1\",\"version\":1},\"setupFrames\":1,\"slots\":[\"best\"],\"stepDuration\":{\"denominator\":\"512\",\"numerator\":\"8572265625\"}},\"episodePolicy\":\"legacy-ratchet-rollback-v1\",\"executor\":{\"adapter\":\"pokered-unique8-v8\",\"id\":\"pokered-macros-v1\",\"macroChannels\":[],\"mode\":\"raw\",\"rom\":{\"byteLength\":\"1048576\",\"digest\":\"c840ea493f9bf41505f26cf5b1db26815dd588e7ec91d5fd6f1ad4d363dc4f20\",\"format\":\"gb-rom\",\"id\":\"pokered-rom\"},\"symbolProvenance\":\"0cd19d3b877b7dc66d12c7050bed9a7f38154d4b\"},\"flysimCompatibility\":\"lif-1ms-f64-v2/pokered-unique8-v8/75ba5d3536a2862fdb9f4ef1a76b96fe099a7201ac737f0cf53fe4c5ad4183f3:1657ba7716494c9db95a13b1527bc129226363f99b395774de1f76ff28571f0e:63b1acb26272edccdcfacf3c2ff58069e0cefaa84451429c989258bafaeae1d5:f567d7f07227e71c0df2ab4e6510f3a3f79e51b675095792e16d216d74b7b5b7:ece0b5e76d1884dd2f3ff6e0362bc284febe205ac1ce07fdab5009942ddffb62:b8c33144d4cec31c3ac4b6091ef1f4207f567c4f710f7c13fd2dc47c44c2b634:dbbafc044cd50aad7b792615988ff6d9991c846cc3d8b2eafc86b7c357b5eefc/fly-kc-mbon-rstdp-v2/binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b/statefmt:199616-x86_64-unknown-linux-gnu\",\"profile\":{\"byteLength\":\"1137\",\"digest\":\"41e5d1ac62ab23f1b2d7252d52faac08b269c85e6b4c9ed7a370c74032c60878\",\"format\":\"fly-profile-v1\",\"id\":\"gameboy-legacy-fafb-v783-v1\"},\"restore\":\"legacy-transient-reset\",\"scheduler\":\"lockstep-v1\"}",
|
||||
"digest": "0e62f2d6ee98226262f0d212762a9a69f1901a97f08dbe7790a502fe308e56a5"
|
||||
},
|
||||
{
|
||||
"name": "a rank climb: slot saved, then the milestone capture",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ ROM bytes -> Emulator::run_frame -> RGBA frame + PCM + WRAM
|
|||
| `emulator` | Safe wrapper over binjgb: frames, framebuffer, buttons, WRAM, audio, save states, ROM hash |
|
||||
| `image` | The boundary memory image (`read_memory_image`), the `Cartridge` and `ImageReader`, which runs the macros and adapters over an image instead of a live emulator (MEM-01) |
|
||||
| `adapter` | `GameAdapter`, `RewardEvent`, `ProgressSnapshot`, `MemoryReader`, `adapter_for` |
|
||||
| `pokemon_red` | The `pokered-unique8-v7` reward adapter, its catalog and its generated symbol table |
|
||||
| `pokemon_red` | The `pokered-unique8-v8` reward adapter, its catalog and its generated symbol table |
|
||||
| `platformer` | The `sml-progress-v1` Super Mario Land adapter, its catalog and its RAM map |
|
||||
| `ratchet` | The progress ratchet, generic over the adapter's rank and its `RecoveryPolicy` |
|
||||
| `recovery` | Rolling the game back to the ratchet's best safe snapshot |
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl MemoryReader for &mut dyn MemoryReader {
|
|||
///
|
||||
/// `kind` is an adapter-owned interned name (Pokémon: `milestone`,
|
||||
/// `exploration`, `map`, `species`, `trainer`, `battle`, `badge`, `boundary`, `catch`,
|
||||
/// `talk`, `item`); it is the key the statistics counters and the on-screen ticker group
|
||||
/// `talk`, `item`, `damage`); it is the key the statistics counters and the on-screen ticker group
|
||||
/// by. Field names serialize exactly as the prototype's `RewardEvent` did, so a
|
||||
/// checkpoint written by either implementation reads in the other.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
||||
|
|
@ -241,7 +241,7 @@ impl std::error::Error for AdapterError {}
|
|||
/// A game, as the sim loop sees it.
|
||||
pub trait GameAdapter: Send {
|
||||
/// Adapter version string, pinned into the checkpoint compatibility string.
|
||||
/// Pokémon: `pokered-unique8-v7`.
|
||||
/// Pokémon: `pokered-unique8-v8`.
|
||||
fn id(&self) -> &'static str;
|
||||
|
||||
/// Earlier [`GameAdapter::id`]s whose checkpoints this build can read, by a migration
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub const PROTOTYPE_PLASTICITY_VERSION: &str = "fly-kc-mbon-rstdp-v2";
|
|||
pub struct Compatibility<'a> {
|
||||
/// `kernelVersion(config)` from the neural library.
|
||||
pub neural_kernel_version: &'a str,
|
||||
/// The adapter's version string, e.g. `pokered-unique8-v7`.
|
||||
/// The adapter's version string, e.g. `pokered-unique8-v8`.
|
||||
pub adapter: &'a str,
|
||||
/// The dataset's seven SHA-256 digests joined with `:`.
|
||||
pub dataset_fingerprint: &'a str,
|
||||
|
|
@ -78,7 +78,7 @@ const ADAPTER_SEGMENT: usize = 1;
|
|||
/// The environment variable that opts a deploy into the adapter migration.
|
||||
///
|
||||
/// Read by flysim at restore and by `infra/05-deploy.sh`'s compatibility gate. Comma- or
|
||||
/// whitespace-separated adapter ids, e.g. `FLY_ACCEPT_ADAPTERS=pokered-unique8-v6`.
|
||||
/// whitespace-separated adapter ids, e.g. `FLY_ACCEPT_ADAPTERS=pokered-unique8-v7`.
|
||||
pub const ACCEPT_ADAPTERS_ENV: &str = "FLY_ACCEPT_ADAPTERS";
|
||||
|
||||
/// What a build may do with a checkpoint whose compatibility string is not its own.
|
||||
|
|
@ -180,7 +180,7 @@ mod tests {
|
|||
assert_eq!(
|
||||
fixture().prototype_string(),
|
||||
concat!(
|
||||
"lif-1ms-f64-v2/pokered-unique8-v7/aa:bb:cc:dd:ee:ff:00/",
|
||||
"lif-1ms-f64-v2/pokered-unique8-v8/aa:bb:cc:dd:ee:ff:00/",
|
||||
"fly-kc-mbon-rstdp-v2/",
|
||||
"binjgb:c60e138da5a795ebb55e56b11b7e90024e41112c/",
|
||||
"pokered:0cd19d3b877b7dc66d12c7050bed9a7f38154d4b",
|
||||
|
|
@ -194,10 +194,43 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn an_identical_string_restores_without_any_opt_in() {
|
||||
let current = with_adapter("pokered-unique8-v7");
|
||||
let current = with_adapter("pokered-unique8-v8");
|
||||
assert_eq!(decide(¤t, ¤t, &[], &[]), RestoreDecision::Exact);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_v7_checkpoint_restores_under_v8_only_with_the_opt_in_and_v6_still_does() {
|
||||
let new = with_adapter("pokered-unique8-v8");
|
||||
let migrates = crate::pokemon_red::MIGRATES_FROM;
|
||||
for from in ["pokered-unique8-v7", "pokered-unique8-v6"] {
|
||||
let old = with_adapter(from);
|
||||
assert!(matches!(decide(&old, &new, migrates, &[]), RestoreDecision::Refuse(_)));
|
||||
assert_eq!(
|
||||
decide(&old, &new, migrates, &accepted_adapters(Some(from))),
|
||||
RestoreDecision::MigrateAdapter { from: from.to_string() }
|
||||
);
|
||||
}
|
||||
// Naming v7 does not wave a v6 checkpoint through, nor v5 at all.
|
||||
assert!(matches!(
|
||||
decide(
|
||||
&with_adapter("pokered-unique8-v6"),
|
||||
&new,
|
||||
migrates,
|
||||
&accepted_adapters(Some("pokered-unique8-v7"))
|
||||
),
|
||||
RestoreDecision::Refuse(_)
|
||||
));
|
||||
assert!(matches!(
|
||||
decide(
|
||||
&with_adapter("pokered-unique8-v5"),
|
||||
&new,
|
||||
migrates,
|
||||
&accepted_adapters(Some("pokered-unique8-v5"))
|
||||
),
|
||||
RestoreDecision::Refuse(_)
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_v6_checkpoint_restores_under_v7_only_with_the_opt_in() {
|
||||
let old = with_adapter("pokered-unique8-v6");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//! The `pokered-unique8-v7` reward catalog.
|
||||
//! The `pokered-unique8-v8` reward catalog.
|
||||
//!
|
||||
//! A direct port of the prototype's `src/reward/catalog.ts`, including the
|
||||
//! declaration order, which is the order `counts` and `last` serialize in.
|
||||
|
|
@ -23,6 +23,7 @@ pub mod kind {
|
|||
pub const CATCH: &str = "catch";
|
||||
pub const TALK: &str = "talk";
|
||||
pub const ITEM: &str = "item";
|
||||
pub const DAMAGE: &str = "damage";
|
||||
}
|
||||
|
||||
/// What a `catch` of a species this run has already caught pays.
|
||||
|
|
@ -46,7 +47,7 @@ pub struct RewardRule {
|
|||
pub stimulation_ms: u32,
|
||||
}
|
||||
|
||||
pub const REWARDS: [RewardRule; 11] = [
|
||||
pub const REWARDS: [RewardRule; 12] = [
|
||||
RewardRule {
|
||||
kind: kind::MILESTONE,
|
||||
label: "Story",
|
||||
|
|
@ -151,6 +152,22 @@ pub const REWARDS: [RewardRule; 11] = [
|
|||
value: 0.15,
|
||||
stimulation_ms: 120,
|
||||
},
|
||||
// The operator's decision of 2026-09-29: pay the fly for the HP its own attack removes from
|
||||
// the Pokémon it is fighting, so the move that deals damage is worth more than the one that
|
||||
// does not (row 67: TAIL WHIP 155, BUBBLE 23, TACKLE 0, 29 battles lost). Appended for the
|
||||
// same reason as every rule since `boundary`.
|
||||
//
|
||||
// The value is what one whole enemy Pokémon's max HP pays, paid in proportion as it goes;
|
||||
// `damage::KO_BONUS` adds 0.05 when the fly's hit knocks out a trainer's Pokémon, and
|
||||
// `damage::BATTLE_CAP` holds a battle to the 0.50 the `trainer` rule pays for winning one.
|
||||
// A wild battle is scaled 1, 1/2, 1/3 per (map, species, level) like the wild-KO rule.
|
||||
RewardRule {
|
||||
kind: kind::DAMAGE,
|
||||
label: "Damage",
|
||||
trigger: "HP the fly's own attack removed in battle, 0.20 per whole Pokémon; +0.05 a trainer's Pokémon knocked out; max 0.50 a battle; wild 1, 1/2, 1/3 per map/species/level",
|
||||
value: 0.20,
|
||||
stimulation_ms: 80,
|
||||
},
|
||||
];
|
||||
|
||||
/// Position of `kind` in [`REWARDS`], or `None` for an unknown kind. This is
|
||||
|
|
@ -260,6 +277,9 @@ mod tests {
|
|||
assert_eq!(rule(kind::TALK).unwrap().stimulation_ms, 100);
|
||||
assert_eq!(rule(kind::ITEM).unwrap().value, 0.15);
|
||||
assert_eq!(rule(kind::ITEM).unwrap().stimulation_ms, 120);
|
||||
// Nor this: the operator's damage rule, `pokered-unique8-v8`.
|
||||
assert_eq!(rule(kind::DAMAGE).unwrap().value, 0.20);
|
||||
assert_eq!(rule(kind::DAMAGE).unwrap().stimulation_ms, 80);
|
||||
assert!(rule("blackout").is_none(), "the catalog has no penalties");
|
||||
assert!(REWARDS.iter().all(|rule| rule.value > 0.0));
|
||||
}
|
||||
|
|
@ -281,9 +301,10 @@ mod tests {
|
|||
kind::CATCH,
|
||||
kind::TALK,
|
||||
kind::ITEM,
|
||||
kind::DAMAGE,
|
||||
]
|
||||
);
|
||||
assert_eq!(index(kind::ITEM), Some(REWARDS.len() - 1));
|
||||
assert_eq!(index(kind::DAMAGE), Some(REWARDS.len() - 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
447
services/flysim/crates/flybrain-gb/src/pokemon_red/damage.rs
Normal file
447
services/flysim/crates/flybrain-gb/src/pokemon_red/damage.rs
Normal file
|
|
@ -0,0 +1,447 @@
|
|||
//! What the damage rule of `pokered-unique8-v8` reads: HP the fly's own attack removed from the
|
||||
//! Pokémon it is fighting.
|
||||
//!
|
||||
//! The operator's decision of 2026-09-29 (`docs/rewards-learning.md`, "Damage rewards"), chosen
|
||||
//! over a pad rule that would have withheld a stat move once it had been used. Row 67
|
||||
//! (`infra/docs/macros-traps.md`) is the reason: the live fly lost the Pewter Gym's Jr. Trainer 29
|
||||
//! times running with TAIL WHIP 155, BUBBLE 23, TACKLE 0, and nothing in the catalog paid for
|
||||
//! anything that happened inside a battle it did not win. This rule pays for the attack that lands,
|
||||
//! so the move that deals damage is worth more than the one that does not, in the battle where the
|
||||
//! choice is made.
|
||||
//!
|
||||
//! Everything here is a read of game memory after a frame. Nothing chooses, biases or presses a
|
||||
//! button: which moves are on the pad is still the scene's (`docs/design/macros.md`), and which one
|
||||
//! is pressed is still the fly's.
|
||||
//!
|
||||
//! ## What counts as the fly's attack
|
||||
//!
|
||||
//! A drop in `wEnemyMonHP` on a sample where `hWhoseTurn` reads 0 (the player's side is acting)
|
||||
//! and `wPlayerMoveNum` is not `STRUGGLE`. At the pinned commit (`engine/battle/core.asm`):
|
||||
//!
|
||||
//! - `ApplyDamageToEnemyPokemon` subtracts `wDamage` from `wEnemyMonHP` inside
|
||||
//! `ExecutePlayerMove`, with `hWhoseTurn` 0. Multi-hit moves subtract once per hit.
|
||||
//! - the enemy's poison and burn ticks and a Leech Seed on the enemy are
|
||||
//! `HandlePoisonBurnLeechSeed`, which picks the enemy's HP *because* `hWhoseTurn` is 1;
|
||||
//! the enemy's recoil, its confusion self-hit, its own Explosion and a Substitute it makes
|
||||
//! all happen in `ExecuteEnemyMove`, with `hWhoseTurn` 1. None of them pays.
|
||||
//! - a Leech Seed on the *player* heals the enemy on the player's turn: HP goes up, which never
|
||||
//! pays (below). Damage into an enemy Substitute is `AttackSubstitute`, which never touches
|
||||
//! `wEnemyMonHP`.
|
||||
//! - `STRUGGLE` is the move the cartridge executes for a Pokémon with no PP. The fly chose FIGHT,
|
||||
//! not the move, so it is not paid for; winning still pays what winning pays.
|
||||
//!
|
||||
//! ## What cannot be farmed
|
||||
//!
|
||||
//! - **Heal.** Each target keeps its lowest HP this battle; only HP below that pays. A Potion,
|
||||
//! Recover, Rest or a drain lifts the HP and the same HP is not paid twice.
|
||||
//! - **Switch.** A target is `(wEnemyMonPartyPos, species, level)`, so a trainer's Pokémon that
|
||||
//! goes out and comes back keeps its mark, and two Weedles of one level are two targets. A
|
||||
//! target is marked the first time it reads full HP, which is how every enemy Pokémon enters a
|
||||
//! battle in this game, so a stale `wEnemyMon` left over from the last battle neither pays nor
|
||||
//! hides the real Pokémon's first hit.
|
||||
//! - **The battle.** At most [`BATTLE_CAP`] a battle, whatever the party size.
|
||||
//! - **Wild Pokémon.** A wild battle pays at the scale the wild-KO rule uses -- 1, 1/2, 1/3 --
|
||||
//! for its first three battles per `(map, species, level)` that paid any damage, and nothing
|
||||
//! after, and a rollback blocks every key that has paid. Trainer battles have no such ledger:
|
||||
//! a trainer is only fought again after losing to it (or a rollback), and the per-battle cap
|
||||
//! bounds each of those.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::adapter::MemoryReader;
|
||||
|
||||
use super::state::poke;
|
||||
use super::symbols::ram;
|
||||
|
||||
/// What a trainer's Pokémon knocked out by the fly's own hit adds to that hit.
|
||||
///
|
||||
/// The damage share of the knockout hit is already paid; this is the step "one of the trainer's
|
||||
/// Pokémon is down", on the frame it happens. Trainer battles only: a wild knockout is the
|
||||
/// `battle` rule's, paid on the way out of the battle.
|
||||
pub const KO_BONUS: f64 = 0.05;
|
||||
|
||||
/// The most damage pays in one battle: the `trainer` rule's own 0.50, so that a battle's worth
|
||||
/// of damage is worth what winning it is. The Pewter Gym's Jr. Trainer (two Pokémon) reaches it
|
||||
/// exactly: 2 x (0.20 + 0.05).
|
||||
pub const BATTLE_CAP: f64 = 0.50;
|
||||
|
||||
/// Wild battles per `(map, species, level)` that may pay damage, for the lifetime of the ledger:
|
||||
/// the wild-KO rule's three, for the same reason.
|
||||
pub const MAX_WILD_BATTLES: u64 = 3;
|
||||
|
||||
/// The sanity bound the adapter already applies to an enemy's max HP (`sample`'s wild-KO read):
|
||||
/// the largest in the game is under 1000, so anything else is a byte read out of a battle that
|
||||
/// is not set up yet.
|
||||
const MAX_HP_BOUND: u16 = 1000;
|
||||
|
||||
/// One enemy Pokémon, as far as a battle can tell them apart.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Target {
|
||||
/// `wEnemyMonPartyPos`: the enemy party slot (`$ff` before a trainer's first send-out).
|
||||
pub slot: u8,
|
||||
pub species: u8,
|
||||
pub level: u8,
|
||||
}
|
||||
|
||||
/// The bytes one sample reads for the rule.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Reading {
|
||||
pub target: Target,
|
||||
pub hp: u16,
|
||||
pub max_hp: u16,
|
||||
/// `hWhoseTurn` reads 0.
|
||||
pub fly_turn: bool,
|
||||
/// `wPlayerMoveNum`.
|
||||
pub move_id: u8,
|
||||
}
|
||||
|
||||
impl Reading {
|
||||
/// Read one sample, or `None` when the enemy's HP is not a readable HP: a max of 0 or past
|
||||
/// [`MAX_HP_BOUND`], or a current HP above the max -- which is also what the one torn read
|
||||
/// possible here looks like, `ApplyDamageToEnemyPokemon`'s `sbc` having wrapped below zero
|
||||
/// before it clamps.
|
||||
pub fn read(memory: &mut impl MemoryReader) -> Option<Self> {
|
||||
let hp = word(memory, ram::wEnemyMonHP);
|
||||
let max_hp = word(memory, ram::wEnemyMonMaxHP);
|
||||
if max_hp == 0 || max_hp >= MAX_HP_BOUND || hp > max_hp {
|
||||
return None;
|
||||
}
|
||||
Some(Self {
|
||||
target: Target {
|
||||
slot: memory.read8(ram::wEnemyMonPartyPos),
|
||||
species: memory.read8(ram::wEnemyMonSpecies),
|
||||
level: memory.read8(ram::wEnemyMonLevel),
|
||||
},
|
||||
hp,
|
||||
max_hp,
|
||||
fly_turn: memory.read8(poke::H_WHOSE_TURN) == 0,
|
||||
move_id: memory.read8(ram::wPlayerMoveNum),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn word(memory: &mut impl MemoryReader, address: u16) -> u16 {
|
||||
u16::from(memory.read8(address)) << 8 | u16::from(memory.read8(address + 1))
|
||||
}
|
||||
|
||||
/// HP the fly's own attack removed on one sample.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct Hit {
|
||||
pub target: Target,
|
||||
pub removed: u16,
|
||||
pub max_hp: u16,
|
||||
pub knocked_out: bool,
|
||||
}
|
||||
|
||||
/// One target's mark: its max HP when first seen and the lowest HP it has shown.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
struct Mark {
|
||||
target: Target,
|
||||
max_hp: u16,
|
||||
low: u16,
|
||||
}
|
||||
|
||||
/// The rule's state for one battle. Carried in the adapter's `battle` (and so in a checkpoint
|
||||
/// taken mid-battle); a new battle starts with a new one.
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct BattleDamage {
|
||||
marks: Vec<Mark>,
|
||||
/// Paid so far this battle, after the wild scale.
|
||||
paid: f64,
|
||||
/// The wild scale, decided at the battle's first hit; always 1 in a trainer battle.
|
||||
scale: Option<f64>,
|
||||
/// A battle restored from a state written before this rule: a target first seen is marked
|
||||
/// at the HP it has *now*, since what it had lost before the restore is unknown.
|
||||
restored: bool,
|
||||
}
|
||||
|
||||
impl BattleDamage {
|
||||
/// The state for a battle a `v7` checkpoint was taken in.
|
||||
pub fn restored() -> Self {
|
||||
Self { restored: true, ..Self::default() }
|
||||
}
|
||||
|
||||
pub fn paid(&self) -> f64 {
|
||||
self.paid
|
||||
}
|
||||
|
||||
pub fn scale(&self) -> Option<f64> {
|
||||
self.scale
|
||||
}
|
||||
|
||||
/// Update the marks with one sample and say what the fly is owed for, if anything.
|
||||
///
|
||||
/// Every drop moves the mark, whoever caused it, so a poison tick is never paid later as
|
||||
/// part of the fly's next hit. Only a drop on the fly's own turn, by a move it chose, is a
|
||||
/// [`Hit`].
|
||||
pub fn observe(&mut self, reading: Reading) -> Option<Hit> {
|
||||
let index = match self.marks.iter().position(|mark| mark.target == reading.target) {
|
||||
Some(index) if self.marks[index].max_hp == reading.max_hp => index,
|
||||
found => {
|
||||
// Every enemy Pokémon enters a battle at its max HP -- a wild one is generated
|
||||
// full, a trainer's party is built full -- so a target not yet marked is only
|
||||
// real once it reads full. Anything else is `wEnemyMon` still holding the last
|
||||
// battle's Pokémon: `InitBattleVariables` does not clear it, and a trainer
|
||||
// battle sets `wIsInBattle` a whole transition before `LoadEnemyMonData` runs.
|
||||
// In the row 67 ring that stale Pokémon is the same trainer's, in the same
|
||||
// slot, at the HP it beat the fly with. A battle restored from a state without
|
||||
// this rule cannot know, and marks what it reads.
|
||||
if !self.restored && reading.hp != reading.max_hp {
|
||||
return None;
|
||||
}
|
||||
let mark =
|
||||
Mark { target: reading.target, max_hp: reading.max_hp, low: reading.hp };
|
||||
match found {
|
||||
// The same slot, species and level with another max HP is another Pokémon
|
||||
// (a wild one with other DVs): its mark starts again.
|
||||
Some(index) => {
|
||||
self.marks[index] = mark;
|
||||
index
|
||||
}
|
||||
None => {
|
||||
self.marks.push(mark);
|
||||
self.marks.len() - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let mark = &mut self.marks[index];
|
||||
if reading.hp >= mark.low {
|
||||
return None;
|
||||
}
|
||||
let removed = mark.low - reading.hp;
|
||||
mark.low = reading.hp;
|
||||
if !reading.fly_turn || reading.move_id == poke::moves::STRUGGLE {
|
||||
return None;
|
||||
}
|
||||
Some(Hit {
|
||||
target: reading.target,
|
||||
removed,
|
||||
max_hp: reading.max_hp,
|
||||
knocked_out: reading.hp == 0,
|
||||
})
|
||||
}
|
||||
|
||||
/// Decide the wild scale once per battle. `ledger` is `(battles already paid for this key,
|
||||
/// whether a rollback blocked it)`; the caller counts the battle when this returns a
|
||||
/// non-zero scale for the first time.
|
||||
pub fn decide_scale(&mut self, trainer: bool, ledger: (u64, bool)) -> (f64, bool) {
|
||||
if let Some(scale) = self.scale {
|
||||
return (scale, false);
|
||||
}
|
||||
let (count, blocked) = ledger;
|
||||
let scale = if trainer {
|
||||
1.0
|
||||
} else if blocked || count >= MAX_WILD_BATTLES {
|
||||
0.0
|
||||
} else {
|
||||
1.0 / (count as f64 + 1.0)
|
||||
};
|
||||
self.scale = Some(scale);
|
||||
(scale, !trainer && scale > 0.0)
|
||||
}
|
||||
|
||||
/// What `hit` pays: `value` per whole Pokémon's max HP, plus [`KO_BONUS`] for a trainer's
|
||||
/// Pokémon knocked out, at the battle's scale, within what is left of [`BATTLE_CAP`].
|
||||
pub fn pay(&mut self, hit: Hit, value: f64, trainer: bool) -> f64 {
|
||||
let scale = self.scale.unwrap_or(0.0);
|
||||
let mut amount = value * f64::from(hit.removed) / f64::from(hit.max_hp);
|
||||
if trainer && hit.knocked_out {
|
||||
amount += KO_BONUS;
|
||||
}
|
||||
let amount = (amount * scale).min((BATTLE_CAP - self.paid).max(0.0));
|
||||
self.paid += amount;
|
||||
amount
|
||||
}
|
||||
|
||||
pub fn to_json(&self) -> Value {
|
||||
json!({
|
||||
"paid": self.paid,
|
||||
"scale": self.scale,
|
||||
"restored": self.restored,
|
||||
"marks": self.marks.iter().map(|mark| json!([
|
||||
mark.target.slot, mark.target.species, mark.target.level, mark.max_hp, mark.low,
|
||||
])).collect::<Vec<_>>(),
|
||||
})
|
||||
}
|
||||
|
||||
/// The inverse of [`BattleDamage::to_json`]; `None` for anything malformed.
|
||||
pub fn from_json(value: &Value) -> Option<Self> {
|
||||
let paid = value.get("paid")?.as_f64().filter(|paid| paid.is_finite() && *paid >= 0.0)?;
|
||||
let scale = match value.get("scale") {
|
||||
None | Some(Value::Null) => None,
|
||||
Some(scale) => Some(scale.as_f64().filter(|scale| (0.0..=1.0).contains(scale))?),
|
||||
};
|
||||
let restored = value.get("restored")?.as_bool()?;
|
||||
let byte = |value: &Value| value.as_u64().and_then(|v| u8::try_from(v).ok());
|
||||
let hp = |value: &Value| value.as_u64().and_then(|v| u16::try_from(v).ok());
|
||||
let marks = value
|
||||
.get("marks")?
|
||||
.as_array()?
|
||||
.iter()
|
||||
.map(|mark| {
|
||||
let mark = mark.as_array().filter(|mark| mark.len() == 5)?;
|
||||
Some(Mark {
|
||||
target: Target {
|
||||
slot: byte(&mark[0])?,
|
||||
species: byte(&mark[1])?,
|
||||
level: byte(&mark[2])?,
|
||||
},
|
||||
max_hp: hp(&mark[3])?,
|
||||
low: hp(&mark[4])?,
|
||||
})
|
||||
})
|
||||
.collect::<Option<Vec<_>>>()?;
|
||||
Some(Self { marks, paid, scale, restored })
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
const DIGLETT: Target = Target { slot: 0, species: 0x3b, level: 11 };
|
||||
const SANDSHREW: Target = Target { slot: 1, species: 0x60, level: 11 };
|
||||
const BUBBLE: u8 = 145;
|
||||
const TACKLE: u8 = 33;
|
||||
|
||||
fn fly(target: Target, hp: u16, max_hp: u16, move_id: u8) -> Reading {
|
||||
Reading { target, hp, max_hp, fly_turn: true, move_id }
|
||||
}
|
||||
|
||||
fn enemy(target: Target, hp: u16, max_hp: u16) -> Reading {
|
||||
Reading { target, hp, max_hp, fly_turn: false, move_id: BUBBLE }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_drop_on_the_flys_turn_is_a_hit_and_one_on_the_enemys_is_not() {
|
||||
let mut battle = BattleDamage::default();
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 31, 31, BUBBLE)), None, "full HP is the mark");
|
||||
let hit = battle.observe(fly(DIGLETT, 20, 31, BUBBLE)).unwrap();
|
||||
assert_eq!((hit.removed, hit.knocked_out), (11, false));
|
||||
// The enemy's own poison tick: the mark moves, nothing is owed.
|
||||
assert_eq!(battle.observe(enemy(DIGLETT, 18, 31)), None);
|
||||
// ... so the next hit is paid from 18, not from 20.
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 12, 31, TACKLE)).unwrap().removed, 6);
|
||||
// The same HP on the next sample is not a second hit.
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 12, 31, TACKLE)), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn struggle_is_not_the_flys_choice_and_pays_nothing() {
|
||||
let mut battle = BattleDamage::default();
|
||||
battle.observe(fly(DIGLETT, 31, 31, BUBBLE));
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 25, 31, poke::moves::STRUGGLE)), None);
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 20, 31, BUBBLE)).unwrap().removed, 5);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn healed_hp_is_not_paid_twice() {
|
||||
let mut battle = BattleDamage::default();
|
||||
battle.observe(fly(DIGLETT, 31, 31, BUBBLE));
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 10, 31, BUBBLE)).unwrap().removed, 21);
|
||||
// A Super Potion on the trainer's turn, or a drain on the fly's: up is never paid.
|
||||
assert_eq!(battle.observe(enemy(DIGLETT, 31, 31)), None);
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 31, 31, BUBBLE)), None);
|
||||
// Down to 15 again is ground already paid for; 15 to 4 is new.
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 15, 31, BUBBLE)), None);
|
||||
let hit = battle.observe(fly(DIGLETT, 0, 31, BUBBLE)).unwrap();
|
||||
assert_eq!((hit.removed, hit.knocked_out), (10, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_switch_keeps_each_targets_mark() {
|
||||
let mut battle = BattleDamage::default();
|
||||
battle.observe(fly(DIGLETT, 31, 31, BUBBLE));
|
||||
battle.observe(fly(DIGLETT, 16, 31, BUBBLE));
|
||||
// Sandshrew comes out: a new target, marked at its max.
|
||||
assert_eq!(battle.observe(enemy(SANDSHREW, 33, 33)), None);
|
||||
assert_eq!(battle.observe(fly(SANDSHREW, 30, 33, TACKLE)).unwrap().removed, 3);
|
||||
// Diglett comes back at the 16 it left with: nothing new until it goes below.
|
||||
assert_eq!(battle.observe(enemy(DIGLETT, 16, 31)), None);
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 10, 31, BUBBLE)).unwrap().removed, 6);
|
||||
// Two Pokémon of one species and level in different slots are two targets.
|
||||
let twin = Target { slot: 2, ..DIGLETT };
|
||||
assert_eq!(battle.observe(enemy(twin, 31, 31)), None);
|
||||
assert_eq!(battle.observe(fly(twin, 21, 31, BUBBLE)).unwrap().removed, 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_stale_enemy_from_the_last_battle_cannot_pay_or_hide_the_real_one() {
|
||||
// The first in-battle samples can still hold the last battle's Pokémon at the HP it
|
||||
// finished on -- in the row 67 ring, the same trainer's Diglett in the same slot. It is
|
||||
// not marked until it reads full, so neither it nor the real Diglett's first hit is lost.
|
||||
let mut battle = BattleDamage::default();
|
||||
assert_eq!(battle.observe(enemy(DIGLETT, 7, 31)), None);
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 3, 31, BUBBLE)), None, "not marked: not paid");
|
||||
assert_eq!(battle.observe(enemy(DIGLETT, 31, 31)), None, "the real one loads full");
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 20, 31, BUBBLE)).unwrap().removed, 11);
|
||||
// The same identity with another max HP is another Pokémon: its mark starts again.
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 29, 29, BUBBLE)), None);
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 19, 29, BUBBLE)).unwrap().removed, 10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_battle_restored_without_the_rule_marks_targets_where_they_stand() {
|
||||
let mut battle = BattleDamage::restored();
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 12, 31, BUBBLE)), None, "12/31 is the mark");
|
||||
assert_eq!(battle.observe(fly(DIGLETT, 5, 31, BUBBLE)).unwrap().removed, 7);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_trainer_battle_pays_the_share_plus_the_knockout_and_stops_at_the_cap() {
|
||||
let mut battle = BattleDamage::default();
|
||||
assert_eq!(battle.decide_scale(true, (99, true)), (1.0, false), "no ledger for trainers");
|
||||
let value = 0.20;
|
||||
battle.observe(fly(DIGLETT, 31, 31, BUBBLE));
|
||||
let hit = battle.observe(fly(DIGLETT, 0, 31, BUBBLE)).unwrap();
|
||||
assert!((battle.pay(hit, value, true) - 0.25).abs() < 1e-12, "0.20 + the 0.05 knockout");
|
||||
battle.observe(fly(SANDSHREW, 33, 33, BUBBLE));
|
||||
let hit = battle.observe(fly(SANDSHREW, 0, 33, BUBBLE)).unwrap();
|
||||
assert!((battle.pay(hit, value, true) - 0.25).abs() < 1e-12);
|
||||
assert!((battle.paid() - BATTLE_CAP).abs() < 1e-12, "two Pokémon reach the cap");
|
||||
let third = Target { slot: 2, ..SANDSHREW };
|
||||
battle.observe(fly(third, 33, 33, BUBBLE));
|
||||
let hit = battle.observe(fly(third, 0, 33, BUBBLE)).unwrap();
|
||||
assert_eq!(battle.pay(hit, value, true), 0.0, "a third pays nothing");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wild_battle_pays_one_half_one_third_then_nothing() {
|
||||
let value = 0.20;
|
||||
let mut paid = Vec::new();
|
||||
for count in 0..4 {
|
||||
let mut battle = BattleDamage::default();
|
||||
let (scale, counted) = battle.decide_scale(false, (count, false));
|
||||
assert_eq!(counted, count < MAX_WILD_BATTLES);
|
||||
battle.observe(fly(DIGLETT, 31, 31, TACKLE));
|
||||
let hit = battle.observe(fly(DIGLETT, 0, 31, TACKLE)).unwrap();
|
||||
paid.push(battle.pay(hit, value, false));
|
||||
assert_eq!(battle.decide_scale(false, (0, false)).0, scale, "decided once a battle");
|
||||
}
|
||||
assert!((paid[0] - 0.20).abs() < 1e-12, "no knockout bonus in the wild: {paid:?}");
|
||||
assert!((paid[1] - 0.10).abs() < 1e-12);
|
||||
assert!((paid[2] - 0.20 / 3.0).abs() < 1e-12);
|
||||
assert_eq!(paid[3], 0.0);
|
||||
let mut blocked = BattleDamage::default();
|
||||
assert_eq!(blocked.decide_scale(false, (0, true)), (0.0, false), "a rollback blocks it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_battle_state_round_trips() {
|
||||
let mut battle = BattleDamage::default();
|
||||
battle.decide_scale(false, (1, false));
|
||||
battle.observe(fly(DIGLETT, 31, 31, BUBBLE));
|
||||
let hit = battle.observe(fly(DIGLETT, 20, 31, BUBBLE)).unwrap();
|
||||
battle.pay(hit, 0.2, false);
|
||||
let back = BattleDamage::from_json(&battle.to_json()).unwrap();
|
||||
assert_eq!(back, battle);
|
||||
assert!(BattleDamage::from_json(&json!({ "paid": -1.0 })).is_none());
|
||||
assert!(
|
||||
BattleDamage::from_json(&json!({
|
||||
"paid": 0.0, "scale": null, "restored": false, "marks": [[0, 1, 2, 3]]
|
||||
}))
|
||||
.is_none()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//! The Pokémon Red reward adapter, `pokered-unique8-v7`.
|
||||
//! The Pokémon Red reward adapter, `pokered-unique8-v8`.
|
||||
//!
|
||||
//! A port of the prototype's `src/reward/pokemon-red.ts`. The gates and budgets
|
||||
//! are unchanged; `docs/rewards-learning.md` holds the live rule table and the
|
||||
|
|
@ -8,9 +8,11 @@
|
|||
//! next to and the first step onto each of a map's exits; v6 adds `catch`, the
|
||||
//! operator's decision of 2026-09-22, which pays for keeping a wild Pokémon; v7 adds
|
||||
//! `talk` and `item` and stops `boundary` paying indoors, the operator's decision of
|
||||
//! 2026-09-23 to pay for engaging with a building rather than for leaving it.
|
||||
//! 2026-09-23 to pay for engaging with a building rather than for leaving it; v8 adds `damage`,
|
||||
//! the operator's decision of 2026-09-29 to pay for the HP the fly's own attack removes.
|
||||
|
||||
pub mod catalog;
|
||||
pub mod damage;
|
||||
pub mod engage;
|
||||
#[cfg(test)]
|
||||
pub(crate) mod fake_wram;
|
||||
|
|
@ -36,7 +38,15 @@ use symbols::ram;
|
|||
|
||||
/// Adapter version, pinned into the checkpoint compatibility string.
|
||||
///
|
||||
/// `v7` is the engagement rules: `talk` and `item` pay, and `boundary` stops paying on an
|
||||
/// `v8` is the damage rule (the operator, 2026-09-29): HP the fly's own attack removes from the
|
||||
/// Pokémon it is fighting pays, in proportion, within a per-battle cap ([`damage`]). A `v7`
|
||||
/// checkpoint is refused by default and resumed only when the operator names it in
|
||||
/// `FLY_ACCEPT_ADAPTERS`, like every migration before it. `v7`'s state is a `v8` state with no
|
||||
/// `damageCounts` (no wild key has paid damage) and, for a battle in flight, no per-battle damage
|
||||
/// state: that battle marks each enemy Pokémon at the HP it has when first read, so nothing lost
|
||||
/// before the restore is paid ([`damage::BattleDamage::restored`]).
|
||||
///
|
||||
/// `v7` was the engagement rules: `talk` and `item` pay, and `boundary` stops paying on an
|
||||
/// indoor map (the operator, 2026-09-23). Bumping it is what makes a `v6` checkpoint a
|
||||
/// decision rather than an accident: the compatibility string is compared whole before a
|
||||
/// restore is attempted, so a `v6` run is refused by default and resumed only when the
|
||||
|
|
@ -53,11 +63,17 @@ use symbols::ram;
|
|||
/// that meant "4 badges" on the old ladder is not a rung on the new one. Neither of
|
||||
/// those is a migration; the last two are, because nothing an older ledger holds means
|
||||
/// something different under the newer rules.)
|
||||
pub const REWARD_ADAPTER: &str = "pokered-unique8-v7";
|
||||
pub const REWARD_ADAPTER: &str = "pokered-unique8-v8";
|
||||
|
||||
/// Adapter ids whose checkpoints `v7` can read.
|
||||
/// Adapter ids whose checkpoints `v8` can read.
|
||||
///
|
||||
/// Exactly one, and it is one because the engagement rules add ledger keys and change nothing
|
||||
/// `v7`, the live run's, by the migration [`REWARD_ADAPTER`] describes. And still `v6`: the
|
||||
/// chain composes, because nothing in `v8` reads a key `v7` wrote that a `v6` state lacks other
|
||||
/// than the ones `v7`'s own migration already handles in this build -- the item seed runs on the
|
||||
/// first sample that finds `items:seeded` absent, and the damage state starts empty either way.
|
||||
/// `compat_migration.rs` restores a `v6` envelope and a `v7` envelope under this build.
|
||||
///
|
||||
/// (For `v7` the list was `v6` alone, and the reason it was one:) the engagement rules add ledger keys and change nothing
|
||||
/// else a `v6` state holds: every field keeps its name, shape and meaning, the `talk:` keys start
|
||||
/// empty (no conversation was ever paid), and the `item:`/`hidden:` keys are seeded from the
|
||||
/// game's own flags on the first sample, so no pickup made under `v6` pays when a rollback
|
||||
|
|
@ -68,7 +84,7 @@ pub const REWARD_ADAPTER: &str = "pokered-unique8-v7";
|
|||
///
|
||||
/// Listing an id here is necessary but not sufficient: `FLY_ACCEPT_ADAPTERS` must name it too
|
||||
/// (`crate::compatibility::decide`, `docs/design/flysim.md`).
|
||||
pub const MIGRATES_FROM: &[&str] = &["pokered-unique8-v6"];
|
||||
pub const MIGRATES_FROM: &[&str] = &["pokered-unique8-v7", "pokered-unique8-v6"];
|
||||
|
||||
/// The only cartridge semantic rewards are enabled for. Even the canonical
|
||||
/// pret build stays disabled until reviewed; see `docs/rewards-learning.md`.
|
||||
|
|
@ -102,6 +118,11 @@ pub const SUPPORTED_ROM: &str =
|
|||
/// *Not* bumped for the engagement rules either. `talk` and `item` key their payouts into the
|
||||
/// existing `seen` array, the way `boundary` did, and the item seed is marked there too
|
||||
/// ([`ITEMS_SEEDED`]); a `v6` state is structurally a `v7` state with none of those keys.
|
||||
///
|
||||
/// *Not* bumped for the damage rule. It adds one optional counter, `damageCounts`, and one
|
||||
/// optional object inside a battle in flight, `battle.damage`; a `v7` state without them restores
|
||||
/// with the counter empty and the battle marked where it stands, which is the truth about a run
|
||||
/// that was never paid for damage.
|
||||
pub const STATE_VERSION: u64 = 4;
|
||||
|
||||
/// The `seen` key that says the item keys have been seeded from the cartridge's flags.
|
||||
|
|
@ -374,7 +395,7 @@ fn rung_place(seen: &OrderedSet, rung: usize) -> Option<MapPlace> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
struct Battle {
|
||||
key: String,
|
||||
wild: bool,
|
||||
|
|
@ -400,6 +421,8 @@ struct Battle {
|
|||
/// Whether that catch was a species this run had never owned, decided on the frame
|
||||
/// the capture was observed.
|
||||
captured_new: bool,
|
||||
/// The damage rule's marks and what this battle has paid ([`damage::BattleDamage`]).
|
||||
damage: damage::BattleDamage,
|
||||
}
|
||||
|
||||
/// Immutable per-sample byte cache. Each address requested during one sample
|
||||
|
|
@ -449,6 +472,9 @@ pub struct PokemonRedReward {
|
|||
/// string. The one field `v6` adds to the checkpoint; absent in a `v5` state, which
|
||||
/// reads as every species at zero.
|
||||
catch_counts: BTreeMap<String, u64>,
|
||||
/// Wild battles that paid damage, per wild key (`map:species:level`, the wild-KO rule's). The
|
||||
/// one field `v8` adds to the checkpoint; absent in a `v7` state, which reads as none.
|
||||
damage_counts: BTreeMap<String, u64>,
|
||||
replay_blocked: OrderedSet,
|
||||
counts: Counts,
|
||||
total: f64,
|
||||
|
|
@ -507,6 +533,7 @@ impl PokemonRedReward {
|
|||
tile_counts: BTreeMap::new(),
|
||||
wild_wins: BTreeMap::new(),
|
||||
catch_counts: BTreeMap::new(),
|
||||
damage_counts: BTreeMap::new(),
|
||||
replay_blocked: OrderedSet::new(),
|
||||
counts: Counts::default(),
|
||||
total: 0.0,
|
||||
|
|
@ -676,6 +703,10 @@ impl PokemonRedReward {
|
|||
for species in caught {
|
||||
self.replay_blocked.insert(&format!("catch:{species}"));
|
||||
}
|
||||
let damaged: Vec<String> = self.damage_counts.keys().cloned().collect();
|
||||
for key in damaged {
|
||||
self.replay_blocked.insert(&format!("damage:{key}"));
|
||||
}
|
||||
}
|
||||
|
||||
/// Sample WRAM after one completed frame and return this frame's payouts.
|
||||
|
|
@ -800,6 +831,7 @@ impl PokemonRedReward {
|
|||
species_at_start: Some(species_paid),
|
||||
captured: None,
|
||||
captured_new: false,
|
||||
damage: damage::BattleDamage::default(),
|
||||
});
|
||||
}
|
||||
// The cartridge's own answer to "was one caught": `ram/wram.asm`'s comment on
|
||||
|
|
@ -831,6 +863,9 @@ impl PokemonRedReward {
|
|||
battle.species_at_start.is_some_and(|before| species_paid > before);
|
||||
}
|
||||
}
|
||||
if in_battle != 255 {
|
||||
self.damage(&mut emitted, memory, in_battle == 2, brain_ms);
|
||||
}
|
||||
} else if in_battle == 0 {
|
||||
self.mode = "OVERWORLD".to_string();
|
||||
if let Some(battle) = self.battle.take() {
|
||||
|
|
@ -985,6 +1020,39 @@ impl PokemonRedReward {
|
|||
emitted
|
||||
}
|
||||
|
||||
/// The damage rule (`docs/rewards-learning.md`, the operator 2026-09-29): pay for the HP the
|
||||
/// fly's own attack removed from the enemy on this sample. [`damage`] says what counts.
|
||||
fn damage(
|
||||
&mut self,
|
||||
emitted: &mut Vec<RewardEvent>,
|
||||
memory: &mut impl MemoryReader,
|
||||
trainer: bool,
|
||||
brain_ms: f64,
|
||||
) {
|
||||
let Some(reading) = damage::Reading::read(memory) else { return };
|
||||
let Some(battle) = self.battle.as_mut() else { return };
|
||||
let Some(hit) = battle.damage.observe(reading) else { return };
|
||||
let key = battle.key.clone();
|
||||
let count = self.damage_counts.get(&key).copied().unwrap_or(0);
|
||||
let blocked = self.replay_blocked.contains(&format!("damage:{key}"));
|
||||
let (_, counted) = battle.damage.decide_scale(trainer, (count, blocked));
|
||||
let value = catalog::rule(kind::DAMAGE).expect("the damage rule is in the catalog").value;
|
||||
let amount = battle.damage.pay(hit, value, trainer);
|
||||
if counted {
|
||||
self.damage_counts.insert(key, (count + 1).min(damage::MAX_WILD_BATTLES));
|
||||
}
|
||||
if amount > 0.0 {
|
||||
let knocked_out = if hit.knocked_out { " KO" } else { "" };
|
||||
self.emit_amount(
|
||||
emitted,
|
||||
kind::DAMAGE,
|
||||
format!("HIT #{} FOR {} HP{knocked_out}", hit.target.species, hit.removed),
|
||||
amount,
|
||||
brain_ms,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn emit(
|
||||
&mut self,
|
||||
emitted: &mut Vec<RewardEvent>,
|
||||
|
|
@ -1220,6 +1288,8 @@ impl PokemonRedReward {
|
|||
// empty, which is the documented v5 -> v6 migration and the truth about a run
|
||||
// that was never paid for a catch.
|
||||
"catchCounts": self.catch_counts,
|
||||
// The one field v8 adds, absent in a v7 state for the same reason.
|
||||
"damageCounts": self.damage_counts,
|
||||
"replayBlocked": self.replay_blocked.as_slice(),
|
||||
"counts": self.counts,
|
||||
"total": self.total,
|
||||
|
|
@ -1243,6 +1313,7 @@ impl PokemonRedReward {
|
|||
"speciesAtStart": battle.species_at_start,
|
||||
"captured": battle.captured,
|
||||
"capturedNew": battle.captured_new,
|
||||
"damage": battle.damage.to_json(),
|
||||
})),
|
||||
"mode": self.mode,
|
||||
})
|
||||
|
|
@ -1295,6 +1366,11 @@ impl PokemonRedReward {
|
|||
None | Some(Value::Null) => BTreeMap::new(),
|
||||
Some(value) => counted_record(Some(value)).ok_or(BAD_CHECKPOINT)?,
|
||||
};
|
||||
// Absent in every v7 state: no wild key has paid damage, because the rule did not exist.
|
||||
let damage_counts = match input.get("damageCounts") {
|
||||
None | Some(Value::Null) => BTreeMap::new(),
|
||||
Some(value) => counted_record(Some(value)).ok_or(BAD_CHECKPOINT)?,
|
||||
};
|
||||
|
||||
let recent = recent_raw
|
||||
.iter()
|
||||
|
|
@ -1330,6 +1406,12 @@ impl PokemonRedReward {
|
|||
.get("capturedNew")
|
||||
.and_then(Value::as_bool)
|
||||
.unwrap_or(false),
|
||||
// v8's. A v7 battle has none, and marks each enemy Pokémon at the HP it reads
|
||||
// next rather than paying for HP lost before the restore.
|
||||
damage: match value.get("damage") {
|
||||
None | Some(Value::Null) => damage::BattleDamage::restored(),
|
||||
Some(state) => damage::BattleDamage::from_json(state).ok_or(BAD_HISTORY)?,
|
||||
},
|
||||
}),
|
||||
};
|
||||
let replay_blocked = match input.get("replayBlocked") {
|
||||
|
|
@ -1356,6 +1438,7 @@ impl PokemonRedReward {
|
|||
self.tile_counts = tile_counts;
|
||||
self.wild_wins = wild_wins_raw;
|
||||
self.catch_counts = catch_counts;
|
||||
self.damage_counts = damage_counts;
|
||||
self.replay_blocked = replay_blocked.iter().map(String::as_str).collect();
|
||||
self.counts = Counts::default();
|
||||
for (key, count) in &counts_raw {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,17 @@ pub mod poke {
|
|||
/// reads it back from there (row 63, `docs/design/macros.md` 12.27).
|
||||
pub const H_JOY_LAST: u16 = 0xffb1;
|
||||
|
||||
/// `ram/hram.asm`: `hWhoseTurn`, "0 on player's turn, 1 on enemy's turn". Counted from the
|
||||
/// `hJoyLast` anchor above through the declarations that follow it (each `UNION` at its
|
||||
/// largest member) to `$FFF3`; the section's remaining nine bytes then end at `$FFFE`, the
|
||||
/// last byte of HRAM, which is the check that the count is right. It is the classic
|
||||
/// `H_WHOSETURN`. The battle engine writes it before each side acts (`MainInBattleLoop`,
|
||||
/// `ExecutePlayerMove`), and `HandlePoisonBurnLeechSeed` reads it to pick whose HP to cut, so
|
||||
/// the enemy's poison, burn and Leech Seed ticks all land while it reads 1. Read by the damage
|
||||
/// reward (`docs/rewards-learning.md`) and pinned on the cartridge by
|
||||
/// `tests/rom_damage.rs`, which reads 0 on the frame BUBBLE lands.
|
||||
pub const H_WHOSE_TURN: u16 = 0xfff3;
|
||||
|
||||
pub mod pad {
|
||||
pub const A: u8 = 1 << 0;
|
||||
pub const B: u8 = 1 << 1;
|
||||
|
|
@ -285,6 +296,10 @@ pub mod poke {
|
|||
pub const ROW_BYTES: u16 = 6;
|
||||
/// `constants/move_constants.asm`: `NUM_ATTACKS`, `STRUGGLE` (`$a5`) the last.
|
||||
pub const LAST_MOVE: u8 = 0xa5;
|
||||
/// The same constant under its own name: the move the cartridge executes for a
|
||||
/// Pokémon whose moves have no PP left (`ExecutePlayerMove`'s caller, `MoveSelectionMenu`'s
|
||||
/// "has no moves left!"). The damage reward does not pay for it: the fly did not choose it.
|
||||
pub const STRUGGLE: u8 = 0xa5;
|
||||
|
||||
/// `constants/move_effect_constants.asm`: the stat-stage effects, each run in stage
|
||||
/// order ATTACK, DEFENSE, SPEED, SPECIAL, ACCURACY, EVASION.
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ pub mod ram {
|
|||
pub const wListMenuID: u16 = 0xcf94; // 53140
|
||||
pub const wFontLoaded: u16 = 0xcfc4; // 53188
|
||||
pub const wWalkCounter: u16 = 0xcfc5; // 53189
|
||||
pub const wPlayerMoveNum: u16 = 0xcfd2; // 53202
|
||||
pub const wEnemyMonSpecies: u16 = 0xcfe5; // 53221
|
||||
pub const wEnemyMonHP: u16 = 0xcfe6; // 53222
|
||||
pub const wEnemyMonPartyPos: u16 = 0xcfe8; // 53224
|
||||
pub const wEnemyMonStatus: u16 = 0xcfe9; // 53225
|
||||
pub const wEnemyMonType1: u16 = 0xcfea; // 53226
|
||||
pub const wEnemyMonLevel: u16 = 0xcff3; // 53235
|
||||
|
|
|
|||
|
|
@ -865,8 +865,8 @@ fn the_recent_ticker_keeps_the_newest_eight_events_newest_first() {
|
|||
#[test]
|
||||
fn the_adapter_reports_its_identity_and_pinned_rom() {
|
||||
let reward = PokemonRedReward::new();
|
||||
assert_eq!(reward.id(), "pokered-unique8-v7");
|
||||
assert_eq!(reward.migrates_from(), ["pokered-unique8-v6"]);
|
||||
assert_eq!(reward.id(), "pokered-unique8-v8");
|
||||
assert_eq!(reward.migrates_from(), ["pokered-unique8-v7", "pokered-unique8-v6"]);
|
||||
assert!(reward.rom_allowed(SUPPORTED_ROM));
|
||||
assert!(!reward.rom_allowed(
|
||||
"5ca7ba01642a3b27b0cc0b5349b52792795b62d3ed977e98a09390659af96b7b"
|
||||
|
|
@ -1894,3 +1894,272 @@ fn a_warp_is_classified_by_the_header_still_loaded_while_the_map_id_has_moved_on
|
|||
f.memory.set(ram::wCurMap, maps::PEWTER_CITY);
|
||||
assert!(boundary_values(&f.visit(10, 7)).is_empty());
|
||||
}
|
||||
|
||||
// -- the damage rule (`pokered-unique8-v8`, the operator 2026-09-29) --------------------------
|
||||
|
||||
/// Move ids from `constants/move_constants.asm`, the three row 67's Squirtle knows.
|
||||
const TACKLE: u8 = 0x21;
|
||||
const TAIL_WHIP: u8 = 0x27;
|
||||
const BUBBLE: u8 = 0x91;
|
||||
/// `wTrainerClass`-independent: `wIsInBattle` is 2 in a trainer battle, 1 in a wild one.
|
||||
const TRAINER_BATTLE: u8 = 2;
|
||||
const WILD_BATTLE: u8 = 1;
|
||||
|
||||
impl Fixture {
|
||||
/// The enemy battle struct as `LoadEnemyMonData` leaves it: party slot, species, level, HP
|
||||
/// and max HP (both big-endian words).
|
||||
fn enemy(&mut self, slot: u8, species: u8, level: u8, hp: u16, max_hp: u16) {
|
||||
self.memory.set(ram::wEnemyMonPartyPos, slot);
|
||||
self.memory.set(ram::wEnemyMonSpecies, species);
|
||||
self.memory.set(ram::wEnemyMonLevel, level);
|
||||
self.enemy_hp(hp, max_hp);
|
||||
}
|
||||
|
||||
fn enemy_hp(&mut self, hp: u16, max_hp: u16) {
|
||||
self.memory.set(ram::wEnemyMonHP, (hp >> 8) as u8);
|
||||
self.memory.set(ram::wEnemyMonHP + 1, hp as u8);
|
||||
self.memory.set(ram::wEnemyMonMaxHP, (max_hp >> 8) as u8);
|
||||
self.memory.set(ram::wEnemyMonMaxHP + 1, max_hp as u8);
|
||||
}
|
||||
|
||||
/// `hWhoseTurn` and `wPlayerMoveNum` for the side acting, as `ExecutePlayerMove` and
|
||||
/// `MainInBattleLoop` write them.
|
||||
fn turn(&mut self, fly: bool, move_id: u8) {
|
||||
self.memory.set(state::poke::H_WHOSE_TURN, u8::from(!fly));
|
||||
self.memory.set(ram::wPlayerMoveNum, move_id);
|
||||
}
|
||||
|
||||
fn damage_events(&mut self) -> Vec<RewardEvent> {
|
||||
self.sample().into_iter().filter(|event| event.kind == kind::DAMAGE).collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn values(events: &[RewardEvent]) -> Vec<f64> {
|
||||
events.iter().map(|event| event.value).collect()
|
||||
}
|
||||
|
||||
fn close(a: f64, b: f64) -> bool {
|
||||
(a - b).abs() < 1e-12
|
||||
}
|
||||
|
||||
/// Row 67's battle: the Jr. Trainer's Diglett (slot 0, $3b, L11, 31 HP) and Sandshrew (slot 1,
|
||||
/// $60, L11, 33 HP), entered with the *last* battle's Diglett still in `wEnemyMon` at 7 HP.
|
||||
fn row67_battle() -> Fixture {
|
||||
let mut f = Fixture::booted();
|
||||
f.enemy(0, 0x3b, 11, 7, 31);
|
||||
f.turn(true, BUBBLE);
|
||||
f.memory.set(ram::wIsInBattle, TRAINER_BATTLE);
|
||||
assert!(f.damage_events().is_empty(), "the stale Diglett is not the battle's");
|
||||
f.enemy_hp(3, 31);
|
||||
assert!(f.damage_events().is_empty(), "and nothing it does pays");
|
||||
f.enemy(0, 0x3b, 11, 31, 31);
|
||||
assert!(f.damage_events().is_empty(), "the real Diglett loads full");
|
||||
f
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_flys_own_attack_pays_in_proportion_and_tail_whip_pays_nothing() {
|
||||
let mut f = row67_battle();
|
||||
// TAIL WHIP: no HP moves, whatever the turn.
|
||||
f.turn(true, TAIL_WHIP);
|
||||
assert!(f.damage_events().is_empty());
|
||||
// BUBBLE lands for 12 of 31.
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(19, 31);
|
||||
let hit = f.damage_events();
|
||||
assert_eq!(labels(&hit), ["HIT #59 FOR 12 HP"]);
|
||||
assert!(close(hit[0].value, 0.20 * 12.0 / 31.0));
|
||||
assert_eq!(hit[0].stimulation_ms, 80);
|
||||
// The HP bar animates for a while; the same HP is not paid again.
|
||||
assert!(f.damage_events().is_empty());
|
||||
// TACKLE for 5.
|
||||
f.turn(true, TACKLE);
|
||||
f.enemy_hp(14, 31);
|
||||
assert_eq!(values(&f.damage_events()).len(), 1);
|
||||
assert_eq!(f.reward.statistics().counts[kind::DAMAGE], 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hp_the_enemy_loses_on_its_own_turn_and_struggle_pay_nothing() {
|
||||
let mut f = row67_battle();
|
||||
// Poison, burn, Leech Seed, recoil, a confusion self-hit, its own Explosion: all with
|
||||
// `hWhoseTurn` 1.
|
||||
f.turn(false, BUBBLE);
|
||||
f.enemy_hp(27, 31);
|
||||
assert!(f.damage_events().is_empty());
|
||||
// Struggle is the cartridge's move, not the fly's.
|
||||
f.turn(true, state::poke::moves::STRUGGLE);
|
||||
f.enemy_hp(24, 31);
|
||||
assert!(f.damage_events().is_empty());
|
||||
// The fly's next hit is paid from 24, not from 31.
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(20, 31);
|
||||
let hit = f.damage_events();
|
||||
assert_eq!(labels(&hit), ["HIT #59 FOR 4 HP"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_healed_enemy_is_not_paid_for_twice_and_a_switch_keeps_the_marks() {
|
||||
let mut f = row67_battle();
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(11, 31);
|
||||
assert_eq!(f.damage_events().len(), 1);
|
||||
// A Potion on the trainer's turn.
|
||||
f.turn(false, BUBBLE);
|
||||
f.enemy_hp(31, 31);
|
||||
assert!(f.damage_events().is_empty());
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(19, 31);
|
||||
assert!(f.damage_events().is_empty(), "31 to 19 was paid before the Potion");
|
||||
// The trainer switches to Sandshrew, which is hit, and back.
|
||||
f.turn(false, BUBBLE);
|
||||
f.enemy(1, 0x60, 11, 33, 33);
|
||||
assert!(f.damage_events().is_empty());
|
||||
f.turn(true, TACKLE);
|
||||
f.enemy_hp(28, 33);
|
||||
assert_eq!(labels(&f.damage_events()), ["HIT #96 FOR 5 HP"]);
|
||||
f.turn(false, BUBBLE);
|
||||
f.enemy(0, 0x3b, 11, 19, 31);
|
||||
assert!(f.damage_events().is_empty());
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(8, 31);
|
||||
assert_eq!(labels(&f.damage_events()), ["HIT #59 FOR 3 HP"], "only below its low of 11");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_trainer_battle_pays_the_knockouts_and_stops_at_the_cap() {
|
||||
let mut f = row67_battle();
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(0, 31);
|
||||
let ko = f.damage_events();
|
||||
assert_eq!(labels(&ko), ["HIT #59 FOR 31 HP KO"]);
|
||||
assert!(close(ko[0].value, 0.25));
|
||||
f.enemy(1, 0x60, 11, 33, 33);
|
||||
f.sample();
|
||||
f.enemy_hp(0, 33);
|
||||
assert!(close(values(&f.damage_events())[0], 0.25));
|
||||
// A third Pokémon: the cap is spent.
|
||||
f.enemy(2, 0x60, 11, 33, 33);
|
||||
f.sample();
|
||||
f.enemy_hp(0, 33);
|
||||
assert!(f.damage_events().is_empty());
|
||||
f.memory.set(ram::wIsInBattle, 0);
|
||||
f.sample();
|
||||
assert!(close(f.reward.statistics().total, 0.50), "the battle's damage is the trainer's 0.50");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_new_trainer_battle_starts_a_new_budget() {
|
||||
// Row 67's ring: lose, black out, walk back, fight again. Each battle pays its own damage.
|
||||
let mut f = row67_battle();
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(19, 31);
|
||||
assert_eq!(f.damage_events().len(), 1);
|
||||
f.memory.set(ram::wIsInBattle, 0xff);
|
||||
f.sample();
|
||||
f.memory.set(ram::wIsInBattle, 0);
|
||||
f.sample();
|
||||
f.memory.set(ram::wIsInBattle, TRAINER_BATTLE);
|
||||
f.sample();
|
||||
f.enemy(0, 0x3b, 11, 31, 31);
|
||||
f.sample();
|
||||
f.enemy_hp(19, 31);
|
||||
assert_eq!(f.damage_events().len(), 1, "the second battle's first hit pays");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_wild_battle_pays_damage_on_the_wild_ko_scale_and_a_rollback_blocks_the_key() {
|
||||
let mut f = Fixture::booted();
|
||||
let mut paid = Vec::new();
|
||||
for _ in 0..4 {
|
||||
f.enemy(0, 0xa5, 3, 12, 12);
|
||||
f.turn(true, TACKLE);
|
||||
f.memory.set(ram::wIsInBattle, WILD_BATTLE);
|
||||
f.sample();
|
||||
f.enemy_hp(6, 12);
|
||||
paid.extend(values(&f.damage_events()));
|
||||
f.memory.set(ram::wIsInBattle, 0);
|
||||
f.memory.set(ram::wBattleResult, 1);
|
||||
f.sample();
|
||||
}
|
||||
assert_eq!(paid.len(), 3, "three wild battles per map/species/level: {paid:?}");
|
||||
assert!(close(paid[0], 0.10) && close(paid[1], 0.05) && close(paid[2], 0.10 / 3.0));
|
||||
assert_eq!(f.reward.export_state()["damageCounts"], json!({ "38:165:3": 3 }));
|
||||
|
||||
// Another species on the same map is another key, and a rollback blocks it once paid.
|
||||
f.enemy(0, 0x24, 3, 12, 12);
|
||||
f.memory.set(ram::wIsInBattle, WILD_BATTLE);
|
||||
f.sample();
|
||||
f.enemy_hp(0, 12);
|
||||
let events = f.damage_events();
|
||||
assert_eq!(labels(&events), ["HIT #36 FOR 12 HP KO"]);
|
||||
assert!(close(events[0].value, 0.20), "no knockout bonus in the wild");
|
||||
f.memory.set(ram::wIsInBattle, 0);
|
||||
f.memory.set(ram::wBattleResult, 0);
|
||||
assert_eq!(kinds(&f.sample()), ["battle"], "the wild KO still pays as it did");
|
||||
f.reward.clear_transient();
|
||||
f.enemy(0, 0x24, 3, 12, 12);
|
||||
f.memory.set(ram::wIsInBattle, WILD_BATTLE);
|
||||
f.sample();
|
||||
f.enemy_hp(0, 12);
|
||||
assert!(f.damage_events().is_empty(), "a rollback cannot replay the damage");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_battle_sample_still_reads_each_address_once() {
|
||||
let mut f = row67_battle();
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(19, 31);
|
||||
f.damage_events();
|
||||
assert!(
|
||||
f.memory.reads.values().all(|count| *count == 1),
|
||||
"{:?}",
|
||||
f.memory.reads.iter().filter(|(_, count)| **count != 1).collect::<Vec<_>>()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_battle_in_flight_round_trips_through_a_checkpoint() {
|
||||
let mut f = row67_battle();
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(19, 31);
|
||||
f.damage_events();
|
||||
let state = f.reward.export_state();
|
||||
let mut restored = PokemonRedReward::new();
|
||||
restored.import_state(&state).unwrap();
|
||||
assert_eq!(restored.export_state(), state);
|
||||
f.reward = restored;
|
||||
f.enemy_hp(15, 31);
|
||||
assert_eq!(labels(&f.damage_events()), ["HIT #59 FOR 4 HP"], "the mark came back with it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_v7_state_restores_under_v8_with_no_damage_ledger_and_its_battle_marked_where_it_stands() {
|
||||
// A v7 export mid-battle: v8's export without `damageCounts`, `counts.damage` or
|
||||
// `battle.damage`.
|
||||
let mut f = row67_battle();
|
||||
f.turn(true, BUBBLE);
|
||||
f.enemy_hp(19, 31);
|
||||
f.damage_events();
|
||||
let mut v7 = f.reward.export_state();
|
||||
v7.as_object_mut().unwrap().remove("damageCounts");
|
||||
v7["counts"].as_object_mut().unwrap().remove("damage");
|
||||
v7["battle"].as_object_mut().unwrap().remove("damage");
|
||||
assert_eq!(v7["version"], json!(STATE_VERSION), "v7 and v8 share a schema version");
|
||||
|
||||
let mut restored = PokemonRedReward::new();
|
||||
restored.import_state(&v7).unwrap();
|
||||
assert_eq!(restored.statistics().counts[kind::DAMAGE], 0);
|
||||
assert_eq!(restored.export_state()["damageCounts"], json!({}));
|
||||
f.reward = restored;
|
||||
// Diglett stands at 19 of 31: that is its mark, and the 12 lost before the restore is not
|
||||
// paid. The next hit is.
|
||||
assert!(f.damage_events().is_empty());
|
||||
f.enemy_hp(10, 31);
|
||||
assert_eq!(labels(&f.damage_events()), ["HIT #59 FOR 9 HP"]);
|
||||
// Sandshrew, which the restore never saw, is marked where it first reads too.
|
||||
f.enemy(1, 0x60, 11, 33, 33);
|
||||
f.sample();
|
||||
f.enemy_hp(30, 33);
|
||||
assert_eq!(labels(&f.damage_events()), ["HIT #96 FOR 3 HP"]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ mod tests {
|
|||
wall_ms: 1_700_000_000_000,
|
||||
rom_sha256: "ab".repeat(32),
|
||||
emulator_frame: 12_345,
|
||||
compatibility: "kernel/pokered-unique8-v7/fingerprint".to_string(),
|
||||
compatibility: "kernel/pokered-unique8-v8/fingerprint".to_string(),
|
||||
speed: 1.0,
|
||||
buttons: 0,
|
||||
rank_since_ms: 4_242.0,
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ pub struct FeedMacroOutcome {
|
|||
|
||||
/// Reward categories the feed reports counts for. The adapter's own interned kinds
|
||||
/// (`milestone`, `exploration`, `map`, `species`, `trainer`, `battle`, `badge`, `boundary`,
|
||||
/// `catch`, `talk`, `item`) map onto these.
|
||||
/// `catch`, `talk`, `item`) map onto these; `damage` has no counter (`from_adapter`).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum RewardKind {
|
||||
|
|
@ -300,6 +300,15 @@ impl RewardKind {
|
|||
// "new place" for all four, the operator's call (`apps/stage/src/games/pokemon-red.ts`).
|
||||
"talk" => Self::Explore,
|
||||
"item" => Self::Explore,
|
||||
// `damage` (the operator, 2026-09-29) has no counter, deliberately. It pays for a hit,
|
||||
// several times a battle, in trainer battles as well as wild ones: on `wildwin` the
|
||||
// stage would fold every hit into "N wild wins", which is false of a trainer battle
|
||||
// and of a battle the fly goes on to lose, and on any other counter it would be as
|
||||
// wrong. Unmapped, a hit still reaches the page as a reward event with its own label
|
||||
// (`HIT #<species> FOR <n> HP`), the event log, `/status` and the checkpoint; it is
|
||||
// only left out of `game.rewardCounts` and the ticker's per-kind copy, the way the
|
||||
// platformer's `started` and `clear` are. The feed's closed kind set does not move.
|
||||
"damage" => return None,
|
||||
// The platformer.
|
||||
"band" => Self::Explore,
|
||||
"coin" => Self::Wildwin,
|
||||
|
|
@ -753,13 +762,16 @@ mod tests {
|
|||
GameMode::Unknown
|
||||
);
|
||||
for rule in flybrain_gb::pokemon_red::catalog::REWARDS {
|
||||
assert!(RewardKind::from_adapter(rule.kind).is_some(), "{}", rule.kind);
|
||||
// Every Pokémon kind shares a counter but `damage`, which has none on purpose.
|
||||
let mapped = RewardKind::from_adapter(rule.kind).is_some();
|
||||
assert_eq!(mapped, rule.kind != "damage", "{}", rule.kind);
|
||||
}
|
||||
assert_eq!(RewardKind::from_adapter("nonsense"), None);
|
||||
assert_eq!(RewardKind::from_adapter("boundary"), Some(RewardKind::Explore));
|
||||
assert_eq!(RewardKind::from_adapter("catch"), Some(RewardKind::Wildwin));
|
||||
assert_eq!(RewardKind::from_adapter("talk"), Some(RewardKind::Explore));
|
||||
assert_eq!(RewardKind::from_adapter("item"), Some(RewardKind::Explore));
|
||||
assert_eq!(RewardKind::from_adapter("damage"), None, "a hit is not a wild win");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
//! A `v6` checkpoint restored under `v7`: accepted with the opt-in, refused without it.
|
||||
//! A `v7` (and a `v6`) checkpoint restored under `v8`: accepted with the opt-in, refused without
|
||||
//! it.
|
||||
//!
|
||||
//! The unit tests in `flybrain-gb` cover the decision function and the adapter's own state
|
||||
//! migration separately. This is the two of them against one artefact: a real `FLYSIM01`
|
||||
//! envelope carrying a `pokered-unique8-v6` compatibility string and a `v6` reward ledger —
|
||||
//! written, encoded, decoded, and then put through exactly what `Sim::try_restore` puts a
|
||||
//! candidate through, and then one sample of a game in which items were already taken.
|
||||
//! envelope carrying a `pokered-unique8-v7` (or `-v6`) compatibility string and that version's
|
||||
//! reward ledger — written, encoded, decoded, and then put through exactly what
|
||||
//! `Sim::try_restore` puts a candidate through, and then samples of a game: one in which items
|
||||
//! were already taken (`v6`), one in the middle of the row 67 battle (`v7`).
|
||||
//!
|
||||
//! No ROM and no dataset, deliberately. Building a `Sim` would need both, and neither is part of
|
||||
//! the question: what decides a restore is the compatibility string and `import_state`, and what
|
||||
//! decides the seed is the first sample's read of the cartridge's own item bits.
|
||||
//!
|
||||
//! (`v5` -> `v6`, the catch rule's migration, was this same file; `v6` no longer migrates from
|
||||
//! anything, so that pair is refused now like any other.)
|
||||
//! (`v5` -> `v6`, the catch rule's migration, was this same file, and `v6` -> `v7` the engagement
|
||||
//! rules'. `v8` reads both `v7` and `v6`: the chain composes, and `v5` stays refused.)
|
||||
|
||||
use flybrain_gb::GameAdapter;
|
||||
use flybrain_gb::MemoryReader;
|
||||
|
|
@ -67,7 +69,34 @@ fn v6_reward() -> serde_json::Value {
|
|||
})
|
||||
}
|
||||
|
||||
/// A `v7` reward ledger: the `v6` one after the engagement rules' first sample (the item seed and
|
||||
/// a conversation), with a battle in flight -- the row 67 Jr. Trainer's Diglett at 19 of 31 --
|
||||
/// and **no** `damageCounts`, `counts.damage` or `battle.damage`.
|
||||
fn v7_reward() -> serde_json::Value {
|
||||
let mut reward = v6_reward();
|
||||
let seen = reward["seen"].as_array_mut().unwrap();
|
||||
for key in ["items:seeded", "item:42", "talk:54:sprite:1"] {
|
||||
seen.push(serde_json::json!(key));
|
||||
}
|
||||
reward["counts"]["talk"] = serde_json::json!(1);
|
||||
reward["counts"]["item"] = serde_json::json!(0);
|
||||
reward["mode"] = serde_json::json!("BATTLE");
|
||||
reward["battle"] = serde_json::json!({
|
||||
"key": "54:59:11", "wild": false, "sawLiving": true, "ko": false,
|
||||
"speciesAtStart": 1, "captured": null, "capturedNew": false
|
||||
});
|
||||
reward
|
||||
}
|
||||
|
||||
fn v6_checkpoint() -> Vec<u8> {
|
||||
checkpoint_of("pokered-unique8-v6", v6_reward())
|
||||
}
|
||||
|
||||
fn v7_checkpoint() -> Vec<u8> {
|
||||
checkpoint_of("pokered-unique8-v7", v7_reward())
|
||||
}
|
||||
|
||||
fn checkpoint_of(adapter: &str, reward: serde_json::Value) -> Vec<u8> {
|
||||
use flybrain_core::decoder::DecoderState;
|
||||
use flybrain_core::lif::LifState;
|
||||
use flybrain_core::ordered::NumberMap;
|
||||
|
|
@ -118,12 +147,12 @@ fn v6_checkpoint() -> Vec<u8> {
|
|||
wall_ms: 1_790_000_000_000,
|
||||
rom_sha256: flybrain_gb::pokemon_red::SUPPORTED_ROM.to_string(),
|
||||
emulator_frame: 1_000_000,
|
||||
compatibility: compatibility("pokered-unique8-v6"),
|
||||
compatibility: compatibility(adapter),
|
||||
speed: 1.0,
|
||||
buttons: 0,
|
||||
rank_since_ms: 1_000.0,
|
||||
last_event_id: 4_242,
|
||||
reward: v6_reward(),
|
||||
reward,
|
||||
ratchet: flybrain_gb::RatchetState { best: 3, attempts: 1, recoveries: 4, ..Default::default() },
|
||||
emulator: vec![3; 64],
|
||||
framebuffer: vec![0; 32],
|
||||
|
|
@ -134,25 +163,31 @@ fn v6_checkpoint() -> Vec<u8> {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn a_v6_checkpoint_is_refused_under_v7_without_the_opt_in() {
|
||||
let checkpoint = store::decode(&v6_checkpoint()).expect("the fixture decodes");
|
||||
fn a_v7_or_v6_checkpoint_is_refused_under_v8_without_its_own_opt_in() {
|
||||
let adapter = PokemonRedReward::new();
|
||||
let current = compatibility(adapter.id());
|
||||
assert_ne!(checkpoint.runtime.compatibility, current, "v7 is not v6");
|
||||
|
||||
for opt_in in [None, Some(""), Some("pokered-unique8-v5"), Some("some-other-adapter")] {
|
||||
assert!(
|
||||
matches!(
|
||||
decide(
|
||||
&checkpoint.runtime.compatibility,
|
||||
¤t,
|
||||
adapter.migrates_from(),
|
||||
&accepted_adapters(opt_in),
|
||||
for (bytes, own) in
|
||||
[(v7_checkpoint(), "pokered-unique8-v7"), (v6_checkpoint(), "pokered-unique8-v6")]
|
||||
{
|
||||
let checkpoint = store::decode(&bytes).expect("the fixture decodes");
|
||||
assert_ne!(checkpoint.runtime.compatibility, current, "v8 is not {own}");
|
||||
let other = if own.ends_with("v7") { "pokered-unique8-v6" } else { "pokered-unique8-v7" };
|
||||
for opt_in in
|
||||
[None, Some(""), Some("pokered-unique8-v5"), Some("some-other-adapter"), Some(other)]
|
||||
{
|
||||
assert!(
|
||||
matches!(
|
||||
decide(
|
||||
&checkpoint.runtime.compatibility,
|
||||
¤t,
|
||||
adapter.migrates_from(),
|
||||
&accepted_adapters(opt_in),
|
||||
),
|
||||
RestoreDecision::Refuse(_)
|
||||
),
|
||||
RestoreDecision::Refuse(_)
|
||||
),
|
||||
"FLY_ACCEPT_ADAPTERS={opt_in:?} must not migrate anything"
|
||||
);
|
||||
"{own} with FLY_ACCEPT_ADAPTERS={opt_in:?} must not migrate"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +201,7 @@ impl MemoryReader for Wram {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn a_v6_checkpoint_restores_under_v7_with_the_new_ledgers_empty_and_the_items_seeded() {
|
||||
fn a_v6_checkpoint_restores_under_v8_with_the_new_ledgers_empty_and_the_items_seeded() {
|
||||
let checkpoint = store::decode(&v6_checkpoint()).expect("the fixture decodes");
|
||||
let mut adapter = PokemonRedReward::new();
|
||||
let current = compatibility(adapter.id());
|
||||
|
|
@ -182,18 +217,20 @@ fn a_v6_checkpoint_restores_under_v7_with_the_new_ledgers_empty_and_the_items_se
|
|||
);
|
||||
|
||||
// The migration itself: `import_state`, exactly as `Sim::try_restore` calls it.
|
||||
adapter.import_state(&checkpoint.runtime.reward).expect("a v6 ledger is a valid v7 ledger");
|
||||
adapter.import_state(&checkpoint.runtime.reward).expect("a v6 ledger is a valid v8 ledger");
|
||||
|
||||
let after = adapter.export_state();
|
||||
assert_eq!(after["counts"]["talk"], serde_json::json!(0), "no conversation was ever paid");
|
||||
assert_eq!(after["counts"]["item"], serde_json::json!(0), "nor any item");
|
||||
assert_eq!(after["counts"]["damage"], serde_json::json!(0), "nor any damage");
|
||||
assert_eq!(after["damageCounts"], serde_json::json!({}));
|
||||
|
||||
// And nothing else moved: every field the v6 state carried round-trips to the same value,
|
||||
// and v7 adds no field at all -- its ledgers are keys in `seen`.
|
||||
// And nothing else moved: every field the v6 state carried round-trips to the same value;
|
||||
// v7 added no field (its ledgers are keys in `seen`) and v8 adds one, `damageCounts`.
|
||||
//
|
||||
// `counts` is the one field that is not byte-identical, and it is not a change of meaning:
|
||||
// it serializes every kind in the catalog, so a v7 state lists `talk` and `item` where a v6
|
||||
// state had nothing to list. Every kind the v6 state did carry keeps its number.
|
||||
// it serializes every kind in the catalog, so a v8 state lists `talk`, `item` and `damage`
|
||||
// where a v6 state had nothing to list. Every kind the v6 state did carry keeps its number.
|
||||
let before = v6_reward();
|
||||
for (key, value) in before.as_object().unwrap() {
|
||||
if key == "counts" {
|
||||
|
|
@ -206,7 +243,7 @@ fn a_v6_checkpoint_restores_under_v7_with_the_new_ledgers_empty_and_the_items_se
|
|||
.keys()
|
||||
.filter(|kind| !value.as_object().unwrap().contains_key(*kind))
|
||||
.collect();
|
||||
assert_eq!(added, vec!["talk", "item"], "v7 counts two more kinds and no others");
|
||||
assert_eq!(added, vec!["talk", "item", "damage"], "three more kinds and no others");
|
||||
continue;
|
||||
}
|
||||
assert_eq!(&after[key], value, "{key} must survive the migration byte for byte");
|
||||
|
|
@ -217,7 +254,7 @@ fn a_v6_checkpoint_restores_under_v7_with_the_new_ledgers_empty_and_the_items_se
|
|||
.keys()
|
||||
.filter(|key| !before.as_object().unwrap().contains_key(*key))
|
||||
.collect();
|
||||
assert!(added.is_empty(), "v7 adds no field: {added:?}");
|
||||
assert_eq!(added, vec!["damageCounts"], "v8 adds one field");
|
||||
|
||||
// The first sample of the restored game. Under v6 the fly took an item ball (global
|
||||
// toggleable index 0x2a) and a hidden item (index 9); v6 paid for neither. The sample seeds
|
||||
|
|
@ -250,11 +287,11 @@ fn a_v6_checkpoint_restores_under_v7_with_the_new_ledgers_empty_and_the_items_se
|
|||
#[test]
|
||||
fn nothing_but_the_adapter_segment_may_differ_for_the_migration_to_apply() {
|
||||
let adapter = PokemonRedReward::new();
|
||||
let accepted = accepted_adapters(Some("pokered-unique8-v6"));
|
||||
let accepted = accepted_adapters(Some("pokered-unique8-v7"));
|
||||
let current = compatibility(adapter.id());
|
||||
|
||||
// A v6 string whose state format also moved: a different build, not a rule change.
|
||||
let other_abi = compatibility("pokered-unique8-v6").replace("199616", "199617");
|
||||
// A v7 string whose state format also moved: a different build, not a rule change.
|
||||
let other_abi = compatibility("pokered-unique8-v7").replace("199616", "199617");
|
||||
assert!(matches!(
|
||||
decide(&other_abi, ¤t, adapter.migrates_from(), &accepted),
|
||||
RestoreDecision::Refuse(_)
|
||||
|
|
@ -266,14 +303,85 @@ fn nothing_but_the_adapter_segment_may_differ_for_the_migration_to_apply() {
|
|||
RestoreDecision::Exact
|
||||
);
|
||||
|
||||
// And v5 -> v7 is not a migration this adapter wrote, whatever the operator names.
|
||||
// And v5 -> v8 is not a migration this adapter wrote, whatever the operator names.
|
||||
assert!(matches!(
|
||||
decide(
|
||||
&compatibility("pokered-unique8-v5"),
|
||||
¤t,
|
||||
adapter.migrates_from(),
|
||||
&accepted_adapters(Some("pokered-unique8-v5,pokered-unique8-v6")),
|
||||
&accepted_adapters(Some("pokered-unique8-v5,pokered-unique8-v6,pokered-unique8-v7")),
|
||||
),
|
||||
RestoreDecision::Refuse(_)
|
||||
));
|
||||
}
|
||||
|
||||
/// The enemy battle struct and the turn, as `LoadEnemyMonData` and `ExecutePlayerMove` leave them.
|
||||
fn battle_wram(hp: u8, fly_turn: bool) -> Wram {
|
||||
let mut wram = Wram(vec![0; 0x10000]);
|
||||
wram.0[ram::wStatusFlags6 as usize] = 1;
|
||||
wram.0[ram::wPartyCount as usize] = 1;
|
||||
wram.0[ram::wCurMap as usize] = 54;
|
||||
wram.0[ram::wCurMapWidth as usize] = 5;
|
||||
wram.0[ram::wCurMapHeight as usize] = 7;
|
||||
wram.0[ram::wXCoord as usize] = 4;
|
||||
wram.0[ram::wYCoord as usize] = 10;
|
||||
wram.0[ram::wIsInBattle as usize] = 2;
|
||||
wram.0[ram::wEnemyMonPartyPos as usize] = 0;
|
||||
wram.0[ram::wEnemyMonSpecies as usize] = 59;
|
||||
wram.0[ram::wEnemyMonLevel as usize] = 11;
|
||||
wram.0[(ram::wEnemyMonHP + 1) as usize] = hp;
|
||||
wram.0[(ram::wEnemyMonMaxHP + 1) as usize] = 31;
|
||||
wram.0[flybrain_gb::pokemon_red::state::poke::H_WHOSE_TURN as usize] = u8::from(!fly_turn);
|
||||
wram.0[ram::wPlayerMoveNum as usize] = 0x91;
|
||||
wram
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_v7_checkpoint_taken_mid_battle_restores_under_v8_and_pays_only_what_follows() {
|
||||
let checkpoint = store::decode(&v7_checkpoint()).expect("the fixture decodes");
|
||||
let mut adapter = PokemonRedReward::new();
|
||||
let current = compatibility(adapter.id());
|
||||
assert_eq!(
|
||||
decide(
|
||||
&checkpoint.runtime.compatibility,
|
||||
¤t,
|
||||
adapter.migrates_from(),
|
||||
&accepted_adapters(Some("pokered-unique8-v7")),
|
||||
),
|
||||
RestoreDecision::MigrateAdapter { from: "pokered-unique8-v7".to_string() }
|
||||
);
|
||||
adapter.import_state(&checkpoint.runtime.reward).expect("a v7 ledger is a valid v8 ledger");
|
||||
|
||||
// Every field v7 carried survives, and v8 adds `damageCounts` and the battle's `damage`.
|
||||
let before = v7_reward();
|
||||
let after = adapter.export_state();
|
||||
for (key, value) in before.as_object().unwrap() {
|
||||
match key.as_str() {
|
||||
"counts" => {
|
||||
for (kind, count) in value.as_object().unwrap() {
|
||||
assert_eq!(&after["counts"][kind], count, "counts.{kind}");
|
||||
}
|
||||
assert_eq!(after["counts"]["damage"], serde_json::json!(0));
|
||||
}
|
||||
"battle" => {
|
||||
for (field, v) in value.as_object().unwrap() {
|
||||
assert_eq!(&after["battle"][field], v, "battle.{field}");
|
||||
}
|
||||
assert_eq!(after["battle"]["damage"]["restored"], serde_json::json!(true));
|
||||
}
|
||||
_ => assert_eq!(&after[key], value, "{key} must survive the migration byte for byte"),
|
||||
}
|
||||
}
|
||||
assert_eq!(after["damageCounts"], serde_json::json!({}));
|
||||
|
||||
// The restored battle: Diglett stands at 19 of 31. The 12 HP it lost under v7 are not paid;
|
||||
// its own turn's poison tick is not paid; BUBBLE's next hit is.
|
||||
assert!(adapter.sample(&mut battle_wram(19, true), 2_000.0).is_empty(), "no back pay");
|
||||
assert!(adapter.sample(&mut battle_wram(17, false), 2_017.0).is_empty(), "not its turn");
|
||||
let hit = adapter.sample(&mut battle_wram(8, true), 2_034.0);
|
||||
assert_eq!(hit.len(), 1);
|
||||
assert_eq!(hit[0].kind, "damage");
|
||||
assert_eq!(hit[0].label, "HIT #59 FOR 9 HP");
|
||||
assert!((hit[0].value - 0.20 * 9.0 / 31.0).abs() < 1e-12);
|
||||
assert_eq!(adapter.progress().rank, 3, "the rank is untouched");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ async fn the_service_streams_takes_sugar_checkpoints_and_resumes_after_being_kil
|
|||
};
|
||||
assert_eq!(status, 200);
|
||||
assert_eq!(versions["version"]["kernel"], json!("lif-1ms-f64-v2"));
|
||||
assert_eq!(versions["version"]["adapter"], json!("pokered-unique8-v7"));
|
||||
assert_eq!(versions["version"]["adapter"], json!("pokered-unique8-v8"));
|
||||
assert!(
|
||||
versions["version"]["dataset"].as_str().unwrap_or_default().len() > 32,
|
||||
"the dataset fingerprint is in /status: {}",
|
||||
|
|
|
|||
278
services/flysim/crates/flysim/tests/rom_damage.rs
Normal file
278
services/flysim/crates/flysim/tests/rom_damage.rs
Normal file
|
|
@ -0,0 +1,278 @@
|
|||
//! The damage reward against the real cartridge, from the live row 67 checkpoint.
|
||||
//!
|
||||
//! Gated on `FLY_ROM` *and* on the checkpoint, the way every ROM test in this workspace is, and
|
||||
//! skips cleanly without either:
|
||||
//!
|
||||
//! ```sh
|
||||
//! FLY_ROM="$HOME/roms/pokemon-red.gb" \
|
||||
//! FLY_ROW67_CHECKPOINT=.local/checkpoints/<the row 67 Pewter checkpoint> \
|
||||
//! cargo test --release -p flysim --test rom_damage -- --nocapture
|
||||
//! ```
|
||||
//!
|
||||
//! ## What only the cartridge can answer
|
||||
//!
|
||||
//! The synthetic traces in `pokemon_red/tests.rs` and `pokemon_red/damage.rs` write
|
||||
//! `wEnemyMonHP`, `hWhoseTurn` and `wPlayerMoveNum` from the disassembly. They cannot say that
|
||||
//! `hWhoseTurn` is at `$FFF3` on this cartridge, that it reads 0 on the frame the fly's BUBBLE
|
||||
//! lands and 1 on the frame the enemy's attack does, or that the enemy's HP drops on a frame the
|
||||
//! adapter samples with the move that did it still in `wPlayerMoveNum`. This test does, with the
|
||||
//! shipping adapter sampling once a frame -- and it restores the checkpoint's own `v7` reward
|
||||
//! ledger, so it is also the `v7` -> `v8` migration on the live run's state.
|
||||
//!
|
||||
//! ## How the fly is moved
|
||||
//!
|
||||
//! Not by a brain: the shipping palette (`PokemonPalette`) deals the pad, and a harness picks. Out
|
||||
//! of battle the pick is uniform over what the pad deals, which is what `row67_the_gym_trainer_is_
|
||||
//! beaten_from_what_the_pad_deals` (`rom_macros_mode.rs`) showed reaches the gym's Jr. Trainer.
|
||||
//! In battle it rotates the three moves -- TAIL WHIP, BUBBLE, TACKLE -- so each is used, and the
|
||||
//! test asserts what each one was paid.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use flybrain_gb::adapter::RewardEvent;
|
||||
use flybrain_gb::compatibility::{RestoreDecision, accepted_adapters, decide};
|
||||
use flybrain_gb::pokemon_red::macros::PokemonPalette;
|
||||
use flybrain_gb::pokemon_red::symbols::ram;
|
||||
use flybrain_gb::pokemon_red::{MIGRATES_FROM, PokemonRedReward, REWARD_ADAPTER, state};
|
||||
use flybrain_gb::{
|
||||
AdapterLedger, DEFAULT_AUDIO_FRAMES, DEFAULT_AUDIO_FREQUENCY, Emulator, GameAdapter,
|
||||
MacroPalette, MemoryReader, Started,
|
||||
};
|
||||
|
||||
const MS_PER_FRAME: f64 = 1000.0 / 59.7275;
|
||||
const SEED: u32 = 20_260_929;
|
||||
/// `constants/move_constants.asm`.
|
||||
const TACKLE: u8 = 0x21;
|
||||
const TAIL_WHIP: u8 = 0x27;
|
||||
const BUBBLE: u8 = 0x91;
|
||||
|
||||
fn rom() -> Option<Vec<u8>> {
|
||||
let path = std::env::var_os("FLY_ROM")?;
|
||||
match std::fs::read(&path) {
|
||||
Ok(bytes) => Some(bytes),
|
||||
Err(error) => panic!("FLY_ROM is set to {path:?} but could not be read: {error}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn checkpoint() -> Option<flysim::store::Checkpoint> {
|
||||
let path = std::env::var_os("FLY_ROW67_CHECKPOINT")?;
|
||||
Some(
|
||||
flysim::store::load(std::path::Path::new(&path))
|
||||
.expect("the checkpoint should be a FLYSIM01 envelope"),
|
||||
)
|
||||
}
|
||||
|
||||
fn hp(gb: &mut Emulator, address: u16) -> u16 {
|
||||
u16::from(gb.read8(address)) << 8 | u16::from(gb.read8(address + 1))
|
||||
}
|
||||
|
||||
/// The live `v7` checkpoint is refused by this build without the opt-in and restored with it, by
|
||||
/// the same decision `Sim::try_restore` makes, and its reward ledger imports.
|
||||
#[test]
|
||||
fn the_live_v7_checkpoint_migrates_to_v8() {
|
||||
let Some(checkpoint) = checkpoint() else {
|
||||
eprintln!("skipped: no FLY_ROW67_CHECKPOINT");
|
||||
return;
|
||||
};
|
||||
let live = checkpoint.runtime.compatibility.clone();
|
||||
let segments: Vec<&str> = live.split('/').collect();
|
||||
assert_eq!(segments[1], "pokered-unique8-v7", "the live run is v7: {live}");
|
||||
// This build's string is the live one with the adapter segment moved and nothing else: the
|
||||
// dataset, kernel, plasticity, emulator, symbols and state format are the same build inputs.
|
||||
let mut ours = segments.clone();
|
||||
ours[1] = REWARD_ADAPTER;
|
||||
let current = ours.join("/");
|
||||
assert!(matches!(decide(&live, ¤t, MIGRATES_FROM, &[]), RestoreDecision::Refuse(_)));
|
||||
assert_eq!(
|
||||
decide(&live, ¤t, MIGRATES_FROM, &accepted_adapters(Some("pokered-unique8-v7"))),
|
||||
RestoreDecision::MigrateAdapter { from: "pokered-unique8-v7".to_string() }
|
||||
);
|
||||
let mut adapter = PokemonRedReward::new();
|
||||
adapter.import_state(&checkpoint.runtime.reward).expect("a v7 ledger is a v8 ledger");
|
||||
let state = adapter.export_state();
|
||||
assert_eq!(state["damageCounts"], serde_json::json!({}));
|
||||
assert_eq!(state["counts"]["damage"], serde_json::json!(0));
|
||||
for kind in ["milestone", "map", "trainer", "battle", "talk", "item", "catch"] {
|
||||
assert_eq!(
|
||||
state["counts"][kind], checkpoint.runtime.reward["counts"][kind],
|
||||
"counts.{kind} survives"
|
||||
);
|
||||
}
|
||||
assert_eq!(state["seen"], checkpoint.runtime.reward["seen"], "the ledger survives");
|
||||
assert_eq!(adapter.progress().rank, 10, "PEWTER CITY");
|
||||
}
|
||||
|
||||
/// BUBBLE and TACKLE are paid when they land, TAIL WHIP never is, and the enemy's own hits land
|
||||
/// while `hWhoseTurn` reads 1.
|
||||
#[test]
|
||||
fn damage_pays_on_bubble_and_tackle_and_not_on_tail_whip() {
|
||||
let (Some(rom), Some(checkpoint)) = (rom(), checkpoint()) else {
|
||||
eprintln!("skipped: needs FLY_ROM and FLY_ROW67_CHECKPOINT");
|
||||
return;
|
||||
};
|
||||
let mut gb = Emulator::new(&rom, DEFAULT_AUDIO_FREQUENCY, DEFAULT_AUDIO_FRAMES)
|
||||
.expect("binjgb should accept the cartridge");
|
||||
gb.import_state(&checkpoint.runtime.emulator).expect("the checkpoint's emulator state");
|
||||
let mut adapter = PokemonRedReward::new();
|
||||
adapter.import_state(&checkpoint.runtime.reward).expect("a v7 ledger is a v8 ledger");
|
||||
|
||||
let mut palette = PokemonPalette::new(SEED);
|
||||
let rotation = ["MOVE 2", "MOVE 3", "MOVE 1"];
|
||||
let mut next_move = 0usize;
|
||||
let hold_frames = 48u32;
|
||||
let mut since_decision = hold_frames;
|
||||
let mut running = false;
|
||||
let mut rng = 7u32;
|
||||
let mut ms = 0.0;
|
||||
|
||||
// Per move id: moves started, enemy HP drops seen, damage events paid, HP paid for.
|
||||
let mut chosen: BTreeMap<u8, u32> = BTreeMap::new();
|
||||
let mut drops: BTreeMap<u8, u32> = BTreeMap::new();
|
||||
let mut paid: BTreeMap<u8, Vec<RewardEvent>> = BTreeMap::new();
|
||||
let mut enemy_drop_turns: BTreeMap<u8, u32> = BTreeMap::new();
|
||||
let mut own_drop_turns: BTreeMap<u8, u32> = BTreeMap::new();
|
||||
let mut last_enemy: Option<(u8, u8, u16)> = None;
|
||||
let mut last_own: Option<u16> = None;
|
||||
let mut trainer_battles = 0u32;
|
||||
let mut fighting = gb.read8(ram::wIsInBattle);
|
||||
// Frames from the `MOVE n` start to the payout it earned: how old the choice's trace is.
|
||||
let mut chose_at: Option<u32> = None;
|
||||
let mut delays: Vec<u32> = Vec::new();
|
||||
|
||||
for frame in 0..90_000u32 {
|
||||
palette.clock(ms);
|
||||
let observed = {
|
||||
let ledger = AdapterLedger(&adapter);
|
||||
palette.observe(&mut gb, &ledger)
|
||||
};
|
||||
let mut mask = 0u8;
|
||||
{
|
||||
let ledger = AdapterLedger(&adapter);
|
||||
if running {
|
||||
match palette.step(&mut gb, &ledger) {
|
||||
Some(held) => mask = held,
|
||||
None => running = false,
|
||||
}
|
||||
} else if since_decision >= hold_frames && !observed.bindings.is_empty() {
|
||||
since_decision = 0;
|
||||
let moves: Vec<_> =
|
||||
observed.bindings.iter().filter(|b| b.name.starts_with("MOVE ")).collect();
|
||||
let binding = if moves.is_empty() {
|
||||
rng ^= rng << 13;
|
||||
rng ^= rng >> 17;
|
||||
rng ^= rng << 5;
|
||||
&observed.bindings[(rng >> 8) as usize % observed.bindings.len()]
|
||||
} else {
|
||||
let want = rotation[next_move % rotation.len()];
|
||||
let pick = moves.iter().find(|b| b.name == want).unwrap_or(&moves[0]);
|
||||
next_move += 1;
|
||||
pick
|
||||
};
|
||||
if let Some(n) = binding.name.strip_prefix("MOVE ").and_then(|n| n.parse::<u16>().ok())
|
||||
{
|
||||
let id = gb.read8(ram::wBattleMonMoves + n - 1);
|
||||
*chosen.entry(id).or_default() += 1;
|
||||
chose_at = Some(frame);
|
||||
}
|
||||
if let Started::Running(_) = palette.start(binding.slot, &mut gb, &ledger) {
|
||||
running = true;
|
||||
match palette.step(&mut gb, &ledger) {
|
||||
Some(held) => mask = held,
|
||||
None => running = false,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
since_decision += 1;
|
||||
gb.set_buttons(mask);
|
||||
gb.run_frame().expect("a frame should complete");
|
||||
ms += MS_PER_FRAME;
|
||||
let events = adapter.sample(&mut gb, ms);
|
||||
|
||||
let in_battle = gb.read8(ram::wIsInBattle);
|
||||
if fighting == 0 && in_battle == 2 {
|
||||
trainer_battles += 1;
|
||||
}
|
||||
fighting = in_battle;
|
||||
let whose = gb.read8(state::poke::H_WHOSE_TURN);
|
||||
let move_id = gb.read8(ram::wPlayerMoveNum);
|
||||
if in_battle == 2 {
|
||||
let enemy = (
|
||||
gb.read8(ram::wEnemyMonPartyPos),
|
||||
gb.read8(ram::wEnemyMonSpecies),
|
||||
hp(&mut gb, ram::wEnemyMonHP),
|
||||
);
|
||||
if let Some(before) = last_enemy
|
||||
&& (before.0, before.1) == (enemy.0, enemy.1)
|
||||
&& enemy.2 < before.2
|
||||
{
|
||||
*enemy_drop_turns.entry(whose).or_default() += 1;
|
||||
if whose == 0 {
|
||||
*drops.entry(move_id).or_default() += 1;
|
||||
}
|
||||
}
|
||||
last_enemy = Some(enemy);
|
||||
let own = hp(&mut gb, ram::wBattleMonHP);
|
||||
if let Some(before) = last_own
|
||||
&& own < before
|
||||
{
|
||||
*own_drop_turns.entry(whose).or_default() += 1;
|
||||
}
|
||||
last_own = Some(own);
|
||||
} else {
|
||||
last_enemy = None;
|
||||
last_own = None;
|
||||
}
|
||||
for event in events.into_iter().filter(|event| event.kind == "damage") {
|
||||
assert_eq!(whose, 0, "a damage payout on the enemy's turn: {event:?}");
|
||||
assert_eq!(in_battle, 2, "the walk to the gym has no grass: {event:?}");
|
||||
paid.entry(move_id).or_default().push(event);
|
||||
delays.extend(chose_at.map(|at| frame - at));
|
||||
}
|
||||
let hits = |id: u8| paid.get(&id).map_or(0, Vec::len);
|
||||
if hits(BUBBLE) >= 2
|
||||
&& hits(TACKLE) >= 2
|
||||
&& chosen.get(&TAIL_WHIP).copied().unwrap_or(0) >= 3
|
||||
&& own_drop_turns.values().sum::<u32>() >= 2
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let summary: BTreeMap<u8, Vec<(String, f64)>> = paid
|
||||
.iter()
|
||||
.map(|(id, events)| {
|
||||
(*id, events.iter().map(|event| (event.label.clone(), event.value)).collect())
|
||||
})
|
||||
.collect();
|
||||
eprintln!(
|
||||
"{:.1} brain minutes, {trainer_battles} trainer battle(s). moves chosen {chosen:?}; \
|
||||
enemy HP drops on the fly's turn by move {drops:?}; enemy drops by hWhoseTurn \
|
||||
{enemy_drop_turns:?}; own drops by hWhoseTurn {own_drop_turns:?}; damage paid by move \
|
||||
{summary:?}; frames from the MOVE press to its payout {delays:?}",
|
||||
ms / 60_000.0
|
||||
);
|
||||
assert!(trainer_battles > 0, "the run never reached the trainer's battle");
|
||||
assert!(chosen.get(&TAIL_WHIP).copied().unwrap_or(0) >= 3, "TAIL WHIP was not used");
|
||||
assert!(!paid.contains_key(&TAIL_WHIP), "TAIL WHIP was paid: {summary:?}");
|
||||
for id in [BUBBLE, TACKLE] {
|
||||
let events = paid.get(&id).map(Vec::as_slice).unwrap_or_default();
|
||||
assert!(events.len() >= 2, "move {id:#04x} was not paid twice: {summary:?}");
|
||||
for event in events {
|
||||
assert!(event.value > 0.0 && event.value <= 0.25 + 1e-12, "{event:?}");
|
||||
assert_eq!(event.stimulation_ms, 80);
|
||||
}
|
||||
}
|
||||
// The address, pinned on the cartridge: the fly's hits land on 0, the enemy's on 1.
|
||||
assert_eq!(enemy_drop_turns.get(&1), None, "the enemy lost HP on its own turn");
|
||||
assert!(own_drop_turns.get(&1).copied().unwrap_or(0) >= 2, "{own_drop_turns:?}");
|
||||
assert_eq!(own_drop_turns.get(&0), None, "the fly lost HP on its own turn: {own_drop_turns:?}");
|
||||
// Every drop on the fly's turn was paid, and only those.
|
||||
for (id, count) in &drops {
|
||||
assert_eq!(
|
||||
paid.get(id).map_or(0, Vec::len) as u32,
|
||||
*count,
|
||||
"move {id:#04x}: every drop it caused is one payout"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -202,6 +202,11 @@ fn every_status_mode_reward_kind_and_attachment_the_service_can_emit_is_in_the_s
|
|||
assert_valid(&validator, &serde_json::to_value(&snapshot.header).unwrap());
|
||||
}
|
||||
for rule in flybrain_gb::pokemon_red::catalog::REWARDS {
|
||||
// `damage` publishes no counter (`RewardKind::from_adapter`): its events carry their own
|
||||
// label and no `rewardKind`, which the schema already allows.
|
||||
if rule.kind == flybrain_gb::pokemon_red::catalog::kind::DAMAGE {
|
||||
continue;
|
||||
}
|
||||
let kind = flysim::snapshot::RewardKind::from_adapter(rule.kind).expect(rule.kind);
|
||||
snapshot.header.events[0].reward_kind = Some(kind);
|
||||
assert_valid(&validator, &serde_json::to_value(&snapshot.header).unwrap());
|
||||
|
|
|
|||
|
|
@ -225,6 +225,14 @@ EXTRA_RAM = (
|
|||
'wToggleableObjectFlags',
|
||||
'wToggleableObjectList',
|
||||
'wObtainedHiddenItemsFlags',
|
||||
# The damage reward (`docs/rewards-learning.md`, the operator 2026-09-29).
|
||||
# ExecutePlayerMove loads the executing move into wPlayerMoveNum (STRUGGLE, $a5,
|
||||
# when the cartridge chose it for a Pokemon with no PP), and battle_struct's third
|
||||
# field, wEnemyMonPartyPos, names which enemy party slot is out -- so two Pokemon of
|
||||
# one species and level in a trainer's party are two targets, not one.
|
||||
# services/flysim/tools/resolve_wram.py is the second reading of both.
|
||||
'wPlayerMoveNum',
|
||||
'wEnemyMonPartyPos',
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,15 @@ WANTED = {
|
|||
# poisoning one, and a target that must recharge is put to sleep whatever
|
||||
# its status (MoveHitTest, CheckTargetSubstitute, SleepEffect).
|
||||
'wEnemyBattleStatus2': "the enemy's Mist, substitute and recharge bits",
|
||||
# The damage reward (`docs/rewards-learning.md`, the operator 2026-09-29).
|
||||
# ExecutePlayerMove loads the executing move's six bytes here; the move id is
|
||||
# STRUGGLE ($a5) when the cartridge picked Struggle for a Pokemon with no PP,
|
||||
# which is the one attack the fly did not choose, and pays nothing.
|
||||
'wPlayerMoveNum': 'the move the player is executing this turn',
|
||||
# battle_struct's third field (macros/ram.asm: Species db, HP dw, PartyPos):
|
||||
# which enemy party slot is out, $ff until a trainer's first send-out. It is
|
||||
# what tells a trainer's two Weedles of one level apart.
|
||||
'wEnemyMonPartyPos': "the enemy's party slot",
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue