# Anticipation

> Hold the last reels back when a bonus is one scatter away, so the player watches them land.

Source: https://pixi-reels.schmooky.dev/mechanics/anticipation/

An anticipation tease slows the reels that could still complete a win, so the
player watches them land. Call `setAnticipation(reelIndices, options)` after
`spin()` and before `setResult()`. The named reels run an anticipation phase
before they stop. The set is cleared at the start of every `spin()`.

```ts
const spinDone = reelSet.spin();
const grid = await server.spin();          // ColumnTarget[]
reelSet.setAnticipation(anticipationForScatters(grid, { symbol: 'SCAT', trigger: 2 }));
reelSet.setResult(grid);
await spinDone;
```

The second argument is either a stagger (`0`, a number of ms, a list of ms,
or `'sequential'`) or an options object with `stagger`, `slowdown`,
`duration`, `protect`, `curve` and `cells`. The demos above cover each of
them. The speed profile's `anticipationDelay` sets how long a tease lasts, and a
profile with `anticipationDelay: 0` skips the tease unless you pass
`duration`.

## Demos

## Slow the last reels

Two scatters land on reels 0 and 2, and `setAnticipation([3, 4])` slows the last two reels so they land late.

Live demo (anticipate-a-reel): https://pixi-reels.schmooky.dev/mechanics/anticipation/#anticipate-a-reel

## Choose the reels from scatters

`anticipationForScatters` reads the result grid and returns the reels to tease. The demo alternates its two modes. `'all-remaining'` teases every reel after the one where the scatter count reaches `trigger`, empty reels included. `'scatter-only'` teases only the reels that hold a scatter, and the others stop as usual.

Live demo (scatter-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#scatter-driven-anticipation

## Pacing several reels

### One after another

`setAnticipation(reels, 'sequential')` holds each teasing reel until the one before it has landed, instead of slowing them all at once.

Live demo (staggered-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#staggered--sequential-anticipation

### Slower on each reel

Each teasing reel slows further than the last, from 0.5x to 0.1x of spin speed, holds longer, and lands at that slow speed without returning to full speed first.

Live demo (slowing-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#slowing-anticipation

## Teaser symbol

`setAnticipation` plus a `bufferStart` prefill. A chosen symbol sits in the slot above the window while the slow reels decelerate, so the player sees it approach, but it never lands.

Live demo (anticipation-teaser): https://pixi-reels.schmooky.dev/mechanics/anticipation/#anticipation-teaser

## Turbo

The SuperTurbo profile sets `anticipationDelay` to 0, so a plain `setAnticipation` call skips the tease. Pass a `duration` override and the tease plays in every speed mode.

Live demo (turbo-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#anticipation-in-turbo

## Skipping the tease

### Skip at any point

A long sequential tease. A press mid-tease slams the reels onto the result.

Live demo (skip-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#skip-the-tease

### Protected tease

The same long tease, but the first press only lands the reels around it. `protect: 'once'` makes sure both scatters are on screen and the slowdown has visibly started before a second press can end it.

Call `setAnticipation` before `setResult`. A press before the result arrives is queued by `requestSkip()` and fires the moment the result comes in, so the tease has to be registered by then or there is nothing to protect.

Live demo (protected-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#skip-that-cannot-hide-the-tease

`protect: 'stepwise'` moves the tease on by one reel per press instead of ending it in one go. Partial slams, per-reel spin floors and the case for protecting a tease over slowing the skip are on [Skip and slam](/mechanics/skip/).

## Spine scatter animation

The scatter skeleton's own near-win clips. The leftmost scatter snaps its jaw, the loop holds while the tease runs, and the rightmost plays the result as it lands. Spins alternate between a hit and a miss.

Live demo (spine-scatter-jaw-anticipation): https://pixi-reels.schmooky.dev/mechanics/anticipation/#scatter-jaw-anticipation

## Shaping the slowdown

The default tease only slows down. These demos replace that shape with explicit speed segments, anchor the tease to a number of symbols, or limit acceleration for the whole spin.

### Surge, then crawl

An ease applied to a speed changes the acceleration in one step. With `power2.out` the hardest deceleration is on the first frame, so the reel looks like it was switched to a lower speed instead of slowing down.

`curve` replaces the fixed shape with explicit segments. Speeds are multiples of `spinSpeed`, so `2` is a real surge and `0.08` a crawl. Segment eases default to `power2.inOut`, which ramps the acceleration in and out.

```ts
reelSet.setAnticipation([2, 3, 4], {
  stagger: 260,
  curve: [
    { speed: 2,    duration: 240, ease: 'power2.in' },
    { speed: 0.08, duration: 620, ease: 'power3.inOut', hold: 300 },
  ],
});
```

Passing `curve` and `slowdown` together throws, because `slowdown` is shorthand for a two-segment curve. The profile's `anticipationDelay` still decides whether the tease runs at all, so Turbo needs a `duration` override. The curve's own durations set the length.

Live demo (anticipation-surge-curve): https://pixi-reels.schmooky.dev/mechanics/anticipation/#shape-the-tease-surge-then-crawl

### A curve per reel

Two curves of different lengths have no sensible midpoint, so instead of interpolating, `curve` takes a function, `(order, total) => AnticipationSegment[]`.

`order` is the reel's position in the anticipation set, not its index. `setAnticipation([4, 2, 3], ...)` passes `order: 0` to reel 4, the same as `slowdown` and `protect: 'stepwise'` do.

Live demo (anticipation-curve-per-reel): https://pixi-reels.schmooky.dev/mechanics/anticipation/#a-different-curve-per-reel

### Tease for a number of symbols

`duration` is a time budget, so how far a reel moves depends on its speed. When the tease is timed to symbols passing the window, as in "three more and it lands", use `cells: n`. It ends the tease after n symbol pitches, measured on `reel.travelledCells`, a counter that only goes up and is not reset by the snap at the end of each spin. `cells` also accepts a function of order, like `curve`.

The count applies to the last segment. Earlier segments always play in full, otherwise a fast opening segment could use up the count and skip the ones after it. `duration` is the backstop on that segment, since a reel at rest never reaches a travel target.

Live demo (anticipation-cells): https://pixi-reels.schmooky.dev/mechanics/anticipation/#tease-for-n-symbols-not-n-milliseconds

### Limit acceleration

An ease shapes only the transition it is written for. `motionModel('drive', ...)` limits acceleration instead. Phases set `reel.targetSpeed`, and `Reel.update` moves the speed toward it, so every transition gets the same feel, an interruption is a single new target, and `jerkFrames` ramps the acceleration itself.

```ts
builder.motionModel('drive', { accelFrames: 20, decelFrames: 34, jerkFrames: 260 })
```

The limits are relative to the profile, in frames to reach the active profile's full speed. The presets run `spinSpeed` 30, 50 and 80, so one absolute px/frame^2 limit would make SuperTurbo start slower than Normal. The absolute `{ accel, decel, jerk }` form still works for a game with one profile; mixing the two throws.

It is set at build time and off by default. The default `'tween'` model is unchanged. Landing and a skip press are instant, as they are under `'tween'`. If the drive cannot reach a segment's speed in time, it reports that on the notice channel.

Live demo (anticipation-drive): https://pixi-reels.schmooky.dev/mechanics/anticipation/#the-gas-pedal-bounded-acceleration

## Tease audio

`anticipation:reel` and `anticipation:reelEnd` mark the start and end of a reel's tease, which is where a tension loop starts and stops. `anticipation:segment` (`{ reelIndex, index, total, speed, targetSpeed }`) fires once per curve segment, so a surge can sound different from the crawl after it. For a pitch ramp that follows the actual slowdown, read `reelSet.reels[i].speedNormalized` from your own ticker. It is `1` at full spin speed, `0` at rest and above `1` during a surge.

## Other reel directions

Reel indexes do not depend on orientation, so the anticipation code is the same. Only where the teasing reels sit on screen changes.

### Horizontal set

Scatter-driven anticipation with the reels running sideways. `anticipationForScatters` and `setAnticipation` work as on a vertical set. Reels are stacked down the screen here, so the last two reels are the bottom two rows, and they slow while moving sideways.

Live demo (anticipation-horizontal-scatter): https://pixi-reels.schmooky.dev/mechanics/anticipation/#tension-on-a-horizontal-set

### Teaser on reels that spin up

The teaser on a `direction('reverse')` set. Buffers are geometric, so `bufferStart` is still the slot above the window, and on a reverse reel symbols have already left through that side.

Put the teaser on the feed edge instead. `reel.axis.feedEdge` is `'start'` on a forward reel and `'end'` on a reverse one, so one branch covers both.

Live demo (anticipation-reverse-teaser): https://pixi-reels.schmooky.dev/mechanics/anticipation/#teaser-on-a-reel-that-spins-up

## Faking a near-miss

Place one scatter fewer than the trigger needs and tease the reel that would have held the last one. The result is always a loss.

Some jurisdictions restrict engineered near-misses. Check with compliance before you ship one.

Live demo (near-miss): https://pixi-reels.schmooky.dev/mechanics/anticipation/#fake-a-near-miss
