Phaser AE

Slide-merge puzzles

Pro packv3.0.0-32DGrid

The rules of the slide-and-merge number puzzle: every tile shifts as far as it can in one direction and matching neighbours combine on the way. Each move returns a per-tile script for your game to animate, and a hint plays well without ever changing what the game would have done.

This is a Pro pack. Upgrade to Phaser Pro to use it in your games.See Phaser Pro →

Released October 14, 2026 · updated October 20, 2026

Slide-merge puzzles: a screenshot of its demo
A note about these graphics

Expansion packs don't come with graphics. This screenshot is one way of drawing what the pack does, made for its demo: none of the sprites, tiles or backgrounds in it are in the pack.

That's by design. A pack is a game's logic, mechanics and effects, and it works with whatever art you give it. Some packs draw effects, backdrops or 3D scenes of their own, but none carries a game's sprites.

So the look is yours. Make the art on phaser.io, bring your own, or let your agent draw it in code: the same pack can look like anything.

What it does

You create a board from a config and call move with a direction. The board slides every tile, merges the pairs your rule allows, spawns the next tile and returns what happened: each tile's from and to cell, each merge with the surviving tile and the one removed, the spawn, the score gained, and whether the game is won or over. That script is what lets a presenter slide the tiles first and then pop the merges, instead of cutting straight to the new board. Tile ids are stable, so a sprite can follow its tile from move to move.

The family differs in three places, and each is a dial. A tile slides all the way or one cell. A merge is any rule you write as a function of two values, returning the merged value or nothing: equal values summing, or a one and a two making three. New tiles appear in any empty cell or on the edge the board was swiped from, drawn from weighted values or a shuffled bag, and the next one can be shown in advance. A tile that has just merged cannot merge again in the same move, so a row of four equal tiles makes two, not one.

Everything is deterministic from a seed: the same moves always bring the same spawns, so a replay is the move list and undo is a replay to the move before. suggest returns a good move by trying real moves and then rewinding everything, the random generator included, so a hint never changes the game or makes a replay diverge.

Features

  • Two classic configs — config2048 and configThrees set up the two classic rule sets on a 4 by 4 board, and both take overrides.
  • Slide-then-pop records — every move returns tile moves, merges, the spawn, the score gained, won and gameOver.
  • Any merge rule — canMerge is a function, so equal-pairs, sums, or a rule of your own.
  • Spawn policies — anywhere empty or only on the swiped-from edge, from weighted values or a bag, with an optional preview read by peek.
  • Any board size — cols and rows, a number of starting tiles, and a win value that flags a win while play continues, or none.
  • Stuck test — legalMoves lists the directions that would change anything; none means the game is over.
  • A hint that looks ahead — suggest weighs empty room, ordered runs, smooth neighbours and keeping the biggest tile in a corner, against the worst possible spawn.
  • Tunable strength — at the default depth of two it averages about 15,400 points and reaches the 2048 tile, at about a third of a millisecond a call; depth three scores a little more at forty-six times the cost.
  • Autoplay — plays a board out with the hint, or with a quick simple policy for producing a dead board in a test.

Good for

  • Slide-and-merge number puzzles in the style of 2048, with any board size and win target.
  • One-step sliding variants in the style of Threes, where tiles move one cell and a one and a two make three.
  • Themed merge puzzles, where the numbers stand for fruit, gems or creatures and your own merge rule decides what combines.
  • Hint buttons, tutorials and attract modes, using suggest to show a sensible move or play the board on a title screen.
  • Balancing a variant, by autoplaying many seeds of a config headless and comparing scores.
  • 3D boards, since the rules hold no sprite or clock and a 3D presenter animates the same records.

Make it yours

A board is a SlideConfig: the columns and rows, the seed, the slide distance (step, 'full' or 'one'), the merge rule (canMerge), the spawn policy, the number of starting tiles and the win value. Start from either preset and override what you need, or write one from scratch.

Three materially different games from the same pack:

  • The 2048 preset on a 5 by 5 board with a win value of 4096, for a longer game.
  • The Threes preset, where tiles step one cell, spawn on the edge the player swiped from and are previewed before they arrive.
  • A custom config where tiles slide all the way, spawns come from a shuffled bag, and canMerge turns two equal values into the next value up, a ladder of items your game names and draws.

The hint is tunable too: depth sets how far it looks ahead, and corner chooses which corner it stacks the big tiles into.

A quick look

A 2048 board, a move to animate, and a hint:

const board = game.slide.createSlide(game.slide.config2048({ seed: 7 }));
const r = board.move('left');
if (r.valid) {
    for (const m of r.moves) slideSprite(m.id, m.from, m.to);
    for (const g of r.merges) pop(g.intoId, g.goneId, g.value);
    if (r.spawn) appear(r.spawn.id, r.spawn.at, r.spawn.value);
}
const hint = board.suggest({ depth: 2 });   // 'left' | 'right' | 'up' | 'down' | null

Works with

  • tween — to slide the tiles and pop the merges from each move's records.
  • vector-2d or world-3d — to draw the board flat or as a 3D scene.
  • match3 — when tiles should be swapped to make lines instead of slid.
  • faller — for games built on falling pieces.

Good to know

  • There is no animation and no clock: a move resolves instantly and you animate the records.
  • The board has no undo call of its own; undo is a replay of the move list from the seed.
  • A board with no legal move is over, but what that means for your game, a retry or a score screen, is yours to decide.
  • The hint is strong but not perfect: at depth two it averages about 15,400, and each extra level of look-ahead multiplies its work by roughly four times the number of empty cells.

More Grid packs

Show all →