Sandtris

How the Sand Works in Sandtris: Grains, Shapes and Settling

Published · Updated · 3 min read

Sandtris looks simple: a block drops, lands and falls apart into sand. Under that is a small grid simulation. This post explains how it works, using numbers taken from the game's own settings, and what that means when you play.

The field is a grid of grains

The playing field is a grid 94 grains wide and 153 grains tall. Each square of a block is made of 8 by 8 grains, so a two-by-two block brings 256 grains onto the field when it lands. Every grain has a colour and a position on the grid, and the whole picture you see is drawn from that grid.

Each grain also gets a slightly different shade of its block's colour, and the edges of a falling block are drawn lighter or darker. That is why a pile of one colour looks grainy instead of flat.

The five block shapes

Sandtris does not use the seven classic Tetris pieces. It has five shapes:

  • a two-by-two square
  • a straight line four squares long
  • a plus sign made of five squares
  • an L-shaped piece three squares tall
  • an S-shaped piece two squares tall

Shape and colour are picked at random for each block. There is no rotation key: each shape always falls the way it appears in the Next box, so you plan around its fixed outline.

How grains fall and settle

Every frame, the game works up from the bottom row and tries to move each grain down into an empty cell below it. When the cell straight below is full, a grain can roll to one side diagonally, and some grains are allowed to roll further than others. The grains in each row are handled in a shuffled order every frame, and rolling is partly random, so a pile spreads unevenly instead of making the same neat pyramid every time.

In practice:

  • A block dropped onto a peak splits and runs down both sides.
  • A block dropped into a dip mostly stays together and fills it.
  • Sand keeps sliding for a moment after the landing, so a layer can reach a wall a little after the block hits.

How the game spots a clear

A separate routine checks the field a few times a second for groups of same-coloured grains that touch by an edge. A group counts once it spans the field from the left wall to the right wall and has more than 99 grains. Because the check runs on a short timer rather than at the moment of landing, a clear often starts a beat after the sand stops.

Because grains join only side by side or above and below, a single grain of another colour wedged between two greens is enough to keep them apart. Clean layers are worth more than they look.

Aiming with the shade

While a block waits at the top, a column of its colour fades down the field beneath it. That shade shows exactly where the block will fall, and it moves when you move the block. Line its edges up with the pile before you drop. Once a block is falling it goes straight down. In Classic it cannot be steered after you drop it, so the shade is your one chance to aim. In Speeding the block keeps following your pointer while it falls.

When a block lands, the field gives a short shake and a sand sound plays. The next block appears about half a second later.

More from the blog

Play nowSandtris — the full game, free