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