Klotski (Huarong Path)

The legendary Chinese sliding-block escape puzzle — free Cao Cao through the bottom exit. 12 classic layouts, solver-proven optimal counts, ranked scores.

How to play Klotski (Huarong Path)

Klotski is the world-famous sliding-block escape puzzle, known in China as Huarong Dao (华容道) — the “Huarong Trail”. Ten wooden blocks of four different sizes are packed into a small 4×5 frame with only two empty cells, and your task is to slide them around until the big 2×2 hero block — the warlord Cao Cao — escapes through the gap at the bottom-centre of the frame. Nothing is ever lifted or rotated: blocks only slide up, down, left and right into empty space. What sounds like a children’s toy is in fact one of the deepest sliding puzzles ever devised — the classic arrangement needs 90 moves even when played perfectly. This version ships twelve classic-family layouts grouped into Easy, Medium and Hard, each with a computer-proven optimal move count to chase, plus a move counter, a timer, unlimited undo and ranked scores.

The goal

Slide the other blocks out of the way until the amber 2×2 Cao Cao block reaches the bottom-centre of the board and covers the two cells directly above the marked exit. Only Cao Cao can escape — every general and soldier is merely an obstacle to be shuffled aside. Try to match the layout’s optimal move count and finish quickly: fewer wasted moves and fewer seconds mean a higher score.

The story: escape along the Huarong Trail

The puzzle dramatises one of the most retold episodes of the Chinese Three Kingdoms saga. After his crushing defeat at the Battle of Red Cliffs in AD 208, the northern warlord Cao Cao fled with the remnants of his army along the narrow, muddy Huarong Trail. There the general Guan Yu lay in ambush with a handful of soldiers — a perfect chance to finish Cao Cao once and for all. But Guan Yu owed Cao Cao a debt of kindness from years before, and honour won out: he let his enemy pass. The puzzle casts the tale in wood: Cao Cao is the big block struggling to escape, Guan Yu is the long horizontal block so often lying across his path, and four generals and four soldiers crowd the trail. The same mechanical puzzle is known in the West as Klotski (from a Polish word for wooden blocks) and in Japan as Hakoiri Musume.

The board and the pieces

The frame is 4 columns wide and 5 rows tall. The traditional set has ten blocks: one 2×2 hero (Cao Cao), one 2×1 horizontal general (Guan Yu), four 1×2 upright generals (Zhang Fei, Zhao Yun, Ma Chao and Huang Zhong) and four 1×1 soldiers — leaving exactly two empty cells to manoeuvre through. Pick one of the twelve starting layouts from the selector, grouped by difficulty, each showing its optimal move count beside its name. The centuries-old traditional arrangements — such as the notorious “Sword at the Ready” (横刀立马) — keep their historic names; the rest are our own arrangements of the same classic piece set. Every shipped layout has been verified solvable by an exhaustive computer search. The timer starts on your first slide, not when the board appears, so study the position as long as you like.

How to move blocks

  • Drag: press a block and drag it toward the empty space — it slides one cell at a time, and a longer drag keeps it sliding as far as the space allows.
  • Tap-then-arrows: tap a block to select it (blue outline), then slide it with the arrow keys or WASD. A quick tap on a block that has exactly one legal direction slides it there immediately.
  • Blocks slide only up, down, left or right into empty cells. They never rotate, never lift out of the frame and never overlap — a block with no free cell beside it simply cannot move.
  • Move counting is classic: sliding the same block several cells in one straight line counts as a single move. Changing direction, or moving a different block in between, starts a new move. The counter always shows your moves next to the layout’s optimal.
  • Made a mess? Undo takes back one step at a time (the move counter rewinds with it, even inside a merged multi-cell move), and Restart returns the layout to its starting position with the counter and timer cleared.

Winning and scoring

You win the instant Cao Cao’s block occupies the two bottom-centre columns of the last two rows — parked squarely on the marked exit. A banner shows your move count against the optimal, your time and your score, which is submitted automatically to the leaderboard bucket of the layout’s difficulty (Easy, Medium or Hard). Your best score on this device is remembered per difficulty, and signing in puts your results on the global rankings too.

Strategy tips

  • Think in terms of the two empty cells, not the blocks. Each position offers only a handful of legal slides; before every move, ask where the “bubble” of empty space must travel so that the next big block can move.
  • Cao Cao moves at a glacial pace — he needs a corridor two cells wide. Most of the game is spent ferrying soldiers and generals aside to dig that corridor ahead of him, one flank at a time.
  • The horizontal Guan Yu block is usually the crux: like Cao Cao he needs a 2-wide space, and he loves to end up guarding the exit. Decide early where Guan Yu will finally rest — usually flat against the bottom or a side wall — and walk him there before bringing Cao Cao down.
  • Soldiers are your most mobile pieces: 1×1 blocks can tuck into corners the big pieces cannot use. Park them in dead corners, and keep the two empty cells adjacent to each other whenever a big block has to pass.
  • Chasing the optimal count? Exploit the counting rule: one straight multi-cell slide is a single move, so plan long slides instead of two separate nudges — and use Undo freely, the counter simply rewinds with it.

Frequently asked questions

How is the score calculated?

Score = max(1, 12000 − seconds − (moves − optimal) × 15). You start from 12,000 points; every second costs 1 point and every move beyond the layout’s proven optimal costs 15 points, and the score never drops below 1. A perfect-count solve is therefore worth 12,000 minus your time. Higher is better, scores are capped at 99,999, and each difficulty (Easy, Medium, Hard) has its own leaderboard.

How exactly are moves counted?

By the classic Huarong Dao convention: one move is one block sliding any number of cells in one straight direction. Push a soldier two cells along a corridor in consecutive steps and the counter rises by one, not two. Turning a corner, or moving a different block in between, begins a new move. The optimal numbers shown beside every layout use exactly the same rule, so the comparison is always fair.

Where do the “optimal” numbers come from — are all layouts really solvable?

Yes. Each of the twelve layouts has been run through an exhaustive breadth-first computer search that explores every reachable position. The search proves a solution exists and finds the true minimum number of moves under the counting rule above; that minimum is the number printed beside the layout’s name and used by the score formula. There are no dead layouts and no guessed numbers.

I read that the classic layout needs 81 moves, but this game says 90. Which is right?

Both — they use different counting conventions. The famous figure of 81 moves for “Sword at the Ready” (横刀立马) counts a slide that turns a corner in one continuous motion as a single move. This game and its solver use the stricter straight-line rule, under which a corner turn is two moves and the same layout needs a minimum of 90. The in-game counter and the optimal shown always use the same rule, so your comparison is consistent.

I am completely stuck. Is there a way out?

A Klotski position is never truly dead — with two empty cells some block can always move, and because every shipped layout is proven solvable, a route to the exit exists from any position you can reach. If you have tangled yourself up, use Undo to rewind the last few slides, or Restart to return to the opening position. Remember that Cao Cao needs both bottom-centre cells free at the same moment — engineering that final corridor is the real puzzle.

Does the game work offline?

Yes. Once the page has loaded, everything — the layouts, sliding, move counting, the timer and scoring — runs entirely in your browser with no connection needed. Scores earned offline are stored on your device and upload automatically the next time you are online and signed in.