4x4x4 Programming Discussion

Status
Not open for further replies.

unsolved

Veteran
Joined
Mar 2, 2014
Messages
566
Location
Doylestown, PA
I thought it might be a good idea to stratify the discussions about 4x4x4 programming from the discussions about the associated 4x4x4 brute force solvers. Some readers who messaged me on here mentioned they were "getting lost" in some of the technical talk. Also, if you follow the strictest interpretations of the guidelines, I found myself talking about my program in Bruce's area, and sometimes Bruce would include a reference to his program in my area, so rather than "blur the lines" I offer this mutual programming discussion area.

To start things off, let me say that I have decided to re-code my move generator completely from scratch. Sometimes when you get started on a project, by the time you make some serious progress, one of the things you come to realize is how NOT to tackle the problem. It became apparent from Bruce's Rotational Scramble example that my move generator would flounder in the attempt to come up with the optimal solution because one sequence of moves functionally turned the cube by 90 degrees. In trying to find an optimal solution for the original, un-rotated version of the cube, my program was missing some obviously shorter solutions in the rotated state. There was a "quick fix" to address this particular issue, but I preferred a holistic solution to address the more general case.

I'd like to begin here with a discussion about the true "legal position" counts as a function of depth. From one of the early posts in another area:

  1. if there are 2 moves on the same axis, both turn in the same direction (U is the same direction as d') and one of the moves is of <D>, then ignore the case.
  2. if there are 3 moves on the same axis, and >=2 moves turn in the same direction, then ignore the case.
  3. ignore all cases with 4 moves on the same axis.

Using this rules, if get the following numbers of valid sequences:


[table="width: 450, class: grid"]
[tr]
[td]n[/td]
[td]all
36*33^(n-1)[/td]
[td]canceling moves
(U d U = U2 d)[/td]
[td]cancel by rotation
(U u = d D)[/td]
[/tr]
[tr]
[td]0[/td]
[td]
1​
[/td]
[td]
1​
[/td]
[td]
1​
[/td]
[/tr]
[tr]
[td]1[/td]
[td]
36​
[/td]
[td]
36​
[/td]
[td]
36​
[/td]
[/tr]
[tr]
[td]2[/td]
[td]
1.188​
[/td]
[td]
1.026​
[/td]
[td]
999​
[/td]
[/tr]
[tr]
[td]3[/td]
[td]
39.204​
[/td]
[td]
28.836​
[/td]
[td]
27.288​
[/td]
[/tr]
[tr]
[td]4[/td]
[td]
1.293.732​
[/td]
[td]
810.891​
[/td]
[td]
746.562​
[/td]
[/tr]
[tr]
[td]5[/td]
[td]
42.693.156​
[/td]
[td]
22.803.120​
[/td]
[td]
20.421.648​
[/td]
[/tr]
[tr]
[td]6[/td]
[td]
1.408.874.148​
[/td]
[td]
641.245.896​
[/td]
[td]
558.627.948​
[/td]
[/tr]
[/table]

The issue with using such rules (above) to create a move generator is that the move sequence U D' u d'would be disallowed, as would U2 D2 u2 d2, both of which create rotated versions of the cube. I created a move generator that allows those moves, since I generated every possible 36 * 33^(n-1) cube arrangement, loaded the unique positions into a RAM buffer, and scanned the buffer prior to allowing a new entry, verifying (the hard way) that no duplicates were created (including recreating the starting position). These are the numbers I get:

[table="width: 225, class: grid"]
[tr]
[td]n[/td]
[td]Explicit Unique Counts[/td]
[/tr]
[tr]
[td]1[/td]
[td]
36​
[/td]
[/tr]
[tr]
[td]2[/td]
[td]
1,026​
[/td]
[/tr]
[tr]
[td]3[/td]
[td]
28,812​
[/td]
[/tr]
[tr]
[td]4[/td]
[td]
806,694​
[/td]
[/tr]
[tr]
[td]5[/td]
[td]
22,575,425​
[/td]
[/tr]
[tr]
[td]6[/td]
[td]
631,793,942​
[/td]
[/tr]
[tr]
[td]7[/td]
[td]
17,681,379,137​
[/td]
[/tr]
[/table]

My move generator and turns-from-solution (TFS) databases absolutely require uniqueness in order to function properly, so it is imperative that I get these numbers right! We have already seen those "odd solutions" that older version of my program found, since essentially the index "matching" the position was, in fact, pointing to a database slot for a position that was out of synch due to duplicates occupying indices that should have been discarded.

In this new version, it should be noted that U u and D' d' create different positions, and are therefore both allowed.
If possible, I would like confirmation of these numbers before I launch the rest of my re-coding effort.
 
Last edited:
I thought it might be a good idea to stratify the discussions about 4x4x4 programming from the discussions about the associated 4x4x4 brute force solvers. Some readers who messaged me on here mentioned they were "getting lost" in some of the technical talk. Also, if you follow the strictest interpretations of the guidelines, I found myself talking about my program in Bruce's area, and sometimes Bruce would include a reference to his program in my area, so rather than "blur the lines" I offer this mutual programming discussion area.

I agree that your other thread was kind of hijacked with more general discussions on implementing 4x4x4 solvers. I think this is good to separate such discussion from the thread that was intended to be about your own solver. I generally was avoiding talking about my own solver in that thread, but would post information about possible pruning tables not necessarily specific to my own solver. I may have mentioned it some for purposes of comparing or contrasting it with your a solver.

The issue with using such rules (above) to create a move generator is that the move sequence U D' u d'would be disallowed, as would U2 D2 u2 d2, both of which create rotated versions of the cube. I created a move generator that allows those moves, since I generated every possible 36 * 33^(n-1) cube arrangement, loaded the unique positions into a RAM buffer, and scanned the buffer prior to allowing a new entry, verifying (the hard way) that no duplicates were created (including recreating the starting position). These are the numbers I get:

[table="width: 225, class: grid"]
[tr]
[td]n[/td]
[td]Explicit Unique Counts[/td]
[/tr]
[tr]
[td]1[/td]
[td]
36​
[/td]
[/tr]
[tr]
[td]2[/td]
[td]
1,026​
[/td]
[/tr]
[tr]
[td]3[/td]
[td]
28,812​
[/td]
[/tr]
[tr]
[td]4[/td]
[td]
806,694​
[/td]
[/tr]
[tr]
[td]5[/td]
[td]
22,575,425​
[/td]
[/tr]
[tr]
[td]6[/td]
[td]
631,793,942​
[/td]
[/tr]
[tr]
[td]7[/td]
[td]
17,681,379,137​
[/td]
[/tr]
[/table]

I posted the number of position at distances up to 7 moves from solved (single slice turn metric) in your other thread (currently the post numbered 148). These numbers are lower than yours, but I note my numbers are for the distances from the solved state for the regular 4x4x4. I have not computed the equivalent supercube numbers (well, I have, but only for block turn metric). The distribution of distances for a scrambled state will generally not be the same. I would assume you would be using a supercube model if you are interested in knowing how many unique sequences you need in order to generate all positions of a given number of moves away from an arbitrary scrambled state.

My move generator and turns-from-solution (TFS) databases absolutely require uniqueness in order to function properly, so it is imperative that I get these numbers right! We have already seen those "odd solutions" that older version of my program found, since essentially the index "matching" the position was, in fact, pointing to a database slot for a position that was out of synch due to duplicates occupying indices that should have been discarded.

In this new version, it should be noted that U u and D' d' create different positions, and are therefore both allowed.
If possible, I would like confirmation of these numbers before I launch the rest of my re-coding effort.

Well, U u would be equivalent to D d (not D' d') ignoring the resulting cube orientation difference, using the old Singmaster notation standards. If you're somehow considering these different, but considering some positions differing only by orientation of the cube as the same, then I think you need to clarify what you count as to whether two positions are the same or not. I think the simplest way to compare two states is to orient the cubes so that the DLB corner cubie is properly oriented in the DLB position. (Any corner cubie could be used, but fixing DLB is consistent with speedcubers tending to prefer turning U, R, and F,) You could go further and simulate L turns (as well as D and B turns) as turning the other three layers on that same axis, so that the DLB cubie is never allowed to be out of place. This has some consequences as far as "remapping" which axis is which.

As I hope you're well aware by now, the set of sequences that yield positions n moves away from a scrambled state depend upon the scrambled state itself. This is due to different arrangements of indistinguishable pieces in different scrambled states.
 
I posted the number of position at distances up to 7 moves from solved (single slice turn metric) in your other thread (currently the post numbered 148). These numbers are lower than yours, but I note my numbers are for the distances from the solved state for the regular 4x4x4. I have not computed the equivalent supercube numbers (well, I have, but only for block turn metric). The distribution of distances for a scrambled state will generally not be the same. I would assume you would be using a supercube model if you are interested in knowing how many unique sequences you need in order to generate all positions of a given number of moves away from an arbitrary scrambled state.

You are referring to this post I suppose...

Code:
moves  positions  cumulative   positions  cumulative pos.
                   positions     mod M         mod M

  0            1           1           1              1
  1           36          37           4              5
  2          999        1036          36             41
  3        27186       28222         619            660
  4       738096      766318       15771          16431
  5     20000066    20766384      418952         435383
  6    541569809   562336193    11297967       11733350
  7  14661687334 15224023527   305559127      317292477

I am calling the move generator, generating a unique index for the 4x4x4 cube, and comparing that index to every index computed thus far. If the index already exists, the position is a duplicate. If the index is not in the list, the position is unique. I created 3 verbose text files as this was in process: File 1 = all of the move sequences that created the starting position. File 2 = all of the duplicates, which also cite the prior index number that generated the collision. File 3 = the moves leading to the unique index. In this way, I can test any move sequence and see if it passed or failed or just didn't move at all. I will post some data at the end.


Well, U u would be equivalent to D d (not D' d') ignoring the resulting cube orientation difference, using the old Singmaster notation standards. If you're somehow considering these different, but considering some positions differing only by orientation of the cube as the same, then I think you need to clarify what you count as to whether two positions are the same or not. I think the simplest way to compare two states is to orient the cubes so that the DLB corner cubie is properly oriented in the DLB position. (Any corner cubie could be used, but fixing DLB is consistent with speedcubers tending to prefer turning U, R, and F,) You could go further and simulate L turns (as well as D and B turns) as turning the other three layers on that same axis, so that the DLB cubie is never allowed to be out of place. This has some consequences as far as "remapping" which axis is which.

From my data:

Code:
U  u   @ depth 2 generates a unique cube for index 52
D  d   @ depth 2 generates a unique cube for index 153

U u pushes 2 rings of cubes front to left to back to right to front. D d pulls 2 rings of cubes from left to front to right to back to left. If we were to compare the front face after the application of U u it would look identical to the right face after D d. My indexing function considers them as two different cubes. To solve U u and create the original position, only U' u' or u' U' will work. If you solve U u by making the moves D' d', you solve a different cube, although "the cube" is still solved. It was the only way I could reconcile the index-to-position move generator with rotated versions of the cube without having to do the DLB cubie hunt.

As I hope you're well aware by now, the set of sequences that yield positions n moves away from a scrambled state depend upon the scrambled state itself. This is due to different arrangements of indistinguishable pieces in different scrambled states.

Yes, perfectly clear.

Some of my data:

Code:
 starting cube @ depth 0 generates a unique cube for index 0
 U   @ depth 1 generates a unique cube for index 1
 R   @ depth 1 generates a unique cube for index 2
 F   @ depth 1 generates a unique cube for index 3
 D   @ depth 1 generates a unique cube for index 4
 L   @ depth 1 generates a unique cube for index 5
 B   @ depth 1 generates a unique cube for index 6
 U'  @ depth 1 generates a unique cube for index 7
 R'  @ depth 1 generates a unique cube for index 8
 F'  @ depth 1 generates a unique cube for index 9
 D'  @ depth 1 generates a unique cube for index 10
 L'  @ depth 1 generates a unique cube for index 11
 B'  @ depth 1 generates a unique cube for index 12
 U2  @ depth 1 generates a unique cube for index 13
 R2  @ depth 1 generates a unique cube for index 14
 F2  @ depth 1 generates a unique cube for index 15
 D2  @ depth 1 generates a unique cube for index 16
 L2  @ depth 1 generates a unique cube for index 17
 B2  @ depth 1 generates a unique cube for index 18
 u   @ depth 1 generates a unique cube for index 19
 r   @ depth 1 generates a unique cube for index 20
 f   @ depth 1 generates a unique cube for index 21
 d   @ depth 1 generates a unique cube for index 22
 l   @ depth 1 generates a unique cube for index 23
 b   @ depth 1 generates a unique cube for index 24
 u'  @ depth 1 generates a unique cube for index 25
 r'  @ depth 1 generates a unique cube for index 26
 f'  @ depth 1 generates a unique cube for index 27
 d'  @ depth 1 generates a unique cube for index 28
 l'  @ depth 1 generates a unique cube for index 29
 b'  @ depth 1 generates a unique cube for index 30
 u2  @ depth 1 generates a unique cube for index 31
 r2  @ depth 1 generates a unique cube for index 32
 f2  @ depth 1 generates a unique cube for index 33
 d2  @ depth 1 generates a unique cube for index 34
 l2  @ depth 1 generates a unique cube for index 35
 b2  @ depth 1 generates a unique cube for index 36

By generating moves in that order, it becomes easy to predict when moves collide or when they collapse to form a move generated at a prior depth.

I also annotated the duplication failures:

Code:
 U  U   @ depth 2 generates a cube already at index 13
 U  U2  @ depth 2 generates a cube already at index 7
 R  R   @ depth 2 generates a cube already at index 14
 R  R2  @ depth 2 generates a cube already at index 8
 F  F   @ depth 2 generates a cube already at index 15
 F  F2  @ depth 2 generates a cube already at index 9
 D  U   @ depth 2 generates a cube already at index 39
 D  D   @ depth 2 generates a cube already at index 16
 D  D2  @ depth 2 generates a cube already at index 10
 L  R   @ depth 2 generates a cube already at index 73
 L  L   @ depth 2 generates a cube already at index 17
 L  L2  @ depth 2 generates a cube already at index 11
 B  F   @ depth 2 generates a cube already at index 107
 B  B   @ depth 2 generates a cube already at index 18
 B  B2  @ depth 2 generates a cube already at index 12
 U' D   @ depth 2 generates a cube already at index 140
 U' U'  @ depth 2 generates a cube already at index 13
 U' U2  @ depth 2 generates a cube already at index 1
 R' L   @ depth 2 generates a cube already at index 173
 R' R'  @ depth 2 generates a cube already at index 14
 R' R2  @ depth 2 generates a cube already at index 2
 F' B   @ depth 2 generates a cube already at index 206
 F' F'  @ depth 2 generates a cube already at index 15
 F' F2  @ depth 2 generates a cube already at index 3
 D' U   @ depth 2 generates a cube already at index 44
 D' U'  @ depth 2 generates a cube already at index 238
 D' D'  @ depth 2 generates a cube already at index 16
 D' D2  @ depth 2 generates a cube already at index 4
 L' R   @ depth 2 generates a cube already at index 78
 L' R'  @ depth 2 generates a cube already at index 271
 L' L'  @ depth 2 generates a cube already at index 17
 L' L2  @ depth 2 generates a cube already at index 5
 B' F   @ depth 2 generates a cube already at index 112
 B' F'  @ depth 2 generates a cube already at index 304
 B' B'  @ depth 2 generates a cube already at index 18
 B' B2  @ depth 2 generates a cube already at index 6
 U2 U   @ depth 2 generates a cube already at index 7
 U2 D   @ depth 2 generates a cube already at index 145
 U2 U'  @ depth 2 generates a cube already at index 1
 U2 D'  @ depth 2 generates a cube already at index 336
 R2 R   @ depth 2 generates a cube already at index 8
 R2 L   @ depth 2 generates a cube already at index 178
 R2 R'  @ depth 2 generates a cube already at index 2
 R2 L'  @ depth 2 generates a cube already at index 368
 F2 F   @ depth 2 generates a cube already at index 9
 F2 B   @ depth 2 generates a cube already at index 211
 F2 F'  @ depth 2 generates a cube already at index 3
 F2 B'  @ depth 2 generates a cube already at index 400
 D2 U   @ depth 2 generates a cube already at index 49
 D2 D   @ depth 2 generates a cube already at index 10
 D2 U'  @ depth 2 generates a cube already at index 243
 D2 D'  @ depth 2 generates a cube already at index 4
 D2 U2  @ depth 2 generates a cube already at index 431
 L2 R   @ depth 2 generates a cube already at index 83
 L2 L   @ depth 2 generates a cube already at index 11
 L2 R'  @ depth 2 generates a cube already at index 276
 L2 L'  @ depth 2 generates a cube already at index 5
 L2 R2  @ depth 2 generates a cube already at index 463
 B2 F   @ depth 2 generates a cube already at index 117
 B2 B   @ depth 2 generates a cube already at index 12
 B2 F'  @ depth 2 generates a cube already at index 309
 B2 B'  @ depth 2 generates a cube already at index 6
 B2 F2  @ depth 2 generates a cube already at index 495
 u  U   @ depth 2 generates a cube already at index 52
 u  D   @ depth 2 generates a cube already at index 150
 u  U'  @ depth 2 generates a cube already at index 246
 u  D'  @ depth 2 generates a cube already at index 341
 u  U2  @ depth 2 generates a cube already at index 434
 u  D2  @ depth 2 generates a cube already at index 526
 u  u   @ depth 2 generates a cube already at index 31
 u  u2  @ depth 2 generates a cube already at index 25
 r  R   @ depth 2 generates a cube already at index 86
 r  L   @ depth 2 generates a cube already at index 183
 r  R'  @ depth 2 generates a cube already at index 279
 r  L'  @ depth 2 generates a cube already at index 373
 r  R2  @ depth 2 generates a cube already at index 466
 r  L2  @ depth 2 generates a cube already at index 557
 r  r   @ depth 2 generates a cube already at index 32
 r  r2  @ depth 2 generates a cube already at index 26
 f  F   @ depth 2 generates a cube already at index 120
 f  B   @ depth 2 generates a cube already at index 216
 f  F'  @ depth 2 generates a cube already at index 312
 f  B'  @ depth 2 generates a cube already at index 405
 f  F2  @ depth 2 generates a cube already at index 498
 f  B2  @ depth 2 generates a cube already at index 588
 f  f   @ depth 2 generates a cube already at index 33
 f  f2  @ depth 2 generates a cube already at index 27
 d  U   @ depth 2 generates a cube already at index 55
 d  D   @ depth 2 generates a cube already at index 153
 d  U'  @ depth 2 generates a cube already at index 249
 d  D'  @ depth 2 generates a cube already at index 344
 d  U2  @ depth 2 generates a cube already at index 437
 d  D2  @ depth 2 generates a cube already at index 529
 d  u   @ depth 2 generates a cube already at index 618
 d  d   @ depth 2 generates a cube already at index 34
 d  d2  @ depth 2 generates a cube already at index 28
 l  R   @ depth 2 generates a cube already at index 89
 l  L   @ depth 2 generates a cube already at index 186
 l  R'  @ depth 2 generates a cube already at index 282
 l  L'  @ depth 2 generates a cube already at index 376
 l  R2  @ depth 2 generates a cube already at index 469
 l  L2  @ depth 2 generates a cube already at index 560
 l  r   @ depth 2 generates a cube already at index 646
 l  l   @ depth 2 generates a cube already at index 35
 l  l2  @ depth 2 generates a cube already at index 29
 b  F   @ depth 2 generates a cube already at index 123
 b  B   @ depth 2 generates a cube already at index 219
 b  F'  @ depth 2 generates a cube already at index 315
 b  B'  @ depth 2 generates a cube already at index 408
 b  F2  @ depth 2 generates a cube already at index 501
 b  B2  @ depth 2 generates a cube already at index 591
 b  f   @ depth 2 generates a cube already at index 674
 b  b   @ depth 2 generates a cube already at index 36
 b  b2  @ depth 2 generates a cube already at index 30
 u' U   @ depth 2 generates a cube already at index 58
 u' D   @ depth 2 generates a cube already at index 156
 u' U'  @ depth 2 generates a cube already at index 252
 u' D'  @ depth 2 generates a cube already at index 347
 u' U2  @ depth 2 generates a cube already at index 440
 u' D2  @ depth 2 generates a cube already at index 532
 u' d   @ depth 2 generates a cube already at index 701
 u' u'  @ depth 2 generates a cube already at index 31
 u' u2  @ depth 2 generates a cube already at index 19
 r' R   @ depth 2 generates a cube already at index 92
 r' L   @ depth 2 generates a cube already at index 189
 r' R'  @ depth 2 generates a cube already at index 285
 r' L'  @ depth 2 generates a cube already at index 379
 r' R2  @ depth 2 generates a cube already at index 472
 r' L2  @ depth 2 generates a cube already at index 563
 r' l   @ depth 2 generates a cube already at index 728
 r' r'  @ depth 2 generates a cube already at index 32
 r' r2  @ depth 2 generates a cube already at index 20
 f' F   @ depth 2 generates a cube already at index 126
 f' B   @ depth 2 generates a cube already at index 222
 f' F'  @ depth 2 generates a cube already at index 318
 f' B'  @ depth 2 generates a cube already at index 411
 f' F2  @ depth 2 generates a cube already at index 504
 f' B2  @ depth 2 generates a cube already at index 594
 f' b   @ depth 2 generates a cube already at index 755
 f' f'  @ depth 2 generates a cube already at index 33
 f' f2  @ depth 2 generates a cube already at index 21
 d' U   @ depth 2 generates a cube already at index 61
 d' D   @ depth 2 generates a cube already at index 159
 d' U'  @ depth 2 generates a cube already at index 255
 d' D'  @ depth 2 generates a cube already at index 350
 d' U2  @ depth 2 generates a cube already at index 443
 d' D2  @ depth 2 generates a cube already at index 535
 d' u   @ depth 2 generates a cube already at index 623
 d' u'  @ depth 2 generates a cube already at index 781
 d' d'  @ depth 2 generates a cube already at index 34
 d' d2  @ depth 2 generates a cube already at index 22
 l' R   @ depth 2 generates a cube already at index 95
 l' L   @ depth 2 generates a cube already at index 192
 l' R'  @ depth 2 generates a cube already at index 288
 l' L'  @ depth 2 generates a cube already at index 382
 l' R2  @ depth 2 generates a cube already at index 475
 l' L2  @ depth 2 generates a cube already at index 566
 l' r   @ depth 2 generates a cube already at index 651
 l' r'  @ depth 2 generates a cube already at index 808
 l' l'  @ depth 2 generates a cube already at index 35
 l' l2  @ depth 2 generates a cube already at index 23
 b' F   @ depth 2 generates a cube already at index 129
 b' B   @ depth 2 generates a cube already at index 225
 b' F'  @ depth 2 generates a cube already at index 321
 b' B'  @ depth 2 generates a cube already at index 414
 b' F2  @ depth 2 generates a cube already at index 507
 b' B2  @ depth 2 generates a cube already at index 597
 b' f   @ depth 2 generates a cube already at index 679
 b' f'  @ depth 2 generates a cube already at index 835
 b' b'  @ depth 2 generates a cube already at index 36
 b' b2  @ depth 2 generates a cube already at index 24
 u2 U   @ depth 2 generates a cube already at index 64
 u2 D   @ depth 2 generates a cube already at index 162
 u2 U'  @ depth 2 generates a cube already at index 258
 u2 D'  @ depth 2 generates a cube already at index 353
 u2 U2  @ depth 2 generates a cube already at index 446
 u2 D2  @ depth 2 generates a cube already at index 538
 u2 u   @ depth 2 generates a cube already at index 25
 u2 d   @ depth 2 generates a cube already at index 706
 u2 u'  @ depth 2 generates a cube already at index 19
 u2 d'  @ depth 2 generates a cube already at index 861
 r2 R   @ depth 2 generates a cube already at index 98
 r2 L   @ depth 2 generates a cube already at index 195
 r2 R'  @ depth 2 generates a cube already at index 291
 r2 L'  @ depth 2 generates a cube already at index 385
 r2 R2  @ depth 2 generates a cube already at index 478
 r2 L2  @ depth 2 generates a cube already at index 569
 r2 r   @ depth 2 generates a cube already at index 26
 r2 l   @ depth 2 generates a cube already at index 733
 r2 r'  @ depth 2 generates a cube already at index 20
 r2 l'  @ depth 2 generates a cube already at index 887
 f2 F   @ depth 2 generates a cube already at index 132
 f2 B   @ depth 2 generates a cube already at index 228
 f2 F'  @ depth 2 generates a cube already at index 324
 f2 B'  @ depth 2 generates a cube already at index 417
 f2 F2  @ depth 2 generates a cube already at index 510
 f2 B2  @ depth 2 generates a cube already at index 600
 f2 f   @ depth 2 generates a cube already at index 27
 f2 b   @ depth 2 generates a cube already at index 760
 f2 f'  @ depth 2 generates a cube already at index 21
 f2 b'  @ depth 2 generates a cube already at index 913
 d2 U   @ depth 2 generates a cube already at index 67
 d2 D   @ depth 2 generates a cube already at index 165
 d2 U'  @ depth 2 generates a cube already at index 261
 d2 D'  @ depth 2 generates a cube already at index 356
 d2 U2  @ depth 2 generates a cube already at index 449
 d2 D2  @ depth 2 generates a cube already at index 541
 d2 u   @ depth 2 generates a cube already at index 628
 d2 d   @ depth 2 generates a cube already at index 28
 d2 u'  @ depth 2 generates a cube already at index 786
 d2 d'  @ depth 2 generates a cube already at index 22
 d2 u2  @ depth 2 generates a cube already at index 938
 l2 R   @ depth 2 generates a cube already at index 101
 l2 L   @ depth 2 generates a cube already at index 198
 l2 R'  @ depth 2 generates a cube already at index 294
 l2 L'  @ depth 2 generates a cube already at index 388
 l2 R2  @ depth 2 generates a cube already at index 481
 l2 L2  @ depth 2 generates a cube already at index 572
 l2 r   @ depth 2 generates a cube already at index 656
 l2 l   @ depth 2 generates a cube already at index 29
 l2 r'  @ depth 2 generates a cube already at index 813
 l2 l'  @ depth 2 generates a cube already at index 23
 l2 r2  @ depth 2 generates a cube already at index 964
 b2 F   @ depth 2 generates a cube already at index 135
 b2 B   @ depth 2 generates a cube already at index 231
 b2 F'  @ depth 2 generates a cube already at index 327
 b2 B'  @ depth 2 generates a cube already at index 420
 b2 F2  @ depth 2 generates a cube already at index 513
 b2 B2  @ depth 2 generates a cube already at index 603
 b2 f   @ depth 2 generates a cube already at index 684
 b2 b   @ depth 2 generates a cube already at index 30
 b2 f'  @ depth 2 generates a cube already at index 840
 b2 b'  @ depth 2 generates a cube already at index 24
 b2 f2  @ depth 2 generates a cube already at index 990
 U  U  U   @ depth 3 generates a cube already at index 7
 U  U  R   @ depth 3 generates a cube already at index 421

This way if there is a collision that "shouldn't be here" I can look up the index in the "acceptable" list and see what the sequence happens to be.

Of note:

Code:
 U  u  D   @ depth 3 generates a cube already at index 1141

That sequence fails since...

Code:
 U  D  u   @ depth 3 generates a unique cube for index 1141

Also

Code:
 U  u  D' d'  @ depth 4 generates a cube already at index 36441

because...

Code:
 U  D' u  d'  @ depth 4 generates a unique cube for index 36441

So the program will now allow for rotations of the cube via 4 consecutive parallel face turns.

UPDATE: I am thinking about changing my move generator from a parallel collapsed for-loop structure back to a nested move generator

The linear move generator code with all 4-ply legal moves pre-loaded into a global structure:

Code:
					for(i = 0; i < TOTAL_NODES_IN_TFS_4; i++)
					{
						GLOBAL_CUBE_SOLUTION[0] = GLOBAL_ALL_LEGAL_MOVES_04[i].move_list[0] + 1;
						GLOBAL_CUBE_SOLUTION[1] = GLOBAL_ALL_LEGAL_MOVES_04[i].move_list[1] + 1;
						GLOBAL_CUBE_SOLUTION[2] = GLOBAL_ALL_LEGAL_MOVES_04[i].move_list[2] + 1;
						GLOBAL_CUBE_SOLUTION[3] = GLOBAL_ALL_LEGAL_MOVES_04[i].move_list[3] + 1;

						if(time_to_update()){ BUILD_PV_STRING if(solved_in_database== 1) printf("\n"); SHOW_PV_STRING solved_in_database= 0;}

						modified_cube = cube_move_array[GLOBAL_CUBE_SOLUTION[0]-1](starting_cube);
						if(cube_cant_be_solved_by_current_search_depth(modified_cube, 3) == 0)
						{
							modified_cube = cube_move_array[GLOBAL_CUBE_SOLUTION[1]-1](modified_cube);
							if(cube_cant_be_solved_by_current_search_depth(modified_cube, 2) == 0)
							{
								modified_cube = cube_move_array[GLOBAL_CUBE_SOLUTION[2]-1](modified_cube);

								if(cube_cant_be_solved_by_current_search_depth(modified_cube, 1) == 0)
								{
									modified_cube = cube_move_array[GLOBAL_CUBE_SOLUTION[3]-1](modified_cube);
									g_total_nodes++;
									solved_in_database= probe_tfs_database(modified_cube, 4);

									if(time_to_update()){ BUILD_PV_STRING if(solved_in_database== 1) printf("\n"); SHOW_PV_STRING solved_in_database= 0;}
								}
								else {GLOBAL_LEAF_NODE_PRUNES++;}
							}
							else {GLOBAL_BRANCHES_PRUNED++;}
						}
						else {GLOBAL_BRANCHES_PRUNED++; solved_in_database= probe_tfs_database(modified_cube, 1);}
					}

My older code looked like this:

Code:
void search_tree_forever(CUBE_4x4_ARRANGEMENT which_cube, unsigned short which_depth, signed short last_move_axis, signed short last_move_group, signed short move_just_made, unsigned short unchanging_depth)
{
	CUBE_4x4_ARRANGEMENT modified_cube;

	signed short   axis_of_rotation;
	signed short   move_group;
	unsigned short move_index;
	unsigned short which_move_to_make;
	
	unsigned short result;

	if(move_just_made >= 0) GLOBAL_CUBE_SOLUTION[unchanging_depth - which_depth - 1] = move_just_made + 1;

	if(which_depth == 0)
	{
			g_total_nodes++;
			result = analyze_cube(which_cube);
	}
	else
	{
		for(axis_of_rotation = 0; axis_of_rotation < 3; axis_of_rotation++)
			for(move_group = 0; move_group < 4; move_group++)
			{
				if((axis_of_rotation != last_move_axis) || ((axis_of_rotation == last_move_axis) && (move_group > last_move_group)))
				{
					for(move_index = 0; move_index < 3; move_index++)
					{
						which_move_to_make = GLOBAL_AXIS_ROTATION[axis_of_rotation][move_group][move_index];
						modified_cube = cube_move_array[which_move_to_make](which_cube);
						search_tree_forever(modified_cube, which_depth-1, axis_of_rotation, move_group, which_move_to_make, unchanging_depth);
					}
				}
			}
	}
}

...which was based upon Jakube's recommendation. When I switched over to an indexing function that would ONLY generate legal moves, I thought it would be much faster. But now there is a problem! When I implement any pruning, I have "already paid the price" of generating the move! So even with massive pruning, I still have 100% of the overhead associated with move generation. If, however, I resort back to this older format, the pruning would occur PRIOR to move generation if it is evoked at any level in the tree above the move generator call. I should have thought of this before I spent 2 weeks working out the details of an index-to-position move generator!

I thought the parallel gains would more than offset the bloated game tree, but this is clearly not the case. The tree grows exponentially and the parallel gains are a linear constant == your processor core count.

So now I need to work out a modified version of Jakube's idea that will allow certain cases of 4 moves along the same axis. The old code for 3-axis turns:

Code:
void init_axis_move_data(void)
{
	GLOBAL_AXIS_ROTATION[0][0][0] = U___PLUS____;
	GLOBAL_AXIS_ROTATION[0][0][1] = U___MINUS___;
	GLOBAL_AXIS_ROTATION[0][0][2] = U___TWICE___;
	GLOBAL_AXIS_ROTATION[0][1][0] = u___PLUS____;
	GLOBAL_AXIS_ROTATION[0][1][1] = u___MINUS___;
	GLOBAL_AXIS_ROTATION[0][1][2] = u___TWICE___;
	GLOBAL_AXIS_ROTATION[0][2][0] = d___PLUS____;
	GLOBAL_AXIS_ROTATION[0][2][1] = d___MINUS___;
	GLOBAL_AXIS_ROTATION[0][2][2] = d___TWICE___;
	GLOBAL_AXIS_ROTATION[0][3][0] = D___PLUS____;
	GLOBAL_AXIS_ROTATION[0][3][1] = D___MINUS___;
	GLOBAL_AXIS_ROTATION[0][3][2] = D___TWICE___;
	GLOBAL_AXIS_ROTATION[1][0][0] = R___PLUS____;
	GLOBAL_AXIS_ROTATION[1][0][1] = R___MINUS___;
	GLOBAL_AXIS_ROTATION[1][0][2] = R___TWICE___;
	GLOBAL_AXIS_ROTATION[1][1][0] = r___PLUS____;
	GLOBAL_AXIS_ROTATION[1][1][1] = r___MINUS___;
	GLOBAL_AXIS_ROTATION[1][1][2] = r___TWICE___;
	GLOBAL_AXIS_ROTATION[1][2][0] = l___PLUS____;
	GLOBAL_AXIS_ROTATION[1][2][1] = l___MINUS___;
	GLOBAL_AXIS_ROTATION[1][2][2] = l___TWICE___;
	GLOBAL_AXIS_ROTATION[1][3][0] = L___PLUS____;
	GLOBAL_AXIS_ROTATION[1][3][1] = L___MINUS___;
	GLOBAL_AXIS_ROTATION[1][3][2] = L___TWICE___;
	GLOBAL_AXIS_ROTATION[2][0][0] = F___PLUS____;
	GLOBAL_AXIS_ROTATION[2][0][1] = F___MINUS___;
	GLOBAL_AXIS_ROTATION[2][0][2] = F___TWICE___;
	GLOBAL_AXIS_ROTATION[2][1][0] = f___PLUS____;
	GLOBAL_AXIS_ROTATION[2][1][1] = f___MINUS___;
	GLOBAL_AXIS_ROTATION[2][1][2] = f___TWICE___;
	GLOBAL_AXIS_ROTATION[2][2][0] = b___PLUS____;
	GLOBAL_AXIS_ROTATION[2][2][1] = b___MINUS___;
	GLOBAL_AXIS_ROTATION[2][2][2] = b___TWICE___;
	GLOBAL_AXIS_ROTATION[2][3][0] = B___PLUS____;
	GLOBAL_AXIS_ROTATION[2][3][1] = B___MINUS___;
	GLOBAL_AXIS_ROTATION[2][3][2] = B___TWICE___;
}
 
Last edited:
I've now done a calculation for the number of 4x4x4 supercube positions reachable for up to 6 moves (single slice turn metric) from a starting position. The results are the same as for the regular 4x4x4 starting from the solved state for distances up to 3. At 4 moves, the supercube numbers start becoming larger.

Of course, these numbers assume the orientation of the cube doesn't matter. That is, states differing only by reorienting the cube are considered to be the same position. So, for example, U u and D d would be counted as the same position.
Code:
moves  positions  cumulative   positions  cumulative pos.
                   positions     mod M         mod M

  0            1           1           1              1
  1           36          37           4              5
  2          999        1036          36             41
  3        27234       28270         619            660
  4       741699      769969       15818          16478
  5     20150576    20920545      421888         438366
  6    305250472   326171017     6368087        6806453

If I consider the orientation to matter (that, the cube is not considered solved unless each face is a solid color and each color must be on a particular face), I get the following distance distribution for supercube positions. I note that I used a breadth-first search without any move restrictions based on previous moves (other than the fact that I am using single slice turn metric - meaning only one layer can be turned in any single move).

Code:
moves  positions  cumulative
                   positions
  0            1          1
  1           36         37
  2         1026       1063
  3        28836      29899
  4       808623     838522
  5     22627004   23465526

Finally, if I assume a non-supercube model while also assuming a particular orientation for the "solved" state,
I get the following distribution of distances from the "solved" state.

Code:
moves  positions  cumulative
                   positions
  0            1          1
  1           36         37
  2         1026       1063
  3        28812      29875
  4       806772     836647
  5     22538576   23375223

I notice that that this last result agrees with Unsolved's table up to 3 moves:
[table="width: 225, class: grid"]
[tr]
[td]n[/td]
[td]Explicit Unique Counts[/td]
[/tr]
[tr]
[td]1[/td]
[td]
36​
[/td]
[/tr]
[tr]
[td]2[/td]
[td]
1,026​
[/td]
[/tr]
[tr]
[td]3[/td]
[td]
28,812​
[/td]
[/tr]
[tr]
[td]4[/td]
[td]
806,694​
[/td]
[/tr]
[tr]
[td]5[/td]
[td]
22,575,425​
[/td]
[/tr]
[tr]
[td]6[/td]
[td]
631,793,942​
[/td]
[/tr]
[tr]
[td]7[/td]
[td]
17,681,379,137​
[/td]
[/tr]
[/table]

This suggests to me that Unsolved was not only still using a fixed orientation for the "solved" state, but may have also been trying to use a non-supercube model as the basis of his move generator, if I'm understanding him. For an arbitrary scrambled state, my numbers indicate you need to consider at least 28,836 sequences of moves for 3 moves away (although only 27,324 if you eliminated the fixed "solved" orientation of the cube), and 808,623 sequences for 4 moves away.

A simple example of 3-move sequences that look like duplicates from a turns-from-solved perspective (non-supercube), but not from a supercube perspective.

r2 b2 l2
l2 b2 r2

The above two sequences appear to have the same affect on a solved cube, but they have different actual permutation effects. Thus, while only one is needed in a "turns-from-solved" database, you need to consider applying both of these sequences from an arbitrary scrambled state.
 
I've now done a calculation for the number of 4x4x4 supercube positions reachable for up to 6 moves (single slice turn metric) from a starting position. The results are the same as for the regular 4x4x4 starting from the solved state for distances up to 3. At 4 moves, the supercube numbers start becoming larger.

Of course, these numbers assume the orientation of the cube doesn't matter. That is, states differing only by reorienting the cube are considered to be the same position. So, for example, U u and D d would be counted as the same position.

Hi Bruce,

It sounds like we need some nomenclature to make this crystal clear. The enumeration of moves from the solved state can be different from the enumeration of moves from an arbitrarily scrambled state. Furthermore, each different strata can encounter move sequences that may functionally rotate the cube in place. This adds complexity to the move generation/solve state checking process. While it is possible to generate a subset of all possible moves if there is a clever solver that can detect rotations and identify a solved cube independent of its 3-space orientation, any solver that is going to access a collection of pre-solved positions from the solved state for the purpose of reducing the trunk of the game tree must also be capable of generating move sequences that would spawn any interim rotated state en route to a pre-solved database entry.

There is no way around this: it would be too computationally intensive to require the database lookup code to recognize anything but what is in the database itself. Testing for rotated versions of transient positions would create a bottleneck. It would be better to have a greater number of positions that also happen to be 90 degree or 180 degree versions of a move sequence than to pre-filter these during the distance-from-solved generation process and then to delegate the rectification to a more complex lookup procedure.

What all of this means: We need to come up with meaningful names for each of our counts!

A true Turns-From-Solved count MUST include cases where a sequence of turns re-orients a cube face, as long as no move sequence can create the identical cubies on those faces in fewer moves. The prime example: U D' u d' must be a legally countable position in the 4-TFS since there is no way to rotate the cube 90 degrees clockwise in fewer moves. Likewise U2 D2 u2 d2 creates a cube arrangement that is solved but 180 degrees from the initial orientation. However, transposing moves creating a position already, as alluded to by Bruce, should be discarded.

That would seem to suggest that a TFS enumeration is really a Solved State Transpositionless Face Rotation (SSTFR) count.

Your first group of numbers:

Code:
moves  positions  cumulative   positions  cumulative pos.
                   positions     mod M         mod M

  0            1           1           1              1
  1           36          37           4              5
  2          999        1036          36             41
  3        27234       28270         619            660
  4       741699      769969       15818          16478
  5     20150576    20920545      421888         438366
  6    305250472   326171017     6368087        6806453

...is what I would refer to as an Arbitrary Scramble Rotationless Transposition (ASRT) count.

That would imply your data below would be like an Arbitrary Scramble Preferred Orientation Transposition (ASPOT) count.

Code:
moves  positions  cumulative
                   positions
  0            1          1
  1           36         37
  2         1026       1063
  3        28836      29899
  4       808623     838522
  5     22627004   23465526

This set of numbers below is a hybrid of the SSTFR and the ASPOT counts.

Code:
moves  positions  cumulative
                   positions
  0            1          1
  1           36         37
  2         1026       1063
  3        28812      29875
  4       806772     836647
  5     22538576   23375223

This suggests to me that Unsolved was not only still using a fixed orientation for the "solved" state, but may have also been trying to use a non-supercube model as the basis of his move generator, if I'm understanding him. For an arbitrary scrambled state, my numbers indicate you need to consider at least 28,836 sequences of moves for 3 moves away (although only 27,324 if you eliminated the fixed "solved" orientation of the cube), and 808,623 sequences for 4 moves away.

Bingo! As was necessary, I believe, for the sake of my sanity.

I did place every move the TFS database generator will permit into separate text files sorted by depth.

http://www.lightningcloudcomputing.com/depth_01.txt

http://www.lightningcloudcomputing.com/depth_02.txt

http://www.lightningcloudcomputing.com/depth_03.txt

http://www.lightningcloudcomputing.com/depth_04.txt

I also have a 550 MB depth_05.txt file which is not online. Even the depth_04 one at 52 MB will take a while to open.

The moves that did NOT make the list are in a separate file, again, very large, 57 MB:

http://www.lightningcloudcomputing.com/failed_moves.txt
 
Last edited:
A true Turns-From-Solved count MUST include cases where a sequence of turns re-orients a cube face, as long as no move sequence can create the identical cubies on those faces in fewer moves. The prime example: U D' u d' must be a legally countable position in the 4-TFS since there is no way to rotate the cube 90 degrees clockwise in fewer moves. Likewise U2 D2 u2 d2 creates a cube arrangement that is solved but 180 degrees from the initial orientation. However, transposing moves creating a position already, as alluded to by Bruce, should be discarded.
Hang on. Maybe what you're talking about is a quirk of your own approach, and something that is necessary because of the way you are keeping track of pruning tables, but for almost everyone else, they would say that U D' u d' is 0 turns from solved - rotations are free. For instance, if you load up a Cube Explorer instance and solve some cubes with slice turns enabled, you will often see a rotation or two at the end of the solving sequence. Those are not counted in the movecount, and are just there to bring the cube back to the original orientation.

Of course, even though rotations are free, solvers don't consider them as part of algs. The reason is that doing a rotation before some move sequence A is always equivalent to doing some other move sequence f(A) (of the same length as A) before the rotation. So you can always leave all rotations for the end, and as long as you accept any rotation of the solved state there, the cube will be solved.
 
As I see it, Unsolved wants to use a basic model of the cube where the orientation of the solved cube matters. This differs from the normal view that the orientation of the solved cube does not matter. As a result, his solver either might have to use extra moves to get the cube "solved" to his preferred orientation, or he could try solving all 24 different possible orientations of the initial scramble. Another possibility is simply defining there to be 24 solved states, which would make his TFS databases roughly 24 times bigger than they already are. In summary, he is using a "flawed" definition of the cube being solved, and he either needs to abandon that flawed definition, compensate for it in some consistent manner, or just accept that his generated solutions may not be optimal in the manner that the cubing community would expect.

As for his files in the preceding post, I thought I would look at my 3-move examples in my prior post: r2 b2 l2 and l2 b2 r2. r2 b2 l2 is in the database with index 27067. l2 b2 r2 is in the failed_moves database, where I find:

l2 b2 r2 @ depth 3 generates a cube already at index 27138

But for index 27138, I find:

f2 D U' @ depth 3 generates a unique cube for index 27138

which is clearly not the same state that is generated by l2 b2 r2.

So it seems to me these files are flawed, regardless of whether they're intended to be a "turns from solved" database or a "turns from starting state" for a supercube.

As was necessary, I believe, for the sake of my sanity.

I am not clear what your claiming is "necessary." Are you agreeing that when applying moves to the scramble position, you must consider sequences r2 b2 l2 and l2 b2 r2 as separate unique sequences to be tried?

As for your names, I find them non-intuitive. For one thing, from your names it doesn't seem clear whether a regular cube model or a supercube model is being used, which in my view is very important. And ...

This set of numbers below is a hybrid of the SSTFR and the ASPOT counts.

Code:
moves  positions  cumulative
                   positions
  0            1          1
  1           36         37
  2         1026       1063
  3        28812      29875
  4       806772     836647
  5     22538576   23375223

... how is this set of numbers different from what you are calling SSTFR?
 
Hang on. Maybe what you're talking about is a quirk of your own approach

Quite possibly. I cannot disallow a move sequence to be performed if it can possibly lead to a solve though, can I? Bruce supplied a move sequence that did just that: avoided detection due to the move generator not handling the reversing process correctly. Well, if it can be generated, it must go into a turns-from-solved database. Therein lies the conundrum.

As I see it, Unsolved wants to use a basic model of the cube where the orientation of the solved cube matters. This differs from the normal view that the orientation of the solved cube does not matter. As a result, his solver either might have to use extra moves to get the cube "solved" to his preferred orientation, or he could try solving all 24 different possible orientations of the initial scramble.

My objective is to create a move generator where the orientation does not matter, but this is apparently in conflict with the Turns-From-Solved database generation process altogether. All 24 solved states are within the 4-TFS database anyway, are they not? U D' u d', U2 D2 u2 d2 are for sure, and I imagine the equivalent moves for rotating front-to-top, as well as the others, are as well. In essence, this will not impact the optimal distance for any solve anyway. The program explores all such paths, and once it finds a shorter way, it takes it, and "blocks" the display of any longer paths. What it may do is find a solution to a path to a rotated state, which at worst is just a rotated version of the preferred state, which is still solved, just rotated, with an announced distance that is "n + 4" further away than it is, with moves such as d u' D U' tacked on at the end. This would be preferred to not finding a solution at all because it involved 4 consecutive parallel rotations. And, if there is a shorter solve to the "preferred state," it will have smaller distances in the databases, and it will be found.

Another possibility is simply defining there to be 24 solved states, which would make his TFS databases roughly 24 times bigger than they already are. In summary, he is using a "flawed" definition of the cube being solved, and he either needs to abandon that flawed definition, compensate for it in some consistent manner, or just accept that his generated solutions may not be optimal in the manner that the cubing community would expect.

I guess the question is: Are all 24 rotated states possible within the 4-ply horizon? If so, I don't think the bloating factor is 24. It would be 24 if I took all 24 solved states and generated the moves from each of them, but I don't. I just make 6 turns from a preferred solved state, and if they generate any interim rotations, so be it.

As for his files in the preceding post, I thought I would look at my 3-move examples in my prior post: r2 b2 l2 and l2 b2 r2. r2 b2 l2 is in the database with index 27067. l2 b2 r2 is in the failed_moves database, where I find:

l2 b2 r2 @ depth 3 generates a cube already at index 27138

But for index 27138, I find:

f2 D U' @ depth 3 generates a unique cube for index 27138

which is clearly not the same state that is generated by l2 b2 r2.

Now this is good information! Clearly something is awry. I believe that is a parallel programming error of some sort. I checked all the data by having the program verify the positions. Then I experimented with the parallel code, trying to make it faster. I did not turn off the #define to stop outputting text. It must have overwritten this data many times, corrupting something. I am using omp.h for my parallelism and must have botched something. Clearly earlier versions of the program were running fine and finding solves as expected, certain rare exceptions involving rotated interim states excepted, which is what led to this recoding effort to begin with.

I will set the program back to serial-mode and regenerate the tables. Thanks for the excellent sleuthing effort!

UPDATE: It looks like the serial version creates matching index pairs now:

Code:
l2 b2 r2  @ depth 3 generates a cube already at index 27067
r2 b2 l2  @ depth 3 generates a unique cube for index 27067

However, the count for depth 3 == 28,702 and depth 4 == 799,020. This used the Jakube move generator idea.

I am not clear what your claiming is "necessary." Are you agreeing that when applying moves to the scramble position, you must consider sequences r2 b2 l2 and l2 b2 r2 as separate unique sequences to be tried?

Scrambled state solves and turns-from-solved database creation processes must use separate move generation routines.

As for your names, I find them non-intuitive. For one thing, from your names it doesn't seem clear whether a regular cube model or a supercube model is being used, which in my view is very important. And ...

Most comp-sci names are unintuitive: Alpha-beta routine, hashing function, indexing function, minimal window principal variation search, sparsely-populated matrix, etc. After you hear them enough, they become second nature. Kind of reminds me of an Arthur Shopenhauer quote: All truth passes through three stages. First, it is ridiculed. Second, it is violently opposed. Third, it is accepted as being self-evident.

It looks like it is time for yet-another-move-generator attempt. I will abandon trying to make one move generator for both the forward-solving and backwards-solving code. Being able to deal with all of these orientations is going to be a problem.
 
Last edited:
My objective is to create a move generator where the orientation does not matter, but this is apparently in conflict with the Turns-From-Solved database generation process altogether. All 24 solved states are within the 4-TFS database anyway, are they not?

No, only 9 of the 23 non-identity cube rotations are at a distance of 4. The other 14 I believe are all at a distance of 8. Basically this means what you find as an optimal solution could be as much as 8 moves more than the length of an optimal path to a solved cube.

U D' u d', U2 D2 u2 d2 are for sure, and I imagine the equivalent moves for rotating front-to-top, as well as the others, are as well. In essence, this will not impact the optimal distance for any solve anyway.

Solving to a particular orientation will always take at least as many moves as solving to any orientation, and many times it will require more moves.

By the way, in saying "optimal distance," you are being sort of redundant. Remember, the graph theory term distance refers to the length of an optimal path. The length of an arbitrary path is not necessarily the distance between the endpoints of the path. These are only equal if the path is optimal.

I guess the question is: Are all 24 rotated states possible within the 4-ply horizon? If so, I don't think the bloating factor is 24. It would be 24 if I took all 24 solved states and generated the moves from each of them, but I don't.

In saying "but I don't," you are saying that you are at least choosing not to use this method of fixing the problem of finding the true optimal path to a solved cube. But if you were to choose this option, it would mean a substantial bloating of the TFS databases. It will be less than a factor of 24 because some states will be reached from more than one of these 24 variations of the solved state.

However, the count for depth 3 == 28,702 and depth 4 == 799,020. This used the Jakube move generator idea.

Jakube assumed you would consider the orientation of the solved cube doesn't matter, but you seem to keep on insisting on solving to a particular orientation. You might be able to get away with this if you try all 24 orientations of the scramble, or by trying all 24 orientations of a solved cube separately. Or you might just be content with producing solutions that might be up to 8 moves longer than what we normally would consider as the optimal solution.

I think your database is leaving out certain sequences based upon an assumption that they should not matter if we don't care about the orientation of the solved cube. Hence you end up with numbers in between my numbers for "cube orientation doesn't matter" and my numbers for "cube orientation does matter."
 
No, only 9 of the 23 non-identity cube rotations are at a distance of 4. The other 14 I believe are all at a distance of 8.

So the following moves should all have a distance-from-solved = 0?

U D' u d'
U2 D2 u2 d2

F B' f b'
F2 B2 f2 b2

L R' l r'
L2 R2 l2 r2


So what happens if you start out partway to a different rotated state, such as L R' l? What would its turns-from-solved distance be?


Solving to a particular orientation will always take at least as many moves as solving to any orientation, and many times it will require more moves.

Theorem, postulate, lemma, fact?

By the way, in saying "optimal distance," you are being sort of redundant. Remember, the graph theory term distance refers to the length of an optimal path. The length of an arbitrary path is not necessarily the distance between the endpoints of the path. These are only equal if the path is optimal.

You can say that again! :)


In saying "but I don't," you are saying that you are at least choosing not to use this method of fixing the problem...

It was more along the lines of stating the present condition of the code.

Jakube assumed you would consider the orientation of the solved cube doesn't matter, but you seem to keep on insisting on solving to a particular orientation.

"Insisting" is probably a strong word. The solver now does not prefer an orientation. It can tell if the cube is solved without requiring a color to be on a particular face. However, having said that, the solver does "start somewhere," and that somewhere is the state of the cube initially passed to the move generation routine. Does it have to find a solution in the default orientation? No. Is all of the subsequent move generation based off of this starting arrangement? Yes.

I think your database is leaving out certain sequences based upon an assumption that they should not matter if we don't care about the orientation of the solved cube. Hence you end up with numbers in between my numbers for "cube orientation doesn't matter" and my numbers for "cube orientation does matter."

It is allowing moves that rotate the cube in place, such as U D' u d', it is disallowing transpositions from the solved state, such as the second sequence of the r2 b2 l2/l2 b2 r2 example, and it disallows any sequence that recreates the starting position.

The biggest hurdle I have right now is how to deal with the U u = D d problem. I don't see how to code something from the perspective of the move generator without having to perform some kind of lookup.
 
I handle this in my solver by fixing a single corner (DLB). Then moves such as D are actually handled by Uw3 (for example).

This also means in the end I need to "clean up" my solutions, converting moves such as Uw3 to D and reorienting the
remaining moves appropriately.

My move generator then takes this into account, and all works nicely, both with respect to generating moves and pruning
the tree of redundant move sequences from the top, and looking up values in the pruning table.

Essentially, for each possible syllable (sequence of moves on one axis) you want to have a single canonical move sequence
for that and suppress all the others. And it is here that you either fix a corner, or adopt some other approach to
implicitly suppress sequences that are identical except for full-cube-rotations.

There are 63 non-trivial syllables, where non-trivial means materially affects the cube state (not just being a full-cube
rotation).
 
Last edited:
I handle this in my solver by fixing a single corner (DLB). Then moves such as D are actually handled by Uw3 (for example).

This also means in the end I need to "clean up" my solutions, converting moves such as Uw3 to D and reorienting the
remaining moves appropriately.

My move generator then takes this into account, and all works nicely, both with respect to generating moves and pruning
the tree of redundant move sequences from the top, and looking up values in the pruning table.

Essentially, for each possible syllable (sequence of moves on one axis) you want to have a single canonical move sequence
for that and suppress all the others. And it is here that you either fix a corner, or adopt some other approach to
implicitly suppress sequences that are identical except for full-cube-rotations.

There are 63 non-trivial syllables, where non-trivial means materially affects the cube state (not just being a full-cube
rotation).

Can you show me a concrete example?
 
Concrete example of a syllable?

U u is one. U u' is another.

The 63 number comes from the fact that if you fix a single slice,
you have 4^3=64 possibilities for the other three; one is trivial,
so don't count that, leaving 63.

This number is independent of your metric. But depending on your
metric, the actual move sequence to attain each of these syllables
differs, and in some metrics it is easier than others to figure out
the "shortest" or "best" move sequence.

For instance, one syllable is just U u2 d3. This is equivalently
Uw u d3. You pick one, and make the others illegal.

I've got a Perl script that generates a state machine based on
the next selected move that gives the legal subsequent moves
(as a bitmask). The table turns out to be pretty small in all
three of the metrics we have been working with.
 
Most comp-sci names are unintuitive: Alpha-beta routine, hashing function, indexing function, minimal window principal variation search, sparsely-populated matrix, etc. After you hear them enough, they become second nature. Kind of reminds me of an Arthur Shopenhauer quote: All truth passes through three stages. First, it is ridiculed. Second, it is violently opposed. Third, it is accepted as being self-evident.
Oh god. Don't be like this. He's just suggesting you use better names.

Incidentally, that quote seems to have very little relation to reality. I can only think of a few facts that followed those stages, and they are isolated cases; I can't even imagine violent opposition to facts like "selection sort is O(n^2)" or "7 has no positive factors other than 1 and itself". And surely it must mean something that academics and scientists never use this quote. Clearly being in the first two stages is a completely broken predictor of whether your ideas are valid.

Solving to a particular orientation will always take at least as many moves as solving to any orientation, and many times it will require more moves.
Theorem, postulate, lemma, fact?
It can't take *more* moves to solve to any orientation than to solve to a particular orientation, because any solution to a particular orientation is already a solution to any orientation. And it's easy to exhibit positions where solving to a particular orientation can take many more moves than solving to any orientation (e.g. y x U).
 
Oh god. Don't be like this. He's just suggesting you use better names.

The names are merely a cascade of the start-to-finish types of operations the program is doing. Example:

Solved State Transpositionless Face Rotation

Solved State = where it starts from
Transpositionless = elimination of move sequences that transpose
Face Rotation = allow moves that functionally rotate an entire cube face from one place to another, such as front ---> left via U D' u d'

Arbitrary Scramble Rotationless Transposition

Arbitrary Scramble = where it starts from
Rotationless = disallowing of moves that rotate entire cube faces
Transposition = allowing transpositional move sequences, such as r2 f2 l2 and l2 f2 r2

Arbitrary Scramble Preferred Orientation Transposition

Yeah, this one could use a better name. Especially since it will probably be eliminated.

Incidentally, that quote seems to have very little relation to reality. I can only think of a few facts that followed those stages, and they are isolated cases;

When Galileo supposedly uttered Eppur si muove before The Inquisition, (Latin for "And yet it moves," which opposed the biblical phrase "the Lord set the earth on its foundations; it can never be moved." from the Book of Psalms and 1 Chronicles and perhaps a few other places) I would have to say his supporting Copernicus's heliocentric model was being violently opposed after having been openly ridiculed. I don't think I am going out on a limb suggesting that it is now regarded as self-evident.

Copernicus himself did not publish his book De revolutionibus orbium coelestium until he was on his deathbed, and he even dedicated the book to Pope Paul III in an attempt to basically kiss the Catholic Church's butt. I would have to say from the words of his dedication, Copernicus was, at the very least, fearing rejection: "I can easily conceive, most Holy Father, that as soon as some people learn that in this book which I have written concerning the revolutions of the heavenly bodies, I ascribe certain motions to the Earth, they will cry out at once that I and my theory should be rejected." The fact that he waited until he was nearly dead strongly suggests he was concerned about being "violently opposed."

Jonathan Swift has a great quote on the subject as well: "When a true genius appears in this world, you may know him by this sign, that the dunces are all in confederacy against him."

Darwin's Theory of Evolution was widely criticized at the time, and still stirs controversy today. Even when he wrote to one of his close friends about his theory prior to publication, Darwin said putting such a "foolish" work in print was like "confessing [to] a murder." William Herschel had the best name for it I have heard, calling it "The law of higgledy-piggelty." Darwin's former Geology instructor, Adam Sedgwick, wrote a letter Darwin saying: "I have read your book with more pain than pleasure… you have deserted the true inductive path."

Of course there are more modern examples as well.

After Kitty Hawk, The Wrights flew their "contraption" in fields adjoining very busy railroad lines in Dayton, Ohio for months on end. American businessmen and bankers refused to come to the demonstrations. The magazine Scientific American published stories about "The Lying Brothers." The local Dayton newspapers never dispatched a single reporter to "investigate." The Wrights grew sick of the snubbings, and eventually moved to Europe where they became very successful.

It was someone named Chandrasekhar that first published the idea of what he called a "dark star" and later would be called a "Black Hole." Sir Arthur Eddington, a respectable scientist who had verified one of Einstein's predictions regarding the curvature of spacetime during a solar eclipse in 1919, was so openly critical of Chandrasekhar's papers that the idea of a Black Hole was nearly snuffed out altogether. Because Eddington was held in such high regard, even scientists who supported Chandrasekhar privately did not do so publicly.

Binning, Roher, & Ruska invented an atomic-scale resolution microscope in 1982. Demonstrations of their Scanning-Tunneling Microscope were being ridiculed through 1985, the year before they were awarded the Nobel Prize. Their instrument was ultra-sensitive, and many times they had to wait until very late at night to showcase it, since vibrations from daytime activity in the city would affect it adversely.

The problem with our own comprehension is that it is easy to conceive of "small changes," but hard to grasp really large ones. What comes to mind when you picture the automobile of 1903? A makeshift jalopy with very little horsepower that would backfire often and break down often? If so, you're pretty well on the mark. Now imagine two bicycle mechanics show up on your doorstep and tell you that they invented a "flying machine." It would be very hard to believe! Engines were heavy and weak in 1903. How could one be light enough and powerful enough to fly? Einstein suffered from the same lack of credentials prior to publication of what we now call Relativity. He was, after all, a patent clerk working in Switzerland when he basically supplanted Isaac Newton's most hallowed work. Imagine a "nobody" knocking on the door of a Physics Department chairperson and saying, "Newton is wrong," and offering nothing but "thought experiments" on paper, with no experimental data backing up his claims.

It can't take *more* moves to solve to any orientation than to solve to a particular orientation, because any solution to a particular orientation is already a solution to any orientation. And it's easy to exhibit positions where solving to a particular orientation can take many more moves than solving to any orientation (e.g. y x U).

Hmmm... interesting way to state it! Thank you.

Concrete example of a syllable?

U u is one. U u' is another.

The 63 number comes from the fact that if you fix a single slice,
you have 4^3=64 possibilities for the other three; one is trivial,
so don't count that, leaving 63.

Yes, this is what I was referring to, and I was just working this out independently when I saw the new posts.

This number is independent of your metric. But depending on your
metric, the actual move sequence to attain each of these syllables
differs, and in some metrics it is easier than others to figure out
the "shortest" or "best" move sequence.

...and this is as far as I got before I was stuck!

For instance, one syllable is just U u2 d3. This is equivalently
Uw u d3. You pick one, and make the others illegal.

Which is what I thought my new linear move generator had accomplished when I generated these moves:

http://lightningcloudcomputing.com/depth_03.txt

...but somehow someway moves were left off of the list! My mechanism for demarcating a unique cube position must be wrong.

I've got a Perl script that generates a state machine based on
the next selected move that gives the legal subsequent moves
(as a bitmask). The table turns out to be pretty small in all
three of the metrics we have been working with.

I've done it for up to 5 moves, but it is clearly faulty. And not in PERL, but C. I'd be interested in seeing your script.
 
Last edited:
I don't think I am going out on a limb suggesting that it is now regarded as self-evident.

When you look up at the sky, I don't think there's anything "self-evident" about orbiting the sun.
It may only require "basic" mechanics, but smart thinkers starting with the Greeks drew an incorrect conclusion because it is *not* self-evident. We just have better measurements, theories, and masses of data now, and it is evidently the best theory in that context.

The people trying to help you in this thread are not oligarchs who are trying to prevent you from doing usurping them. They want to help move the field of cube solvers forward, and they're patiently trying to share what they know from working at the front of this area themselves.

Until you come with a revolutionary idea that you demonstrate to work in some way, nothing about your ideas are evident (never mind the "self-"). Please try them, but don't question the merits of existing knowledge unless you have a substantial reason. Talking about paradigm shifts in astronomy just makes you *look* like a crank.

I'm sorry if I sound mean, but it saddens me to see so many posts wasted on silly stuff when we should be listening to each other.
I hope the rest of this thread is filled with cool stuff about making 4x4x4 solvers better.
 
When you look up at the sky, I don't think there's anything "self-evident" about orbiting the sun.
It may only require "basic" mechanics, but smart thinkers starting with the Greeks drew an incorrect conclusion because it is *not* self-evident. We just have better measurements, theories, and masses of data now, and it is evidently the best theory in that context.

Yes, actually, one reason that it became not "self-evident" (aka counter intuitive) is because they did the math. They realized we would have to be spinning at around 1000MPH and revolving around the sun at 67,000 MPH which is correct, and that seems impossible. It's still hard for me to wrap my head around when I really try to think about it.
 
When you look up at the sky, I don't think there's anything "self-evident" about orbiting the sun.
It may only require "basic" mechanics, but smart thinkers starting with the Greeks drew an incorrect conclusion because it is *not* self-evident. We just have better measurements, theories, and masses of data now, and it is evidently the best theory in that context.

I agree, it is not self-evident to the individual. It was the retrograde motion of the planets that gave the hard-core nighttime skywatchers fits. The whole concept of nested, "celestial orbs" was constructed to explain it away, with more and more concentric spheres added whenever a new object in the sky did not fit the existing mold. The Shopenhaurer quote applied to "scientific truth" in general and new discoveries in particular. In this respect, of course, the quote is perfectly applicable.

The people trying to help you in this thread are not oligarchs who are trying to prevent you from doing usurping them.

Such a statement can only mean there is a complete misunderstanding of my mentioning Shopenhaurer. I was not referring to me specifically or anything like that: I was referring to the remark about not liking the names.

Most comp-sci names are unintuitive: Alpha-beta routine, hashing function, indexing function, minimal window principal variation search, sparsely-populated matrix, etc. After you hear them enough, they become second nature. Kind of reminds me of an Arthur Shopenhauer quote...

...and by this I meant, once the idea (in this case, say the name Arbitrary Scramble Rotationless Transposition) is chatted about and discussed and used in context a few times, it becomes second nature. Kind of like TFS = turns-from-solved. That's all I meant. Period. In case there is any doubt, I am not proud of the sad, sorry state of my program at all. By any workable definition, it is a failure. I am not trying to align myself with any great thinker, past or present.

Until you come with a revolutionary idea that you demonstrate to work in some way, nothing about your ideas are evident (never mind the "self-"). Please try them, but don't question the merits of existing knowledge unless you have a substantial reason. Talking about paradigm shifts in astronomy just makes you *look* like a crank.

Again, the Shopenhaurer quote was about the resistance to use the names/acronyms. See the above. And the astronomy references were to offer a response to the qqwref statement:

Incidentally, that quote seems to have very little relation to reality.

Shopenhaurer's quote does have a basis in reality, and I offered examples of its domain of applicability. That's all. It was not meant as a slight. I think I have the right here to post a simple rebuttal to a statement such as the one I answered. It was not meant to stir a debate. I thought the only reply I would get to it would be something like, "Oh, I see."


I'm sorry if I sound mean, but it saddens me to see so many posts wasted on silly stuff when we should be listening to each other.
I hope the rest of this thread is filled with cool stuff about making 4x4x4 solvers better.

I don't take offense to any of it because I can see how what I posted could have been misunderstood. And, hopefully, you see what I was trying to convey after my explanations.
 
I'd be interested in seeing your script.

I'm happy to answer any questions and explain in more detail, but I'd prefer not to share
the code. I'm a big believer in independent implementation to cross-validate results.
Also, my script makes some implicit assumptions (such as move numbering, face numbering,
axis numbering) that are not obvious and may not apply to you.

The script actually does a *search* to find the best move sequence for a given
syllable, and it selects moves based on a set of priorities (prefer quarter turns to
half turns, prefer block moves to slice moves, things like that). Each metric simply
defines the set of moves that are allowed. Said search is straightforward and I
won't insult you by suggesting how it should be implemented.

Once the search is done, and we have a move sequence for each syllable, it combines
these into a finite state machine using a standard nondeterministic finite state machine
reduction. This is a standard algorithm that you are probably familiar with. If not,
the explanations on Wikipedia are probably superior to anything I can write in this
tiny text box.
 
I'm happy to answer any questions and explain in more detail...The script actually does a *search* to find the best move sequence for a given
syllable

Perfectly understandable.

I was hoping there were some Meta-Rules that could be applied to avoid a search, but apparently the only alternative is to work on 24 different cube orientations in tandem.

So a few questions I have are:

1. Given that there are some transposing move sequences which can:

a) create the same position on a solved cube,

and...

b) create a different position from a randomly scrambled cube...

...does this imply that the total number of unique moves possible as a function of depth from any given position might vary?

For example, make moves A,B,C,D on a cube. Note the position. Reset it to where it was. Make moves B,A,D,C. Either it creates the same final cube, or it doesn't. Could there be MANY positions where each of these conditions is true? And, if that is the case, can we say there is no function n(d) where n is the node count and d is the depth from an arbitrary position?

Or, are the only divisions the solved cube state vs. all other non-solved states?

2. This goes along with question 1 somewhat. In chess, we can list every possible legal move to a certain depth, such as 1. e4 e5 2. Nf3 and 1. e4 c5 2. d4 cxd4 3. c3 dxc3 4. Nxc3, etc. Has anyone performed any auditing of the move generator output to determine if, in fact, they are all in agreement? Or has there only been node count level verification?

3. Given that there is a linear array of legal moves to some depth, d, is it possible to extrapolate the list to the next depth via introspecting the current list? For example:

All_Depth_4_Moves[move_1][move_2][move_3][move_4] contains the moves that are legal at depth 4. [move_1] is just an index, 0...35 for U,R,F...d2,l2,b2. Ditto for the other indices.
If the moves are legal, All_Depth_4_Moves[][][][] would contain 1, otherwise it contains 0.

If I want to build a 5th-ply extension to this, can do something like this:

new_move_1_at_depth_ 5 = A
new_move_2_at_depth_ 5 = B
new_move_3_at_depth_ 5 = C
new_move_4_at_depth_ 5 = D
new_move_5_at_depth_ 5 = E

if(All_Depth_4_Moves[A][C][D] == 1) and (All_Depth_4_Moves[C][D][E] == 1) then the 5 moves are legal?
 
Status
Not open for further replies.
Back
Top