From 92e3305f2b11493586f737fda74bfe4e30d6b38d Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Tue, 24 Nov 2026 08:14:55 +0100 Subject: Blog post --- src/blog/2026-11-24-cube-solvers/cube-solvers.md | 124 +++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/blog/2026-11-24-cube-solvers/cube-solvers.md (limited to 'src') 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 @@ +# 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. -- cgit v1.3