# Prediction: mispredict event

> The mispredict event of the Prediction interface fires after each replay that found a misprediction.

The **`mispredict`** event of the [`Prediction`](/docs/client/prediction) interface fires after each replay that found the room's state different from the prediction in a field the stepper writes.

## Syntax

```ts
addEventListener("mispredict", (event) => {})
```

## Event type

A `CustomEvent`. Its `detail` is an object with these properties:

`tick`
: A number: the room tick of the state the prediction replayed from.

`fields`
: An array of strings: the fields of the predicted entity that differed.

`delta`
: An object with a number for each numeric field that differed: the prediction's value less the replayed one, which [`render()`](/docs/client/prediction/render) smooths away. An `angle` field's delta is taken the short way round.

## Description

The event fires after the replay, once [`mispredictions`](/docs/client/prediction/mispredictions) has counted it. A field no step writes never appears in `fields`, and a `quat` field appears in `fields` with no `delta`.

## Examples

### Logging mispredictions while tuning a stepper

While a platformer's jump is tuned, each misprediction is logged with how far off it was.

```ts
// tune-jump.ts
import type { Prediction } from "@irtio/client";

export function logMispredictions(me: Prediction<unknown>, signal: AbortSignal): void {
  me.addEventListener(
    "mispredict",
    ({ detail: { tick, fields, delta } }) => {
      const sizes = fields.map((f) => `${f} ${delta[f]?.toFixed(3) ?? "changed"}`);
      console.warn(`mispredicted at tick ${tick}: ${sizes.join(", ")}`);
    },
    { signal },
  );
}
```

Aborting `signal` removes the listener once tuning is done.

## See also

- [`Prediction.drift`](/docs/client/prediction/drift)
- [`Prediction.mispredictions`](/docs/client/prediction/mispredictions)
- [Client prediction](/docs/client/guides/prediction#predicting-on-the-client)
