Prediction: mispredictions property
Available since
@irtio/client 5.0BrowsersNodeThe mispredictions property of the Prediction interface is how many replays found the room’s state different from the prediction in a field the stepper writes.
Value
A number, 0 when the prediction starts. The prediction adds 1 for each replay that mispredicts. Setting it, such as to 0 at the start of a round, sets the count it adds to.
Description
A field no step writes, such as a score only room code sets, is the room’s: its changes never count. For the fields and sizes of each misprediction, use the mispredict event, and for a summary of recent ones, drift.
Examples
Counting mispredictions per round
A racing game logs how many times prediction missed in each race.
// race-stats.ts
import type { Prediction } from "@irtio/client";
export function endRace(me: Prediction<unknown>, race: number): void {
console.log(`race ${race}: ${me.mispredictions} mispredictions`);
me.mispredictions = 0;
}
See also
Runtime availability
| Browsers | Node | |
|---|---|---|
mispredictions | 5.0 | 5.0 |