← Back to Game

How Flood-Fill Works

Flood Cube is built on one of the most widely used ideas in computer graphics: flood-fill. It is the same operation behind the "paint bucket" tool in every image editor. Understanding how it works — and why turning it into a minimum-moves puzzle makes it genuinely hard — makes the game more rewarding to play and its strategy easier to reason about.

The paint-bucket idea

Picture clicking the paint bucket on one cell of a coloured grid. The tool changes that cell, then spreads outward to every neighbouring cell of the same original colour, and their neighbours, and so on — stopping only where the colour changes. What it fills is a connected region: the set of cells you can reach from the starting cell by stepping between same-coloured neighbours. Flood Cube uses exactly this operation, except your click recolours your entire current region and everything newly connected to it.

The algorithm: BFS and DFS

Under the hood, flood-fill is a graph traversal. Treat each cell as a node with edges to its adjacent cells. Starting from one node, you visit everything reachable through same-coloured edges. There are two classic ways to do this:

Either way the cost is modest: every cell is visited at most once, so filling a board of N cells takes time proportional to N. The fill is easy. What is hard is choosing the sequence of colours.

Why "Flood-It" puzzles are hard

The puzzle version of flood-fill — recolour the whole board to a single colour in as few moves as possible — is the game popularised as "Flood-It". Finding the shortest possible solution is not just fiddly; it is computationally hard. Researchers have shown that the general problem (on boards with enough colours) is NP-hard: as the board grows, no known method is guaranteed to find the optimal move sequence quickly, and the number of possible sequences explodes far too fast to simply try them all.

That is precisely what makes it a good puzzle. A simple "always take the biggest gain" (greedy) strategy is fast and usually decent, but it is provably not always optimal — there are boards where a weaker-looking move leads to a shorter overall solution. The space between "good enough" and "optimal" is where the skill lives, and it is why a tight move budget creates real tension rather than busywork.

What changes in 3D

Traditional Flood-It plays on a flat square grid. Flood Cube wraps the same mechanic around the six faces of a cube. The algorithm is identical — it is still BFS over connected same-coloured cells — but the adjacency is richer. Cells along a face's edge are neighbours with cells on the adjoining face, so your region can spill around corners onto surfaces you cannot currently see.

This has two consequences. First, the connected regions are larger and less intuitive than on a flat grid, so a single well-chosen colour can absorb chunks of three faces at once. Second, you cannot evaluate a move from one viewpoint — the decisive cells are often on hidden faces. That is why rotating the cube before every move is not a nicety but a core part of solving it well. We cover the tactical side of this in the Strategy Guide.

How Flood Cube uses all this

Each cube is procedurally generated as a connected colour layout, then paired with a "Par" move budget. Because a connected board can always be reduced to one colour, a solution always exists — so the design question is never "is it solvable?" but "how tight should the move budget be?" We calibrate Par from aggregate results across real players, aiming for a level that is beatable with good play but genuinely punishes careless moves. The daily cubes are generated from a fixed seed derived from the date, which is why every player worldwide faces the identical puzzle on a given day — the deterministic maths of the generator is what makes the shared daily leaderboard fair.

Want to try the theory in practice? Play today's cube, read the Strategy Guide, or start with the basics in How to Play.