Browse Source

4x4x4: update tsai phase3 tables to avoid Lw, Dw, Bw

Daniel Walton 1 year ago
parent
commit
cfe15739f2
3 changed files with 95 additions and 60 deletions
  1. 2
    2
      misc/TODO.txt
  2. 58
    35
      rubikscubennnsolver/LookupTable.py
  3. 35
    23
      rubikscubennnsolver/RubiksCube444.py

+ 2
- 2
misc/TODO.txt View File

@@ -100,7 +100,7 @@ time ./utils/test.py --test-cubes utils/test_cubes.json.small --size 4x4x4
100 100
 
101 101
 
102 102
 - step80...we spend 40+  moves in this phase
103
-    - we solve LR and then FB prune to speed up step80...can we avoid this
103
+    - we solve LR and then FB prune to speed up step80...can we avoid this?
104 104
     - build the main table out to 6-deep
105 105
     - build a bunch of 24 million entry prune tables
106 106
     - test with this cube
@@ -112,7 +112,7 @@ time ./utils/test.py --test-cubes utils/test_cubes.json.small --size 4x4x4
112 112
 =====
113 113
 8x8x8
114 114
 =====
115
-- Add support in prevent_OLL()
115
+LOW - Add support in prevent_OLL()
116 116
 
117 117
 
118 118
 =================

+ 58
- 35
rubikscubennnsolver/LookupTable.py View File

@@ -86,74 +86,97 @@ class LookupTable(object):
86 86
 
87 87
                 # Special cases where I could not get them one under 100M so I split it via:
88 88
                 # split -b 40m lookup-table-4x4x4-step70-tsai-phase3.txt.gz "lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-"
89
+
90
+                # =====
91
+                # 4x4x4
92
+                # =====
89 93
                 if self.filename_gz == 'lookup-table-4x4x4-step70-tsai-phase3.txt.gz':
90 94
 
91
-                    # Download part-aa
92
-                    url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-aa" %\
93
-                        (self.parent.size, self.parent.size, self.parent.size)
94
-                    log.info("Downloading table via 'wget %s'" % url)
95
-                    subprocess.call(['wget', url])
95
+                    # Download all parts
96
+                    for extension in ('aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak'):
97
+                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-%s" %\
98
+                            (self.parent.size, self.parent.size, self.parent.size, extension)
99
+                        log.info("Downloading table via 'wget %s'" % url)
100
+                        subprocess.call(['wget', url])
96 101
 
97
-                    # Download part-ab
98
-                    url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-ab" %\
99
-                        (self.parent.size, self.parent.size, self.parent.size)
100
-                    log.info("Downloading table via 'wget %s'" % url)
101
-                    subprocess.call(['wget', url])
102
+                    # cat them together into a .gz file
103
+                    subprocess.call('cat lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-* > lookup-table-4x4x4-step70-tsai-phase3.txt.gz', shell=True)
102 104
 
103
-                    # Download part-ac
104
-                    url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-ac" %\
105
-                        (self.parent.size, self.parent.size, self.parent.size)
106
-                    log.info("Downloading table via 'wget %s'" % url)
107
-                    subprocess.call(['wget', url])
105
+                    # remove all of the parts
106
+                    for extension in ('aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak'):
107
+                        os.unlink('lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-%s' % extension)
108 108
 
109
-                    subprocess.call('cat lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-* > lookup-table-4x4x4-step70-tsai-phase3.txt.gz', shell=True)
110
-                    os.unlink('lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-aa')
111
-                    os.unlink('lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-ab')
112
-                    os.unlink('lookup-table-4x4x4-step70-tsai-phase3.txt.gz.part-ac')
109
+                elif self.filename_gz == 'lookup-table-4x4x4-step71-tsai-phase3-edges.txt.gz':
113 110
 
114
-                elif self.filename_gz == 'lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz':
111
+                    # Download all parts
112
+                    for extension in ('aa', 'ab', 'ac', 'ad'):
113
+                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step71-tsai-phase3-edges.txt.gz.part-%s" %\
114
+                            (self.parent.size, self.parent.size, self.parent.size, extension)
115
+                        log.info("Downloading table via 'wget %s'" % url)
116
+                        subprocess.call(['wget', url])
117
+
118
+                    # cat them together into a .gz file
119
+                    subprocess.call('cat lookup-table-4x4x4-step71-tsai-phase3-edges.txt.gz.part-* > lookup-table-4x4x4-step71-tsai-phase3-edges.txt.gz', shell=True)
120
+
121
+                    # remove all of the parts
122
+                    for extension in ('aa', 'ab', 'ac', 'ad'):
123
+                        os.unlink('lookup-table-4x4x4-step71-tsai-phase3-edges.txt.gz.part-%s' % extension)
124
+
125
+                # =====
126
+                # 5x5x5
127
+                # =====
128
+                elif self.filename_gz == 'lookup-table-4x4x4-step50-tsai-phase1.txt.gz':
115 129
 
116 130
                     # Download all three parts
117 131
                     for extension in ('aa', 'ab', 'ac'):
118
-                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-%s" %\
132
+                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-%s" %\
119 133
                             (self.parent.size, self.parent.size, self.parent.size, extension)
120 134
                         log.info("Downloading table via 'wget %s'" % url)
121 135
                         subprocess.call(['wget', url])
122 136
 
123
-                    subprocess.call('cat lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-* > lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz', shell=True)
124
-                    os.unlink('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-aa')
125
-                    os.unlink('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-ab')
126
-                    os.unlink('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-ac')
137
+                    # cat them together into a .gz file
138
+                    subprocess.call('cat lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-* > lookup-table-4x4x4-step50-tsai-phase1.txt.gz', shell=True)
139
+
140
+                    # remove all of the parts
141
+                    os.unlink('lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-aa')
142
+                    os.unlink('lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-ab')
143
+                    os.unlink('lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-ac')
127 144
 
145
+                # =====
146
+                # 6x6x6
147
+                # =====
128 148
                 elif self.filename_gz == 'lookup-table-6x6x6-step20-UD-oblique-edge-pairing.txt.gz':
129 149
 
130 150
                     # Download all parts
131 151
                     for extension in ('aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al'):
132
-                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-%s" %\
152
+                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-6x6x6-step20-UD-oblique-edge-pairing.txt.gz.part-%s" %\
133 153
                             (self.parent.size, self.parent.size, self.parent.size, extension)
134 154
                         log.info("Downloading table via 'wget %s'" % url)
135 155
                         subprocess.call(['wget', url])
136 156
 
137
-                    #subprocess.call('cat lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-* > lookup-table-4x4x4-step50-tsai-phase1.txt.gz', shell=True)
157
+                    # cat them together into a .gz file
138 158
                     subprocess.call('cat lookup-table-6x6x6-step20-UD-oblique-edge-pairing.txt.gz.part-* > lookup-table-6x6x6-step20-UD-oblique-edge-pairing.txt.gz', shell=True)
139 159
 
160
+                    # remove all of the parts
140 161
                     for extension in ('aa', 'ab', 'ac', 'ad', 'ae', 'af', 'ag', 'ah', 'ai', 'aj', 'ak', 'al'):
141
-                        os.unlink('lookup-table-6x6x6-step20-UD-oblique-edge-pairing.txt.gz-%s' % extension)
142
-
162
+                        os.unlink('lookup-table-6x6x6-step20-UD-oblique-edge-pairing.txt.gz.part-%s' % extension)
143 163
 
144
-                elif self.filename_gz == 'lookup-table-4x4x4-step50-tsai-phase1.txt.gz':
164
+                elif self.filename_gz == 'lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz':
145 165
 
146 166
                     # Download all three parts
147 167
                     for extension in ('aa', 'ab', 'ac'):
148
-                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-%s" %\
168
+                        url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-%s" %\
149 169
                             (self.parent.size, self.parent.size, self.parent.size, extension)
150 170
                         log.info("Downloading table via 'wget %s'" % url)
151 171
                         subprocess.call(['wget', url])
152 172
 
153
-                    subprocess.call('cat lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-* > lookup-table-4x4x4-step50-tsai-phase1.txt.gz', shell=True)
154
-                    os.unlink('lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-aa')
155
-                    os.unlink('lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-ab')
156
-                    os.unlink('lookup-table-4x4x4-step50-tsai-phase1.txt.gz.part-ac')
173
+                    # cat them together into a .gz file
174
+                    subprocess.call('cat lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-* > lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz', shell=True)
175
+
176
+                    # remove all of the parts
177
+                    os.unlink('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-aa')
178
+                    os.unlink('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-ab')
179
+                    os.unlink('lookup-table-6x6x6-step60-LFRB-solve-inner-x-center-and-oblique-edges.txt.gz.part-ac')
157 180
 
158 181
                 else:
159 182
                     url = "https://github.com/dwalton76/rubiks-cube-lookup-tables-%sx%sx%s/raw/master/%s" % (self.parent.size, self.parent.size, self.parent.size, self.filename_gz)

+ 35
- 23
rubikscubennnsolver/RubiksCube444.py View File

@@ -767,15 +767,17 @@ class LookupTable444TsaiPhase3CentersSolve(LookupTable):
767 767
     """
768 768
     lookup-table-4x4x4-step72-tsai-phase3-centers.txt
769 769
     =================================================
770
-    1 steps has 7 entries (0 percent, 0.00x previous step)
771
-    2 steps has 83 entries (0 percent, 11.86x previous step)
772
-    3 steps has 724 entries (1 percent, 8.72x previous step)
773
-    4 steps has 3851 entries (6 percent, 5.32x previous step)
774
-    5 steps has 10,426 entries (17 percent, 2.71x previous step)
775
-    6 steps has 16,693 entries (28 percent, 1.60x previous step)
776
-    7 steps has 16,616 entries (28 percent, 1.00x previous step)
777
-    8 steps has 8,928 entries (15 percent, 0.54x previous step)
778
-    9 steps has 1,472 entries (2 percent, 0.16x previous step)
770
+    1 steps has 4 entries (0 percent, 0.00x previous step)
771
+    2 steps has 34 entries (0 percent, 8.50x previous step)
772
+    3 steps has 247 entries (0 percent, 7.26x previous step)
773
+    4 steps has 1,282 entries (2 percent, 5.19x previous step)
774
+    5 steps has 4,844 entries (8 percent, 3.78x previous step)
775
+    6 steps has 11,821 entries (20 percent, 2.44x previous step)
776
+    7 steps has 17,486 entries (29 percent, 1.48x previous step)
777
+    8 steps has 15,121 entries (25 percent, 0.86x previous step)
778
+    9 steps has 6,889 entries (11 percent, 0.46x previous step)
779
+    10 steps has 1,063 entries (1 percent, 0.15x previous step)
780
+    11 steps has 9 entries (0 percent, 0.01x previous step)
779 781
 
780 782
     Total: 58,800 entries
781 783
     """
@@ -840,15 +842,16 @@ class LookupTableIDA444TsaiPhase3(LookupTableIDA):
840 842
 
841 843
     lookup-table-4x4x4-step70-tsai-phase3.txt
842 844
     ==========================================
843
-    1 steps has 7 entries (0 percent, 0.00x previous step)
844
-    2 steps has 83 entries (0 percent, 11.86x previous step)
845
-    3 steps has 960 entries (0 percent, 11.57x previous step)
846
-    4 steps has 10,303 entries (0 percent, 10.73x previous step)
847
-    5 steps has 107,474 entries (0 percent, 10.43x previous step)
848
-    6 steps has 1,124,149 entries (8 percent, 10.46x previous step)
849
-    7 steps has 11,660,824 entries (90 percent, 10.37x previous step)
850
-
851
-    Total: 12,903,800 entries
845
+    1 steps has 4 entries (0 percent, 0.00x previous step)
846
+    2 steps has 34 entries (0 percent, 8.50x previous step)
847
+    3 steps has 371 entries (0 percent, 10.91x previous step)
848
+    4 steps has 3,834 entries (0 percent, 10.33x previous step)
849
+    5 steps has 38,705 entries (0 percent, 10.10x previous step)
850
+    6 steps has 385,747 entries (0 percent, 9.97x previous step)
851
+    7 steps has 3,884,435 entries (8 percent, 10.07x previous step)
852
+    8 steps has 39,549,005 entries (90 percent, 10.18x previous step)
853
+
854
+    Total: 43,862,135 entries
852 855
     """
853 856
 
854 857
     def __init__(self, parent):
@@ -858,13 +861,21 @@ class LookupTableIDA444TsaiPhase3(LookupTableIDA):
858 861
             'lookup-table-4x4x4-step70-tsai-phase3.txt',
859 862
             '001UU31UU322118LL98LL955229BBa9BBa4433aRRbaRRb7700bFF8bFF866445DD75DD766',
860 863
             moves_4x4x4,
861
-            ("Fw", "Fw'", "Bw", "Bw'", "Uw", "Uw'", "Dw", "Dw'",
862
-             "Rw", "Rw'", "Lw", "Lw'", "R", "R'", "L", "L'"), # illegal_moves
864
+
865
+            # illegal moves
866
+            ("Fw", "Fw'",
867
+             "Uw", "Uw'",
868
+             "Rw", "Rw'",
869
+             "Lw", "Lw'", "Lw2",
870
+             "Bw", "Bw'", "Bw2",
871
+             "Dw", "Dw'", "Dw2",
872
+             "R", "R'",
873
+             "L", "L'"),
863 874
 
864 875
             # prune tables
865 876
             (parent.lt_tsai_phase3_edges_solve,
866 877
              parent.lt_tsai_phase3_centers_solve),
867
-            linecount=12903800)
878
+            linecount=43862135)
868 879
 
869 880
     def state(self):
870 881
         parent_state = self.parent.state
@@ -1252,7 +1263,7 @@ class RubiksCube444(RubiksCube):
1252 1263
             log.info("%s: Start of Phase1, %d steps in" % (self, self.get_solution_len_minus_rotates(self.solution)))
1253 1264
             self.lt_tsai_phase1.solve()
1254 1265
             self.print_cube()
1255
-            self.tsai_phase2_orient_edges_print()
1266
+            #self.tsai_phase2_orient_edges_print()
1256 1267
             log.info("%s: End of Phase1, %d steps in" % (self, self.get_solution_len_minus_rotates(self.solution)))
1257 1268
 
1258 1269
             # Test the prune table
@@ -1266,12 +1277,13 @@ class RubiksCube444(RubiksCube):
1266 1277
             self.lt_tsai_phase2.avoid_pll = True
1267 1278
             self.lt_tsai_phase2.solve()
1268 1279
             self.print_cube()
1269
-            self.tsai_phase2_orient_edges_print()
1280
+            #self.tsai_phase2_orient_edges_print()
1270 1281
             log.info("%s: End of Phase2, %d steps in" % (self, self.get_solution_len_minus_rotates(self.solution)))
1271 1282
 
1272 1283
             # Testing the phase3 prune tables
1273 1284
             #self.lt_tsai_phase3_edges_solve.solve()
1274 1285
             #self.lt_tsai_phase3_centers_solve.solve()
1286
+            #self.tsai_phase2_orient_edges_print()
1275 1287
             #self.print_cube()
1276 1288
             #sys.exit(0)
1277 1289