twsearch icon indicating copy to clipboard operation
twsearch copied to clipboard

Implement a clock solver

Open lgarron opened this issue 10 months ago • 5 comments

Anyone up for some linear algebra?

We could probably have an alg to solve each piece independently, and then concat and canonicalize.

lgarron avatar Mar 09 '25 22:03 lgarron

I specialized in Linear Algebra in much of my undergrad.

Last week I wrote a Clock solver in Mathematica. It was just a single matrix multiplication.

I also wrote a TWS file, but it took like 2:55 to run. A matrix mult took 0.001 sec.

DougCube avatar Mar 10 '25 00:03 DougCube

I also found god's number for Clock variants: 2-hour, 3-hour, 4-hour, and it got partway thru 5-hour before crashing.

DougCube avatar Mar 10 '25 00:03 DougCube

@DougCube Sounds like you have good skills for this, a solver would be a very welcome contribution!

Code size matters a lot, so we'd have to check any linear algebra dependencies very carefully for code size.

A direct math implementation would certainly work, though.

Let me know if you need any boilerplate code.

lgarron avatar Mar 10 '25 01:03 lgarron

What I had found is that it's a great way to quickly find A solution... but it's probably not optimal. Like it found a 13 immediately and god's number is 12. Optimal for the scramble I tried was 9. So it just depends on what your goal is.

If it's just a matrix multiplication. Modern compilers on modern hardware can leverage AVX instructions to do this very fast.

DougCube avatar Mar 10 '25 05:03 DougCube

Btw writting a TWS file for Clock was just awful... 14 piece sets, each with a single piece, no permutation, just 12 orientations.

File was 738 lines long. I used the ordering of pieces and moves in my TWS file to encode a matrix that maps from moves to state. Taking an inverse of this matrix is what I use to "solve" a state (well the negation of it).

DougCube avatar Mar 10 '25 05:03 DougCube