Coding Adventure: Rubik's Cube
Sebastian Lague’s latest Coding Adventure walks through building a program that solves a standard 3x3 Rubik’s Cube. The project starts with modeling the cube, then adds move handling, a binary state representation, and search/optimization work to make solving feasible.
The video is useful because it’s not just about “solving a puzzle,” it’s about how you represent complex state and how that representation affects the quality and speed of your solver. Lague compares multiple approaches, including a greedy solver, a sandwich solver, and an oriented solver, which makes the tradeoffs between heuristic strength and implementation complexity very concrete.
For game developers, the takeaways map directly to AI and systems work: compact state encoding, heuristic evaluation, and iterative refinement of search strategies. Even though this is a puzzle project, the same patterns show up in pathfinding variants, procedural systems, and any feature where you need to search a large combinatorial space efficiently.
He also notes a correction about the evaluation function at 22:32: the fallback to the greedy evaluator included a small bonus for correctly oriented corners. That kind of detail is a good reminder that tiny scoring changes can materially affect solver behavior, especially when heuristics are layered or reused.
“My attempt at solving the 3x3 Rubik's cube (by programming the computer to do it for me).”
- what
- Sebastian Lague built a program to solve a 3x3 Rubik’s Cube by search and heuristics.
- who
- Sebastian Lague; source code is published on GitHub at SebLague/Rubiks-Cube.
- when
- The video is structured into chapters from 00:00 to 23:39, with the evaluation-function note at 22:32.
- impact
- Useful reference for developers working on state-space search, heuristics, and compact state encoding.
Strong technical demo with useful solver tradeoffs
Follow ai updates
See relevant stories in your personalized news feed.
Discussion