mwg API
    Preparing search index...

    Interface SimulationRuntimeHistoryOptions<A>

    A bounded, generic back/forward step through recent turns - a mode a game opts into (useless in a permadeath roguelike, useful elsewhere), agnostic about what "a turn's state" actually contains the same way SaveSystem is agnostic about what "the save" contains: a game serializes its own turn-scoped state (a Level, a BoardGrid, whatever it has) and this only ever stores and replays snapshots of it, never interprets them.

    Distinct from Recorder/Player (item 42), which replay a whole Input.onAction log deterministically for testing, not a bounded, player-facing "undo my last move".

    import { UndoHistory } from '@datamoc/mw_games/core';

    interface TurnState { x: number; y: number }

    const history = new UndoHistory<TurnState>({ limit: 20 });
    history.push({ x: 0, y: 0 });
    history.push({ x: 1, y: 0 });

    if (history.canUndo) {
    const previous = history.undo();
    }
    interface SimulationRuntimeHistoryOptions<
        A extends Roguelike.Actor = Roguelike.Actor,
    > {
        actorOf: (id: string) => A;
        limit?: number;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index
    actorOf: (id: string) => A

    Resolves scheduler actor ids when an undo or redo restores a checkpoint.

    limit?: number

    states retained before the oldest is dropped; defaults to 50