I Solved Klotski

Channel:2swap · Length:12:19 · Published:2025-08-22 · Views:2081728

Watch on YouTube

Summary

2swap explains how he solved the Klotski sliding-block puzzle by mapping its full state space as a graph and visualizing it. The video includes footage of the Guinness world-record solve and links to an interactive graph.

Why HN recommends it

HN people point to it for intuition about why some games are hard to navigate and for its Rush Hour and graph visualizations.

the state space of the game can produce some intuition on why certain games are hard — HN, 2025

Data visualization & information design · Algorithms & data structures · Chess, board games & puzzles

Subtitles (excerpt)

This is a random agent exploring the state space of a sliding block puzzle. The puzzle is called Klotski. These block puzzles are quite common, but aside from just being puzzles, these sliding blocks define graphs, modeling convoluted topologies with their local substructure, as well as their global superstructure. Often, it's a 6x6 grid, where the solution is to free this block from the hole on the right. We can't do that yet, since this piece is in the way... Let's represent the current position of the puzzle as a node. If we make one move on the puzzle, we arrive at a different node. Since these positions are just one move apart, We draw an edge connecting the two nodes. Each node is connected to a few more, forming a labyrinth of paths. You might start to wonder- if we add all the nodes, what would the graph look like? Maybe it has some overarching structure... such as a grid, Or maybe it's a total mess! To build some intuition, here's a few contrived puzzles first. With just one block, there's only one degree of freedom. With two, you get the cartesian product of their coordinates, yielding a grid. Each block defines a different axis of motion. Three blocks make a 3d lattice, and with 4 degrees of freedom, the graph naturally extends to a hypercube!

On Hacker News

This looks similar to the graphs on "2swap"[1]. Worth a watch if you haven't by now. [1] [VIDEO] — sublinear, 2026-02
Great article, very impressive to solve the entire game, rather than just individual puzzles. PS: Good chance that if you're reading these comments that you will appreciate this video by 2swap, visualising solutions to Rush Hour in 3D: [VIDEO] — ohc, 2025-12
This reminds me of this nice video : [VIDEO] basically, the state space of the game can produce some intuition on why certain games are hard, and is demonstrated as a clustering of various states that are only linked to the winning state by a very small number of edges. So a player can easily "get lost" in the maze. — chii, 2025-09
This is an interactive accompaniment to a video that contains more information: [VIDEO] (previously discussed a bit at [LINK] ) — dzaima, 2025-09

Related videos