mwg API
    Preparing search index...

    Function validateSimulationReplay

    • Replays a journal from an initial snapshot and compares deterministic event batches. The initial snapshot is treated as a checkpoint, so any journal it carries is ignored. An optional final-state check catches rules that changed state without emitting an event.

      Type Parameters

      Parameters

      Returns SimulationReplayResult<State, Command, Event>

      import { validateSimulationReplay, type SimulationRuntimeRule, type SimulationSnapshot } from '@datamoc/mw_games/simulation';
      import type { ActionJournalEntry } from '@datamoc/mw_games/core';
      import type { Actor } from '@datamoc/mw_games/roguelike';

      declare const initialSnapshot: SimulationSnapshot<unknown>;
      declare const recordedJournal: readonly ActionJournalEntry<unknown, unknown>[];
      declare const rule: SimulationRuntimeRule<unknown, unknown, unknown, Actor>;
      declare const actorOf: (id: string) => Actor;
      declare const actorId: (actor: Actor) => string;
      const result = validateSimulationReplay(initialSnapshot, recordedJournal, {
      rule, actorOf, actorId,
      });
      if (!result.valid) console.error('replay diverged at', result.mismatch?.index);