Pins, boards, Hold & Win
Cell pins across spins, the BoardGrid, the Hold & Win state machine.
Some of the most popular slot features break the basic rule that every cell gets a fresh symbol on every spin. A sticky wild stays where it landed for three more spins while the reels blur around it. In a Hold & Win bonus the coins you have collected lock in place and only the empty cells respin, one at a time, in a wave. An expanding board adds columns mid-feature. Each of those needs a way to say "this cell is claimed" that survives a spin, and a way to show the claimed symbol while everything around it is moving.
This page covers three pieces that together make those features possible, and that games tend to combine. A pin is a claim on one cell: it forces a symbol into every result on that cell for a number of spins. A BoardGrid is a grid where every cell spins on its own, because each cell is a complete one-cell ReelSet. Hold & Win is the bonus game built on both: a pure state machine that knows the rules, and a driver that plays them out on a BoardGrid. The hands-on guides are pins, hold and win, nudge, win animations and multiways; the recipe umbrellas are wilds and pins, hold and win and nudge.
A pin across one spin
A pin does two separate jobs, and it helps to keep them apart. The first is about the result: when you call setResult(grid), the engine rewrites the pinned cell of that grid with the pinned symbol id before the reels use it, so the server's answer never overrides a pin. The second is about the picture: while the reel is spinning, the real symbol in that cell is scrolling away with the rest of the strip, so the set draws a stand-in on top. That stand-in is a pooled symbol placed in the viewport's unmasked container (a layer that sits above the mask, so it is never clipped) at a very high z-index, and it is called the overlay.
Both jobs hang off two set events. On spin:start the set creates the overlays; between that and the stop, setResult() applies the pins to the grid; on spin:allLanded the overlays are destroyed, because the real symbols are now in place, and each pin spends one turn. Figure 1 is that loop. Follow the primary edges round from pin(): a pin with numeric turns goes round once per spin until its count reaches zero and it leaves through pin:expired. A 'permanent' pin never leaves the ring on its own, an 'eval' pin leaves at the very next spin:start (it only lives for one evaluation), and unpin() can pull any pin out at any time.
Moving a pin
Two things can relocate a pin: you, or a board that changed shape. When you call movePin(from, to) between spins, the pinned symbol flies from one cell to the other (400 ms, power2.inOut easing, through the unmasked container so it is visible along the way), the cell it left is backfilled with a random symbol, and the set emits pin:moved with the old position. It only works at rest.
The other case is a MultiWays set, where the number of cells a reel shows can change from spin to spin through setShape(). If a reel shrinks, a pin near its bottom may no longer have a cell. The pin's migration option says what to do. An 'origin' pin moves to the nearest cell that still exists (min(originCell, newCells - 1)) and is moved back later when the reel grows again. A 'frozen' pin stays where it is if the cell still exists, and otherwise clamps to the edge and forgets its original position. Reels are processed top to bottom, pins that can stay claim their cells first, and a pin that loses its cell to another expires with reason 'collision'. Every move emits pin:migrated with { fromCell, toCell, clamped }. Migration happens after spin() and before setResult(), so the result is applied to the new positions.
The pin record
One small record, CellPin, is enough to drive sticky wilds, expanding wilds, Hold & Win coins, multiplier wilds and sticky-win respins; the features differ only in what they pass for turns and what they keep in payload. The record is { reel, cell, symbolId, originCell, migration, turns, payload? }, where turns is a number, 'eval' or 'permanent'. The options you pass to pin() are { turns = 'permanent', payload?, originCell?, migration = 'origin' }; you may pin during a reshape, and originCell then defaults to the cell after the reshape. A pin leaves for one of four reasons, 'turns' | 'explicit' | 'eval' | 'collision', and the reason rides on the pin:expired event.
The table below is the full pin API with the exact rules each method enforces, followed by the places elsewhere in the set that refuse to disturb a pinned cell.
| Method | Behaviour |
|---|---|
| pin(reel, cell, symbolId, opts?) | Throws during a nudge or on an out-of-range cell; negative cells are rejected, buffer cells go through setResult. At rest it asserts a big symbol fits, applies the symbol immediately through _placeCellsAtRest (a pin on a block cell replaces the block) and emits pin:placed. Mid-spin it creates an overlay. Re-pinning the same cell is silent: no pin:expired, the old overlay is destroyed. |
| unpin(reel, cell) | Removes the overlay and emits pin:expired(pin, 'explicit'). Does nothing if there is no pin. |
| pins / getPin(reel, cell) | A ReadonlyMap keyed "reel:cell" (pinKey). During a spin it reflects the next setResult. |
| movePin(from, to, opts?) | Only at rest. Throws if from has no pin, to is out of range, or to already has a pin; from === to still emits pin:moved. Updates the map atomically (originCell = to.cell), destroys the overlay at from, backfills the vacated cell, flies a pooled symbol through viewport.unmaskedContainer, places the pin, releases the flight symbol, emits pin:moved(movedPin, from). Options: duration 400, easing 'power2.inOut', backfill (random by default), onFlightCreated, onFlightCompleted. Hook throws are logged as pin-hook-threw, never thrown. |
| refreshPinOverlaysForReel(reelIndex) | Called automatically after the AdjustPhase. Call it yourself only after a custom layout change. |
| guards elsewhere | |
| setSymbolAt | throws on a pinned cell |
| nudge | throws if any pin is on that reel |
| splitSymbol | throws if a pinned cell is in the split range |
| setColumn | the new column must show the pinned symbol at its cell; a pin past the new length expires |
| removeReels, removeRows, resetColumns | pins past the end expire with 'explicit' |
If you draw your own art on the board, you need to know where the overlay sits in the stacking order. The budget is { symbolLayer: 100, pinOverlay: 10000 } (Z_INDEX_BUDGET in config/types.ts): an ordinary symbol's default z-index is its symbol z-index times 100 plus its array index, so no ordinary symbol can ever climb above a pin overlay. Art that must sit above pins goes into viewport.spotlightContainer instead.
Growing and reshaping a board
Four methods change the board's geometry at rest, and all of them know about pins. expand() adds reels one step at a time and is the basis of infinity-reels features. setColumn() changes how many cells one reel shows. splitSymbol() breaks one symbol into several cells. resetColumns() puts everything back. The table gives each one's behaviour and the rules around it.
| Method | What it does | Rules and edges |
|---|---|---|
| expand({ columns, step?, onStepAdded?, onStepLanded?, anticipation?, mode?, signal? }) | Adds reels one step at a time while the existing reels hold still: the infinity-reels feature. Validation happens first, so a throw leaves the board untouched. Per step the engine adds the reels (reels:added, expand:stepAdded), awaits your onStepAdded, spins with every older reel held, lands, emits expand:stepLanded and awaits onStepLanded. It ends with expand:complete then expand:end('complete'), or expand:end('failed'). | step defaults to 1 and is widened, never split, so a big symbol always fits whole. Aborting the signal fast-forwards: the step in flight slams and the remaining columns land in one last step flagged fastForward: true. A skip carries across steps. While it runs, spin(), addReels() and removeReels() throw, and addRows() is only allowed inside onStepLanded. All steps are one round, so pins are not spent per step. |
| setColumn(reel, column, { height? }) | Shows column.visible.length cells on one reel at rest. The default 'grow' keeps the cell size and re-anchors the board; 'keep' keeps the reel's height and resizes cells to (extent - (n - 1) x gap) / n. Only the changed cells are replaced. Emits column:set, then pin:moved for any pin that shifted. | On a MultiWays set 'keep' is the default, 'grow' throws, and the count must stay within [minCells, maxCells], because MultiWays owns the reel height. |
| splitSymbol(reel, cell, ids) | Splits a 1x1 symbol, or a one-reel-wide stacked block, into ids.length cells. Pins below the split shift down with their symbols. | It goes through the same _setColumn path as setColumn, so the events and the pin handling are identical. |
| resetColumns() | Returns every reel to the cells and cell size it was built or added with, undoing setColumn, splitSymbol and addRows. | Safe to call at round start after removeReels(). Not available on MultiWays. addRows() and removeRows() emit rows:added and rows:removed. |
BoardGrid layering
A BoardGrid is what you reach for when cells, not columns, are the unit of play: Hold & Win, a coin collector, a bingo-style board. It is a grid of independent one-cell ReelSet instances laid out at (reel x (cellWidth + columnGap), cell x (cellHeight + rowGap)), each with its own mask. The grid is mechanism only. It knows nothing about coins, locks, rules or hit areas; games build those on top from cellBounds(). What it does provide is a fixed stacking order and three presentation primitives that work across cells.
Figure 2 shows the five layers, bottom to top. The chrome is a per-cell background you draw once. The cells are the reel sets. Above them, _lifted is a render layer where every cell's unmasked art is attached, so a symbol can poke outside its cell. The dim layer holds the black rectangles that dim() draws over losing cells. And _promoted is where a cell goes when you lift() it: above everything, including the dim, which is how a winning coin stays bright while the rest of the board darkens. The API table that follows the figure has the details of each call.
These are the constructor options. Most are forwarded straight to the builder of every cell, so anything you can configure on a reel set you can configure here.
| BoardGridOptions | Default | Meaning |
|---|---|---|
| cols, rows | required | board size |
| cellSize | required | a number or { width, height } |
| gap, columnGap, rowGap | 4 | columnGap and rowGap fall back to gap |
| emptyId | 'empty' | an EmptySymbol is auto-registered |
| symbols, weights, symbolData, rng | forwarded to every cell builder | |
| ticker | required | the constructor throws without it |
| chrome(g, w, h) | none | per-cell background drawn below the cell |
| mask(cell, { cols, rows, corners }) | SharedRectMaskStrategy | corners lets RoundedRectMaskStrategy round only the outer corners |
| orientation, direction | vertical, forward | the axis each cell strip travels on; the board layout does not change |
| profiles | { default: NORMAL + minimumSpinTime 320 } | name to profile, or a per-cell function |
| symbolZIndex, cellZIndex(ctx) | none | order symbols inside a cell; order the cells lifted art |
And this is the grid's API. The three presentation calls each hand back a release function, which is the pattern for "undo this when the feature ends".
| BoardGrid API | Behaviour |
|---|---|
| lift(cell) → release | Moves the cell lifted art into _promoted. Reference-counted per cell; release is idempotent. Separate from zIndex, so it survives refreshCellZIndex. Also liftedCells and releaseAllLifts(). |
| dim({ except?, amount = 0.5, fade = 180 }) → release | One black rect per non-excepted cell, faded over fade × |delta| ms on the ticker. A second dim while one is up throws. Also dimmedCells and clearDim(). |
| dimSymbols({ except?, amount, fade }) → release | Darkens view.tint toward black (0.5 gives 0x808080). Watches symbol:created so a swapped-in symbol arrives dark and a departing one is cleaned before pooling. Owns view.tint while active. Also dimmedSymbolCells and clearSymbolDim(). |
| refreshCellZIndex() | Re-asks cellZIndex({ symbolId, cell, cols, rows, atRest, attachOrder }) for every cell. Runs on every place and every landing. |
| cells(), cellBounds(cell), cellCenter(cell) | Reel-major order; board-local bounds (use container.toGlobal for stage space). |
| symbolAt(cell), reelAt(cell), setProfile(cell, name) | The live ReelSymbol, the underlying 1x1 ReelSet, the profile selection. |
| place(cell, id) | Instant, empty buffers, then refreshCellZIndex. |
| spinCells(targets: { cell, id }[], onLanded?) | Per target: spin(), setResult with empty buffers, await, refreshCellZIndex, await onLanded. All cells run concurrently; resolves after every cell landed and its after-land work finished. |
| skipSpinning(options?) | Returns the in-flight count; swallows "no result yet" errors. |
| destroy() | Releases lifts and dims, then destroys every reel set. |
Inside each cell the viewport has its own small stack, in order: maskedContainer (the strip, clipped), unmaskedContainer (sortable, above the mask), spotlightContainer, promotedLayer and dimOverlay. When you need a cell's rectangle, ReelSet.getCellBounds(reel, cell) returns set-local bounds including the viewport offset; on a curved reel that is the bounding box of a trapezoid, and getCellQuad gives you the four corners.
The Hold & Win state machine
Hold & Win has rules that are easy to state and easy to get subtly wrong: a coin that lands locks in place; any lock resets the respin counter; a wave with no new coin costs a respin; the feature ends when the board is full or the respins hit zero. The library keeps those rules in one place, HoldAndWinState, a pure reducer with no PixiJS in it. Every derived value is computed from the ledger rather than cached: capacity = all - inactive, isFull = locked.size === capacity. That makes the rules testable in isolation and impossible to drift from the picture. HoldAndWinBoard is the driver: it composes the reducer with a BoardGrid, spins the cells, reports each landing back to the reducer and replays the reducer's effects as events on board.events.
Figure 3 is the reducer's life. It starts idle. enter(seed) places the first coins and makes it active. Each beginWave() opens one wave of respins, and endWave() or abortWave() closes it. Notice that land() is only honoured while spinning: a landing that arrives after an abort is dropped rather than corrupting the ledger.
endWave() is where the rules live, and it applies them in a fixed order. If the wave produced any hit, respins resets to the default and respins:changed fires with reason 'hit-reset'; if not, it decrements, never below zero, with reason 'miss'. The phase goes back to active and respin:end { round, hits, respinsLeft } fires. If the board is now full, board:full { coins } fires. And if the board is full or respins are zero, the phase becomes idle and feature:end fires. The other reducer calls guard themselves: enter(seed) only works from idle and needs active, unique seed cells (the round counter restarts at 0); release(), activate() and swap() throw during a wave; reset() clears the ledger, restores inactive cells and emits only feature:reset; beginWave() throws on an inactive, locked or duplicate hit.
Figure 4 is what the driver does for one wave when you call respin(hits). It opens the wave, picks a speed profile per cell, announces the wave, spins the free cells through the grid with a diagonal stagger and reports each landing, then closes the wave.
The "pick profile" step is how the board builds tension. For each speed you register, the constructor registers two per-cell profiles, the plain one and a name:tension variant that spins 1100 ms longer (TENSION_EXTRA_MS). Each cell's minimum spin time is the profile's (default 320 ms) plus its share of the stagger, so the wave lands diagonally. Your anticipateWhen() callback is asked once per wave, against the state before the wave, and decides whether the tense variant is used; it only matters if at least one cell is spinning. When a coin locks, the driver plays the lock animation: 'win' waits for the symbol's landing animation to finish first, 'landing' does not replay it, and a failure is logged as hw-coin-<anim>-failed rather than thrown.
The two tables below are the builder's defaults and the board's methods. Most of the board's methods are either pass-throughs to the reducer or to the grid; the ones that throw mid-wave do so because the ledger must not change while landings are still arriving.
| HoldAndWinBuilder | Default |
|---|---|
| grid | 5 x 3 |
| cellSize | 72 x 72 |
| columnGap, rowGap | 4 |
| emptyId | 'empty' |
| inactive | [] (inactive id defaults to the empty id) |
| respins | 3 |
| lockAnimation | 'win' (or 'landing', 'none', or a per-coin function) |
| speeds | { normal: NORMAL + minimumSpinTime 320 + stopDelay 70 } |
| initialSpeed | 'normal' |
| stagger | (reel + cell) × profile.stopDelay, a diagonal wave |
| skipMode | 'slam' |
| axis | vertical, forward |
| TENSION_EXTRA_MS | 1100, added to minimumSpinTime for the name:tension profile |
| HoldAndWinBoard | Behaviour |
|---|---|
| enter(seed) | The reducer validates first, then the board places the coins and replays the effects. |
| respin(hits) | One wave; see the diagram. On a throw: abortWave() plus grid.skipSpinning(), then rethrow. |
| setSymbolAt(cell, id, data?) | Locked cells only. Throws inside a coin:locked listener, because the wave is still in flight. |
| setSpeed(name), addSpeed(name, profile) | Updates every cell; keeps the tension variant if a tense wave is in flight. |
| playWin(cells?), activate(cells), release(cells) | Pass-throughs to the lock animation and the reducer; release and activate throw mid-wave. |
| skip({ mode?, speed?, payload? }) | Emits feature:skip and returns the in-flight count. |
| reset() | Releases lifts, clears dims, places empty on every cell, re-dresses inactive cells. The reducer emits only feature:reset, never coin:released. |
| lift, dim, dimSymbols, cellBounds, cellCenter, symbolAt, reelAt, refreshCellZIndex | BoardGrid pass-throughs. Lifts and dims survive a respin() and are released by reset() and destroy(). |
The builder's other methods are grid, cellSize(size, { gap, columnGap, rowGap }), symbols (required), weights, emptyId, inactive(cells, id?), symbolData (merged; { unmask: true } is the headline use), respins, lockAnimation, symbolZIndex, cellZIndex, speedProfile, speeds, initialSpeed, skipMode, stagger, anticipateWhen(fn), cellChrome, cellMask, axis, ticker (required) and rng. build() throws without symbols or ticker, or if initialSpeed names no registered profile.
The board talks back on its own bus, one object per event: feature:enter, respin:start, cell:landed (in stagger order), coin:locked, coin:released, respins:changed, respin:end, board:full, feature:skip, feature:reset, feature:end, cells:activated and speed:changed. The payloads are on the events page. A coin is HwCoin { readonly cell, readonly id, data? }: the board owns cell and id, and data is yours to mutate, for a coin's value or multiplier.
Nudge, in short
A nudge moves one landed reel by a few cells, feeding new symbols in from one end, the way a mechanical slot "bumps" a reel one notch to complete a line. ReelSet.nudge(reel, options) does that at rest. You give it a distance (a positive whole number of cells, below the strip's capacity), a direction of 'forward' or 'reverse' relative to the reel's own travel axis, and the incoming symbols, which must be exactly distance long, listed in start-to-end order, and may overflow into the buffer cells. The defaults are a duration of 200 ms per cell and a 'power2.out' ease with its overshoot clamped, and you can add a startDelay, a custom ease or an abort signal.
The engine refuses a nudge while a spin, a refill or an expand step is in flight, on a reel whose bufferEnd is 0, or if any pin sits on that reel. While a nudge runs, the reverse is also true: spin, setResult, pin, setShape and resizing all throw. The set emits nudge:start after the incoming symbols are placed, so what the event reports is what is about to animate, and then either nudge:complete with the new visible column or nudge:cancelled with a reason and an AbortError rejection. The reel's own bus sees phase:enter('nudge') and phase:exit('nudge'). skipNudge(reel?) fast-forwards and still resolves normally. A nudge is deliberately per reel; to nudge several, run them with Promise.all.
Presenting wins
The engine never decides what a win is (ADR 007), but it does give you three ways to show one once you have decided. WinPresenter runs a whole sequence of wins, cycling through them with the losers dimmed. SymbolSpotlight is the single-highlight primitive it is built on. promote() is the lightest of the three: it lifts symbols above the mask without dimming or animating anything. A Win is just { cells, value?, kind?, id? }, and the order of cells matters when a stagger is set.
wins/WinPresenter.ts. show(wins) aborts any previous run, sorts by value (sortByValue: true), emits win:start, then per win per cycle dims losers (dimLosers alpha 0.35), emits win:group, then win:symbol per cell spaced by stagger (0) and plays symbolAnim ('win', a named animation, or a function). cycleGap 400 ms, cycles 1 (-1 infinite). win:end fires in finally. In a cascade, call it from presentWinners.
reelSet.spotlight. show(positions) emits spotlight:start, dims the viewport (dimAmount 0.5), reparents each view into viewport.spotlightContainer (promoteAboveMask true), and awaits playWin() (playWinAnimation true). hide() reparents back, skipping views the pool recycled, and emits spotlight:end. cycle(lines) shows each for displayDuration 2000 ms with gapDuration 300 ms, cycles 1.
ReelSet.promote(positions) → release is the non-reparenting alternative. It attaches the views to viewport.promotedLayer (a RenderLayer), prunes itself on symbol:created when a swap hands the cell a new instance, and does no dim and no playWin. The engine never computes or draws wins (ADR 007); a Win is { cells, value?, kind?, id? } and the order of cells matters when stagger > 0.
Where this lives
pins/CellPin.tsCellPin, CellPinOptions, MovePinOptions, PinExpireReason, pinKeycore/ReelSet.tspin, unpin, movePin, _onSpinStart, _onSpinLanded, _applyPinsToGrid, _migratePinsForReel, nudge, expand, setColumn, splitSymbol, resetColumns, promotecore/expand.tsExpandStep, ExpandStepLanded, ExpandResult, planExpandSteps
board/BoardGrid.tsthe grid,board/HwTypes.tsevents and coin typesboard/HoldAndWinState.tsthe reducer,board/HoldAndWinBoard.tsthe driver,board/HoldAndWinBuilder.tswins/WinPresenter.ts,spotlight/SymbolSpotlight.ts,config/types.tsZ_INDEX_BUDGET, Win