aboutsummaryrefslogtreecommitdiff
path: root/src/blog/2026-11-24-cube-solvers/cube-solvers.md
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-11-24 08:14:55 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2026-11-24 08:14:55 +0100
commit92e3305f2b11493586f737fda74bfe4e30d6b38d (patch)
tree9e3b596dd6028e8855a8ee2f2ae49dc61548991e /src/blog/2026-11-24-cube-solvers/cube-solvers.md
parent881637ddf76fb8fd95e58a88df80c8c9ff3bff05 (diff)
downloadsebastiano.tronto.net-master.tar.gz
sebastiano.tronto.net-master.zip
Blog postHEADmaster
Diffstat (limited to 'src/blog/2026-11-24-cube-solvers/cube-solvers.md')
-rw-r--r--src/blog/2026-11-24-cube-solvers/cube-solvers.md124
1 files changed, 124 insertions, 0 deletions
diff --git a/src/blog/2026-11-24-cube-solvers/cube-solvers.md b/src/blog/2026-11-24-cube-solvers/cube-solvers.md
new file mode 100644
index 0000000..a93c502
--- /dev/null
+++ b/src/blog/2026-11-24-cube-solvers/cube-solvers.md
@@ -0,0 +1,124 @@
1# State of the art of optimal Rubik's cube solvers
2
3As the regular readers of this blog surely know, one of my hobby coding
4projects is [a Rubik's cube solver](https://git.tronto.net/nissy-core).
5The last time I wrote about was [last January](../2026-01-28-prefetch), when
6I discussed some low-level optimizations that I was particularly proud of.
7
8A couple of weeks ago, I was contacted by [Arhan](https://arhan.sh),
9another programmer that shares my interested in twisty puzzle programming.
10Apparently he was granted $10.000 of cloud compute credit and an unlimited
11AI subscription plan, that he had used to generate a new optimal solver
12that blew all existing ones out of the water in terms of performance.
13
14But first, let's do a little recap.
15
16## The story so far, from my subjective point of view
17
18The first optimal Rubik's cube solver was written by [Korf
19(1997)](https://www.cs.princeton.edu/courses/archive/fall06/cos402/papers/korfrubik.pdf).
20Like all of the solvers we'll mention in this post, his was based on
21the [IDA*](https://en.wikipedia.org/wiki/Iterative_deepening_A*) method,
22using large pruning tables and some clever tricks. The difference between
23his and other solver lies mainly in the specific pruning tables used
24and implementation details - you can read more about this in [my post
25from January](../2026-01-28-prefetch/#the-solving-algorithm).
26
27For a long time, the most popular optimal solver was [Kociemba's Cube
28Explorer](https://kociemba.org/cube.htm), neatly packaged in an easy-to-use
29GUI application.
30
31Later came
32[nxopt](https://github.com/rokicki/cube20src/blob/master/nxopt.md) by
33[Tomas Rokicki](https://tomas.rokicki.com/), the mastermind behind the
34computational proof of the [diameter of the Rubik's cube
35graph being 20 moves](https://cube20.org/) (in other words: every position
36can be solved in 20 moves or less).
37
38A highly-optimized reimplementation of nxopt, Andrew Skalski's
39[vcube](https://github.com/Voltara/vcube), was for a long time, as far as
40I know, the fastest optimal solver available.
41
42There are probably many more solvers worth mentioning, but I simply don't
43know them. Sorry, this is not a primer, just a blog post written from
44my partially-informed self.
45
46Anyway, when I started working on a Rubik's cube solver in 2019, I was
47not too ambitious. I first re-implemented Cube Explorer's pruning tables
48and some of its tricks; later, when I found out about nxopt and vcube,
49I copied that method too. Not knowing all of the tricks that these
50other programmers used, my code was not as fast, but I was quite proud
51of it nonetheless.
52
53At some point in 2023 I started thinking about devising and implementing
54my own pruning tables. I did not think I could beat vcube, but it was
55fun to try anyway. But lo and behold, [beat vcube I
56did](https://github.com/sebastianotronto/nissy-core/blob/master/benchmarks/benchmarks.md)
57- my fully-symmetric tables had an edge over nxopt's ones, and the
58optimization tricks I learned in the last few years were almost on
59par with vcube's.
60
61For some time my solver was one the fastest *optimal* Rubik's cube solvers
62- that is, solvers capable of finding the shortest possible solution for
63any given cube configuration. To my knowledge, the only faster solver
64was cubeopt by [Chen Shuang](https://github.com/cs0x7f), which
65is a better-optimized implementation of my method; this program was
66[about 2x faster than mine](https://github.com/cs0x7f/cube_solver_test/wiki).
67cubeopt is not open source, but you can find a WASM build in
68[this repository](https://github.com/cs0x7f/cubeopt-wasm).
69
70But if the [GRH](https://www.scientificamerican.com/article/anthropic-mathematician-claims-to-prove-riemann-hypothesis-most-famous-problem-in-all-of-math/)
71can't stand the AI tsunami, what chances does a hobbyist programmer's
72toy project have?
73
74## Replaced by AI
75
76Arhan's [egg-solver](https://egg-solver.arhan.sh) is, once again, a better
77implementation of my optimal solver. A much, much faster implementation: in my
78[benchmarks](https://github.com/sebastianotronto/nissy-core/blob/master/benchmarks/benchmarks.md),
79it beats mine by factors of 5x to 9x, depending on the use case.
80
81The solver made some small improvements to the method I used - one of them
82I tried to implement, but got lost in details and gave up; the other I think
83I have simply missed. But most importantly, egg-solver takes full advantage of
84*micro-threading*, a technique I partially implemented and talked about in [my
85last post](../2026-01-28-prefetch).
86
87In practice, the recursive DFS search is broken up into tasks that are then
88processed iteratively. Each task yields back to the caller after a
89fetch-from-memory instruction, so that other tasks can continue while the
90data it needs is being retrieved from memory. Conceptually this is not
91particularly hard, but the implementation details can be tricky.
92
93Oh, and while it was analyzing my solver, the LLM also found a bug in my code.
94It was a silly error (stopping a loop one cycle too early), but it led to
95[concrete failures](https://github.com/sebastianotronto/nissy-core/issues/6).
96
97This piece of software is truly impressive. It also has a functional [web
98version](https://egg-solver.arhan.sh), go check it out if you are interested!
99
100## Conclusion
101
102I guess from a scientific point of view, this is all pretty cool. I am happy
103that my idea - in particular the fully-symmetric pruning tables - proved once
104again to be very effective, and it is cool to see that we now have software
105that can take an idea, refine it, perfect it and implement it.
106
107Am I scared of "AI taking my job"? No. First of all, nobody stops me from
108working on my hobby projects with my slow, mushy brain, even if "AI" can do it
109faster. Secondly, I may be wrong, but I don't think LLMs can come up with new
110ideas the way we do. In the example we saw in this post, the ideas were already
111there, they just needed some refinement; and I think the same is true for the
112recent advances in Mathematics. And if it turns out I am wrong and software
113developers become redundant, I can always find something else to do. Worst
114case scenario I'll be a rat hunter in my local post-singularity community,
115I think I can be pretty good at that.
116
117Jokes aside, one thing I really like about AI in software development is
118the way it can analyze code and find bugs. I find myself aligned with
119[Daniel Stenberg](https://daniel.haxx.se/)'s (curl developer) opinion that
120the *gen* part is the least impressive feature of gen-AI (although it was
121quite impressive in this case), while the analysis part is very nice. Go
122check out his [talk at FOSDEM
123'26](https://archive.fosdem.org/2026/schedule/event/B7YKQ7-oss-in-spite-of-ai)
124if you are curious.

Generated with cgit - Back to sebastiano.tronto.net