KOJP

Klotski Sliding Puzzle Online Game

Slide the wooden blocks inside a 4×5 box and get the big block out through the gate at the bottom

30 levels · 3 to 138 moves

Drag a block and it slides only into empty cells, then snaps to the grid. When the big gold seal block reaches the gate, the box opens and it slides out. The fewest possible moves, your stars and your best result for every level are saved in this browser.

Controls

Drag: slide a block (around corners too)
Tap: a block with one free side moves that way; with several, it moves toward where you tapped
Arrows move · Tab picks a block · Z undo · H hint · R restart

What is Klotski?

Klotski is a sliding block puzzle played in a box four cells wide and five cells tall, where you shuffle wooden blocks through the empty cells until the large 2×2 block can leave through the opening in the middle of the bottom edge. Blocks can never be lifted, only slid along the floor of the box.

The same puzzle has a story in every country. In China it is called Huarong Dao, after the narrow Huarong trail in the Romance of the Three Kingdoms where the defeated Cao Cao is trapped and Guan Yu lets him pass; the big block is Cao Cao and the long blocks are generals. In Japan it is Hakoiri Musume, the daughter in the box. The English name Klotski is usually traced to the Polish word klocki, meaning wooden blocks. Nobody knows for sure who invented it, but by the early twentieth century wooden versions were sold in many countries.

Here the blocks carry no characters. They are red lacquered wood with gold leaf borders and simple patterns: a gold seal on the big block, two diamonds on the tall blocks, three linked rings on the wide blocks and a four petal flower on the small ones.

What are the pieces and rules?

A block moves only up, down, left or right, and only into empty cells. No diagonal moves and no jumping over other blocks. You win when the top left cell of the big block reaches the middle of the second row from the bottom, right in front of the gate.

BlockSizePattern
Big block (Cao Cao, the daughter)2×2, oneGold seal. This is the one to get out
Tall block1×2Two diamonds
Wide block (Guan Yu)2×1Three linked rings
Small block (soldier)1×1Four petal flower
Empty cellsUsually 2, 4 on easy levelsThe only space anything can move into

How are moves counted?

Moving one block in one go counts as one move, however far it travels and even if it turns a corner. Moving the same block again straight after also merges into the same move.

This is the most common way to count Klotski moves, which is why the classic Heng Dao Li Ma layout comes out at the well known 81 moves. Counting every single cell step instead would push the same layout past 100. Undo takes back the whole last move and lowers the count by one.

How do I earn stars?

Your move count is compared with the fewest possible for that level: exactly the fewest gives three stars, up to 20% more gives two, anything else gives one. The star row under the board always shows what you can still earn.

StarsConditionHeng Dao Li Ma (81 moves)
★★★Fewest possible, no hints81 moves
★★Within 120% of the fewest, or hints used82 to 97 moves
★Escaped98 moves or more

Using even one hint caps that level at two stars. A level finished by the auto solver is not recorded.

What is the fewest number of moves for each layout?

The 30 levels range from 3 to 138 moves, and every number was worked out by the built in solver checking every reachable position. Heng Dao Li Ma (81), Zhi Hui Ruo Ding (70), Bing Fen San Lu (72), Qi Tou Bing Jin (60) and Feng Hui Lu Zhuan (138) are classic Chinese layouts.

LevelNameFewest moves
1First Step3
2Open Gate5
3Corner Room8
4Three Ways11
5Empty Yard14
6Middle Path18
7Four Pillars21
8Twisted Alley24
9Row of Guards28
10Five Passes33
11Stone Wall36
12Crossbars40
13Surrounded44
14Double Doors48
15Narrow Gate52
16Stacked Bars56
17Hillside Path58
18Shoulder to Shoulder (Qi Tou Bing Jin)60
19Crossed Paths62
20Winding Road66
21Calm Command (Zhi Hui Ruo Ding)70
22Three Columns (Bing Fen San Lu)72
23Deep Fort75
24Blade and Horse (Heng Dao Li Ma)81
25Maze90
26Last Gate93
27Four Bars97
28Layered Guard120
29Long Road135
30Winding Peaks (Feng Hui Lu Zhuan)138

Feng Hui Lu Zhuan is known as one of the hardest layouts that can be made from one big block, three tall, two wide and four small blocks, and the solver confirms that no start with that set of blocks needs more than 138 moves. The standard Japanese Hakoiri Musume layout has the same shape as Heng Dao Li Ma, so it also takes 81 moves.

Any tips for solving Klotski?

  1. Keep the two empty cells together. A pair of adjacent gaps is what lets tall, wide and big blocks pass.
  2. Do not rush the big block down. Clear the gate area first, or the big block gets stuck halfway and has to climb back up.
  3. Use the small blocks as an engine. A 1×1 block fits anywhere, so it is the best tool for moving the gaps where you need them.
  4. Decide where the wide block goes. When it sits right under the big block, as in Heng Dao Li Ma, making room to move it aside is the first goal.
  5. Stuck? Take one hint. It shows the next move of a shortest solution from the current position, and you still keep two stars.

How do hints and the auto solver work?

A hint runs a breadth first search from the position on the board to the nearest escape and highlights its first move with a gold outline and an arrow. If you follow it, the next hint appears instantly without searching again.

Because the search looks at every possible position, following the hints always finishes in exactly the fewest remaining moves. Even the hardest level takes no more than a second or two on a phone.

Controls

Names and move counts of the classic layouts follow the Chinese Huarong Dao tradition; the other level names were given by this game. Records are kept in this browser only and disappear if you clear its storage.

Frequently asked questions

Is this Klotski puzzle free?

Yes. You can play it on this page for free with no account. It works on computers, phones and tablets, and your stars and best results are saved in this browser.

Are Klotski, Huarong Dao and Hakoiri Musume the same puzzle?

Yes. All three are the same sliding block puzzle where a big 2×2 block has to leave a 4×5 box through the bottom gate. China names it after the Huarong trail in the Romance of the Three Kingdoms, Japan calls it Hakoiri Musume (the daughter in the box), and English speakers call it Klotski.

What is the fewest number of moves for the classic layout?

81 moves for Heng Dao Li Ma, the standard layout, counting one move each time a single block is moved, even around a corner. That is the most common rule and the one used here. Counting every cell step gives more than 100.

Which level is the hardest?

Level 30, Feng Hui Lu Zhuan, which needs at least 138 moves. It is the farthest start that can be made from one big block, three tall, two wide and four small blocks, as checked by the solver.

How do I get three stars?

Escape in exactly the fewest possible moves for that level without using a hint. Up to 20% more moves, or any hint, gives two stars; otherwise you get one.

Are the hints always right?

Yes. Each hint searches every reachable position from the current board with a breadth first search and shows the next move of a shortest solution. Following the hints always escapes in the fewest remaining moves.

Why will a block not move?

Blocks only slide into empty cells. If another block or the box wall is in the way, the block resists a little and springs back. The big block needs two empty cells side by side to move.

Can I undo a move?

Yes. The ↶ button or the Z key takes back the whole last move and lowers the count by one. The ↺ button or the R key restarts the level.