# `Cauldron2D.Replay`
[🔗](https://github.com/jaman/cauldron/blob/v0.1.3/cauldron_2d/lib/cauldron_2d/replay.ex#L1)

A record of everything that was done to a world, and the means to do it again.

`Cauldron2D.World` started with `record: true` builds one; `Cauldron2D.World.replay/1`
returns it. `run/4` rebuilds the game from its options and feeds the record back in,
tick by tick, giving the same state the world reached.

    replay = Cauldron2D.World.replay(world)
    state = Cauldron2D.Replay.run(replay, MyGame, [seed: 7], 1 / 50)

Entries are `{tick, action}` where `action` is `{:join, id, props}`, `{:leave, id}` or
`{:input, id, input_state}`, and `tick` is how many steps had run when it happened.

# `action`

```elixir
@type action() ::
  {:join, term(), map()}
  | {:leave, term()}
  | {:input, term(), Cauldron2D.Input.state()}
```

# `t`

```elixir
@type t() :: %Cauldron2D.Replay{
  entries: [{non_neg_integer(), action()}],
  steps: non_neg_integer()
}
```

# `entries`

```elixir
@spec entries(t()) :: [{non_neg_integer(), action()}]
```

The entries oldest first.

# `new`

```elixir
@spec new() :: t()
```

An empty record.

# `record`

```elixir
@spec record(t(), non_neg_integer(), action()) :: t()
```

Add what happened at `tick`.

# `run`

```elixir
@spec run(t(), module(), keyword(), float()) :: term()
```

Rebuild `game` from `game_opts` and apply the record, stepping by `dt` each tick.

# `stepped`

```elixir
@spec stepped(t(), non_neg_integer()) :: t()
```

Note that `steps` steps have run in total.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
