aboutsummaryrefslogtreecommitdiff
path: root/src/blog/2026-11-24-cube-solvers/cube-solvers.md
blob: a93c5027a1599e3a3e4871087733f3e04a133d3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# State of the art of optimal Rubik's cube solvers

As the regular readers of this blog surely know, one of my hobby coding
projects is [a Rubik's cube solver](https://git.tronto.net/nissy-core).
The last time I wrote about was [last January](../2026-01-28-prefetch), when
I discussed some low-level optimizations that I was particularly proud of.

A couple of weeks ago, I was contacted by [Arhan](https://arhan.sh),
another programmer that shares my interested in twisty puzzle programming.
Apparently he was granted $10.000 of cloud compute credit and an unlimited
AI subscription plan, that he had used to generate a new optimal solver
that blew all existing ones out of the water in terms of performance.

But first, let's do a little recap.

## The story so far, from my subjective point of view

The first optimal Rubik's cube solver was written by [Korf
(1997)](https://www.cs.princeton.edu/courses/archive/fall06/cos402/papers/korfrubik.pdf).
Like all of the solvers we'll mention in this post, his was based on
the [IDA*](https://en.wikipedia.org/wiki/Iterative_deepening_A*) method,
using large pruning tables and some clever tricks. The difference between
his and other solver lies mainly in the specific pruning tables used
and implementation details - you can read more about this in [my post
from January](../2026-01-28-prefetch/#the-solving-algorithm).

For a long time, the most popular optimal solver was [Kociemba's Cube
Explorer](https://kociemba.org/cube.htm), neatly packaged in an easy-to-use
GUI application.

Later came
[nxopt](https://github.com/rokicki/cube20src/blob/master/nxopt.md) by
[Tomas Rokicki](https://tomas.rokicki.com/), the mastermind behind the
computational proof of the [diameter of the Rubik's cube
graph being 20 moves](https://cube20.org/) (in other words: every position
can be solved in 20 moves or less).

A highly-optimized reimplementation of nxopt, Andrew Skalski's
[vcube](https://github.com/Voltara/vcube), was for a long time, as far as
I know, the fastest optimal solver available.

There are probably many more solvers worth mentioning, but I simply don't
know them. Sorry, this is not a primer, just a blog post written from
my partially-informed self.

Anyway, when I started working on a Rubik's cube solver in 2019, I was
not too ambitious. I first re-implemented Cube Explorer's pruning tables
and some of its tricks; later, when I found out about nxopt and vcube,
I copied that method too. Not knowing all of the tricks that these
other programmers used, my code was not as fast, but I was quite proud
of it nonetheless.

At some point in 2023 I started thinking about devising and implementing
my own pruning tables. I did not think I could beat vcube, but it was
fun to try anyway. But lo and behold, [beat vcube I
did](https://github.com/sebastianotronto/nissy-core/blob/master/benchmarks/benchmarks.md)
- my fully-symmetric tables had an edge over nxopt's ones, and the
optimization tricks I learned in the last few years were almost on
par with vcube's.

For some time my solver was one the fastest *optimal* Rubik's cube solvers
- that is, solvers capable of finding the shortest possible solution for
any given cube configuration. To my knowledge, the only faster solver
was cubeopt by [Chen Shuang](https://github.com/cs0x7f), which
is a better-optimized implementation of my method; this program was
[about 2x faster than mine](https://github.com/cs0x7f/cube_solver_test/wiki).
cubeopt is not open source, but you can find a WASM build in
[this repository](https://github.com/cs0x7f/cubeopt-wasm).

But if the [GRH](https://www.scientificamerican.com/article/anthropic-mathematician-claims-to-prove-riemann-hypothesis-most-famous-problem-in-all-of-math/)
can't stand the AI tsunami, what chances does a hobbyist programmer's
toy project have?

## Replaced by AI

Arhan's [egg-solver](https://egg-solver.arhan.sh) is, once again, a better
implementation of my optimal solver. A much, much faster implementation: in my
[benchmarks](https://github.com/sebastianotronto/nissy-core/blob/master/benchmarks/benchmarks.md),
it beats mine by factors of 5x to 9x, depending on the use case.

The solver made some small improvements to the method I used - one of them
I tried to implement, but got lost in details and gave up; the other I think
I have simply missed. But most importantly, egg-solver takes full advantage of
*micro-threading*, a technique I partially implemented and talked about in [my
last post](../2026-01-28-prefetch).

In practice, the recursive DFS search is broken up into tasks that are then
processed iteratively. Each task yields back to the caller after a
fetch-from-memory instruction, so that other tasks can continue while the
data it needs is being retrieved from memory. Conceptually this is not
particularly hard, but the implementation details can be tricky.

Oh, and while it was analyzing my solver, the LLM also found a bug in my code.
It was a silly error (stopping a loop one cycle too early), but it led to
[concrete failures](https://github.com/sebastianotronto/nissy-core/issues/6).

This piece of software is truly impressive. It also has a functional [web
version](https://egg-solver.arhan.sh), go check it out if you are interested!

## Conclusion

I guess from a scientific point of view, this is all pretty cool. I am happy
that my idea - in particular the fully-symmetric pruning tables - proved once
again to be very effective, and it is cool to see that we now have software
that can take an idea, refine it, perfect it and implement it.

Am I scared of "AI taking my job"? No. First of all, nobody stops me from
working on my hobby projects with my slow, mushy brain, even if "AI" can do it
faster. Secondly, I may be wrong, but I don't think LLMs can come up with new
ideas the way we do. In the example we saw in this post, the ideas were already
there, they just needed some refinement; and I think the same is true for the
recent advances in Mathematics. And if it turns out I am wrong and software
developers become redundant, I can always find something else to do. Worst
case scenario I'll be a rat hunter in my local post-singularity community,
I think I can be pretty good at that.

Jokes aside, one thing I really like about AI in software development is
the way it can analyze code and find bugs. I find myself aligned with
[Daniel Stenberg](https://daniel.haxx.se/)'s (curl developer) opinion that
the *gen* part is the least impressive feature of gen-AI (although it was
quite impressive in this case), while the analysis part is very nice. Go
check out his [talk at FOSDEM
'26](https://archive.fosdem.org/2026/schedule/event/B7YKQ7-oss-in-spite-of-ai)
if you are curious.

Generated with cgit - Back to sebastiano.tronto.net