cubing 0.66.0 → 0.66.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/chunks/{chunk-VTD7RU7S.js → chunk-HS7R54XN.js} +2 -2
- package/dist/bin/order.js +1 -1
- package/dist/bin/puzzle-geometry-bin.js +1 -1
- package/dist/bin/scramble.js +1 -1
- package/dist/bin/svg.js +1 -1
- package/dist/lib/cubing/alg/index.d.ts +1 -1
- package/dist/lib/cubing/alg/index.js +1 -2
- package/dist/lib/cubing/bluetooth/index.d.ts +2 -2
- package/dist/lib/cubing/bluetooth/index.js +5 -6
- package/dist/lib/cubing/chunks/{big-puzzle-orientation-KCHMEEM7.js → big-puzzle-orientation-KJL4OFV2.js} +1 -2
- package/dist/lib/cubing/chunks/{chunk-XAOXLHYH.js → chunk-6R47S6MP.js} +24 -25
- package/dist/lib/cubing/chunks/{chunk-ZCZVKGKB.js → chunk-7LEVC3YR.js} +1 -2
- package/dist/lib/cubing/chunks/{chunk-7GUL3OBQ.js → chunk-BHVTDDUY.js} +0 -1
- package/dist/lib/cubing/chunks/{chunk-JL5REGXZ.js → chunk-IIJFVP3K.js} +6 -7
- package/dist/lib/cubing/chunks/{chunk-6RZGNWLS.js → chunk-KH2MQ7KY.js} +2 -3
- package/dist/lib/cubing/chunks/{chunk-L6OQRJJX.js → chunk-LBER75W4.js} +1 -2
- package/dist/lib/cubing/chunks/{chunk-ZV7PYR2S.js → chunk-NJ66FRKF.js} +3 -4
- package/dist/lib/cubing/chunks/{chunk-CAQY24I5.js → chunk-QOLD6GH2.js} +5 -6
- package/dist/lib/cubing/chunks/{chunk-CFZLXDM6.js → chunk-QZK3M7IM.js} +0 -1
- package/dist/lib/cubing/chunks/chunk-RDKH6CDA.js +0 -0
- package/dist/lib/cubing/chunks/{chunk-4KLW7Y6J.js → chunk-T5M3DY5P.js} +2 -3
- package/dist/lib/cubing/chunks/{chunk-K237RIQJ.js → chunk-UKAXYOG2.js} +2 -3
- package/dist/lib/cubing/chunks/{chunk-GHFBZYSV.js → chunk-YJH5LHFN.js} +0 -1
- package/dist/lib/cubing/chunks/{inside-BAQGCKLY.js → inside-UWSZBO4Y.js} +14 -15
- package/dist/lib/cubing/chunks/{puzzles-dynamic-3x3x3-FYXD7SIU.js → puzzles-dynamic-3x3x3-CMH2HHH5.js} +0 -1
- package/dist/lib/cubing/chunks/{puzzles-dynamic-4x4x4-AIGABOAR.js → puzzles-dynamic-4x4x4-UFAQS3QG.js} +0 -1
- package/dist/lib/cubing/chunks/{puzzles-dynamic-megaminx-2LVHIDL4.js → puzzles-dynamic-megaminx-EFR4GQFA.js} +0 -1
- package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-653A7JCM.js → puzzles-dynamic-side-events-KF3PEOJN.js} +0 -1
- package/dist/lib/cubing/chunks/{puzzles-dynamic-unofficial-2CY6GVZ4.js → puzzles-dynamic-unofficial-6BF3EWTI.js} +0 -1
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-KPAPKICT.js → search-dynamic-sgs-side-events-5GQDHSJR.js} +5 -6
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-WJZ2CWX5.js → search-dynamic-sgs-unofficial-YM23KVCN.js} +90 -78
- package/dist/lib/cubing/chunks/{search-dynamic-solve-3x3x3-B2L4IN34.js → search-dynamic-solve-3x3x3-6UMZH4WB.js} +3 -6
- package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-OLWUV6G6.js → search-dynamic-solve-4x4x4-KNSBAM7Q.js} +14 -17
- package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-WLOW7LAM.js → search-dynamic-solve-fto-CSXJYISF.js} +200 -90
- package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-KKUOVW5Y.js → search-dynamic-solve-kilominx-EHAUQJXS.js} +105 -113
- package/dist/lib/cubing/chunks/{search-dynamic-solve-master_tetraminx-GIS7T5B7.js → search-dynamic-solve-master_tetraminx-ZQ25QK7E.js} +99 -100
- package/dist/lib/cubing/chunks/search-worker-entry.js +2 -3
- package/dist/lib/cubing/chunks/{twips-J732JDZJ.js → twips-IMF5RNH5.js} +3 -4
- package/dist/lib/cubing/chunks/{twips_wasm_bg-TJNYGA2C-AP2O4LGG.js → twips_wasm_bg-TJNYGA2C-4JIZWC6Q.js} +1 -2
- package/dist/lib/cubing/chunks/{twisty-dynamic-3d-SFR3X64P.js → twisty-dynamic-3d-HSYJR5CM.js} +5 -6
- package/dist/lib/cubing/{index-Bfranlt_.d.ts → index-lAUL_nRN.d.ts} +1 -1
- package/dist/lib/cubing/{index-B2nOJwLe.d.ts → index-nWspzjVK.d.ts} +43 -39
- package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
- package/dist/lib/cubing/kpuzzle/index.js +2 -3
- package/dist/lib/cubing/notation/index.d.ts +1 -1
- package/dist/lib/cubing/notation/index.js +4 -5
- package/dist/lib/cubing/{outside-BdYfq43N.d.ts → outside-CD19aDjE.d.ts} +1 -1
- package/dist/lib/cubing/protocol/index.d.ts +1 -1
- package/dist/lib/cubing/protocol/index.js +4 -5
- package/dist/lib/cubing/puzzle-geometry/index.d.ts +1 -1
- package/dist/lib/cubing/puzzle-geometry/index.js +375 -375
- package/dist/lib/cubing/puzzles/index.d.ts +1 -1
- package/dist/lib/cubing/puzzles/index.js +4 -5
- package/dist/lib/cubing/scramble/index.d.ts +1 -1
- package/dist/lib/cubing/scramble/index.js +8 -9
- package/dist/lib/cubing/search/index.d.ts +1 -1
- package/dist/lib/cubing/search/index.js +7 -8
- package/dist/lib/cubing/stream/index.d.ts +1 -1
- package/dist/lib/cubing/stream/index.js +1 -2
- package/dist/lib/cubing/twisty/index.d.ts +1 -1
- package/dist/lib/cubing/twisty/index.js +6 -7
- package/package.json +1 -1
- package/dist/lib/cubing/alg/index.js.map +0 -7
- package/dist/lib/cubing/bluetooth/index.js.map +0 -7
- package/dist/lib/cubing/chunks/big-puzzle-orientation-KCHMEEM7.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-4KLW7Y6J.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-6RZGNWLS.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-7GUL3OBQ.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-CAQY24I5.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-CFZLXDM6.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-GHFBZYSV.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-JL5REGXZ.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-K237RIQJ.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-L6OQRJJX.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-NAPITA3L.js +0 -1
- package/dist/lib/cubing/chunks/chunk-NAPITA3L.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-XAOXLHYH.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-ZCZVKGKB.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-ZV7PYR2S.js.map +0 -7
- package/dist/lib/cubing/chunks/inside-BAQGCKLY.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-3x3x3-FYXD7SIU.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-4x4x4-AIGABOAR.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-megaminx-2LVHIDL4.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-653A7JCM.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-unofficial-2CY6GVZ4.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-KPAPKICT.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-WJZ2CWX5.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-solve-3x3x3-B2L4IN34.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-solve-4x4x4-OLWUV6G6.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-solve-fto-WLOW7LAM.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-solve-kilominx-KKUOVW5Y.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-solve-master_tetraminx-GIS7T5B7.js.map +0 -7
- package/dist/lib/cubing/chunks/search-worker-entry.js.map +0 -7
- package/dist/lib/cubing/chunks/twips-J732JDZJ.js.map +0 -7
- package/dist/lib/cubing/chunks/twips_wasm_bg-TJNYGA2C-AP2O4LGG.js.map +0 -7
- package/dist/lib/cubing/chunks/twisty-dynamic-3d-SFR3X64P.js.map +0 -7
- package/dist/lib/cubing/kpuzzle/index.js.map +0 -7
- package/dist/lib/cubing/notation/index.js.map +0 -7
- package/dist/lib/cubing/protocol/index.js.map +0 -7
- package/dist/lib/cubing/puzzle-geometry/index.js.map +0 -7
- package/dist/lib/cubing/puzzles/index.js.map +0 -7
- package/dist/lib/cubing/scramble/index.js.map +0 -7
- package/dist/lib/cubing/search/index.js.map +0 -7
- package/dist/lib/cubing/stream/index.js.map +0 -7
- package/dist/lib/cubing/twisty/index.js.map +0 -7
- /package/dist/bin/chunks/{chunk-VTD7RU7S.js.map → chunk-HS7R54XN.js.map} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Alg
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QZK3M7IM.js";
|
|
4
4
|
|
|
5
|
-
// src/cubing/vendor/mpl/xyzzy/kilosolver.
|
|
5
|
+
// src/cubing/vendor/mpl/xyzzy/kilosolver.ts
|
|
6
6
|
import { randomUIntBelow } from "random-uint-below";
|
|
7
7
|
var PHASE4_THRESHOLD = 7;
|
|
8
8
|
function factorial(n) {
|
|
@@ -35,10 +35,10 @@ function permutation_to_index(perm) {
|
|
|
35
35
|
let ind = 0;
|
|
36
36
|
while (n > 1) {
|
|
37
37
|
n--;
|
|
38
|
-
|
|
38
|
+
const e = perm[0];
|
|
39
39
|
ind += e * f;
|
|
40
40
|
for (let i = 0; i < n; i++) {
|
|
41
|
-
|
|
41
|
+
const x = perm[i + 1];
|
|
42
42
|
perm[i] = x - (x > e);
|
|
43
43
|
}
|
|
44
44
|
f /= n;
|
|
@@ -46,7 +46,7 @@ function permutation_to_index(perm) {
|
|
|
46
46
|
return ind;
|
|
47
47
|
}
|
|
48
48
|
function permutation_parity(A) {
|
|
49
|
-
|
|
49
|
+
const n = A.length;
|
|
50
50
|
let parity = 0;
|
|
51
51
|
for (let i = 0; i < n - 1; i++) {
|
|
52
52
|
for (let j = i; j < n; j++) {
|
|
@@ -61,8 +61,8 @@ function evenpermutation_to_index(perm) {
|
|
|
61
61
|
return permutation_to_index(perm) >> 1;
|
|
62
62
|
}
|
|
63
63
|
var [evenpermutation10_to_index, index_to_evenpermutation10] = (() => {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
const index_in_set_bits = new Int8Array(1024 * 10);
|
|
65
|
+
const look_up_set_bits = new Int8Array(1024 * 10);
|
|
66
66
|
for (let i = 0; i < 1024; i++) {
|
|
67
67
|
for (let j = 0, counter = 0; j < 10; j++) {
|
|
68
68
|
if ((i >>> j & 1) === 0) {
|
|
@@ -78,7 +78,7 @@ var [evenpermutation10_to_index, index_to_evenpermutation10] = (() => {
|
|
|
78
78
|
let f = 181440;
|
|
79
79
|
let ind = 0;
|
|
80
80
|
for (let i = 0; i < 8; i++) {
|
|
81
|
-
|
|
81
|
+
const v = perm[i];
|
|
82
82
|
ind += index_in_set_bits[unused | v << 10] * f;
|
|
83
83
|
unused &= ~(1 << v);
|
|
84
84
|
f /= 9 - i;
|
|
@@ -90,10 +90,10 @@ var [evenpermutation10_to_index, index_to_evenpermutation10] = (() => {
|
|
|
90
90
|
let f = 181440;
|
|
91
91
|
let parity = 0;
|
|
92
92
|
for (let i = 0; i < 8; i++) {
|
|
93
|
-
|
|
93
|
+
const a = ind / f | 0;
|
|
94
94
|
ind -= a * f;
|
|
95
95
|
parity ^= a & 1;
|
|
96
|
-
|
|
96
|
+
const v = look_up_set_bits[unused | a << 10];
|
|
97
97
|
perm[i] = v;
|
|
98
98
|
unused &= ~(1 << v);
|
|
99
99
|
f /= 9 - i;
|
|
@@ -130,8 +130,8 @@ function comb_to_index(l) {
|
|
|
130
130
|
function index_to_comb(ind, ones, bits) {
|
|
131
131
|
let zeros = bits - ones;
|
|
132
132
|
let b = C(bits - 1, ones);
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const l = [];
|
|
134
|
+
const n = bits - 1;
|
|
135
135
|
for (let i = 0; i < n; i++) {
|
|
136
136
|
bits--;
|
|
137
137
|
if (ind < b) {
|
|
@@ -147,23 +147,23 @@ function index_to_comb(ind, ones, bits) {
|
|
|
147
147
|
return l;
|
|
148
148
|
}
|
|
149
149
|
function compose(A, B) {
|
|
150
|
-
|
|
150
|
+
const C2 = [];
|
|
151
151
|
for (let i = 0; i < B.length; i++) {
|
|
152
152
|
C2[i] = A[B[i]];
|
|
153
153
|
}
|
|
154
154
|
return C2;
|
|
155
155
|
}
|
|
156
156
|
function compose_o(A, B) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
const p = compose(A[0], B[0]);
|
|
158
|
+
const o = [];
|
|
159
|
+
const n = B[0].length;
|
|
160
160
|
for (let i = 0; i < n; i++) {
|
|
161
161
|
o[i] = (A[1][B[0][i]] + B[1][i]) % 3;
|
|
162
162
|
}
|
|
163
163
|
return [p, o];
|
|
164
164
|
}
|
|
165
165
|
function permutation_from_cycle(cycle, n) {
|
|
166
|
-
|
|
166
|
+
const perm = [];
|
|
167
167
|
for (let i = 0; i < n; i++) {
|
|
168
168
|
perm[i] = i;
|
|
169
169
|
}
|
|
@@ -173,8 +173,8 @@ function permutation_from_cycle(cycle, n) {
|
|
|
173
173
|
return perm;
|
|
174
174
|
}
|
|
175
175
|
function unsparsify_list(d, n) {
|
|
176
|
-
|
|
177
|
-
for (
|
|
176
|
+
const l = Array(n).fill(0);
|
|
177
|
+
for (const k in d) {
|
|
178
178
|
l[k] = d[k];
|
|
179
179
|
}
|
|
180
180
|
return l;
|
|
@@ -222,16 +222,16 @@ for (let i = 0; i < moves.length; i++) {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
function random_state() {
|
|
225
|
-
|
|
225
|
+
const p = [0];
|
|
226
226
|
for (let i = 1; i < 20; i++) {
|
|
227
|
-
|
|
227
|
+
const r = randomUIntBelow(i + 1);
|
|
228
228
|
p[i] = p[r];
|
|
229
229
|
p[r] = i;
|
|
230
230
|
}
|
|
231
231
|
if (permutation_parity(p) === 1) {
|
|
232
232
|
[p[0], p[1]] = [p[1], p[0]];
|
|
233
233
|
}
|
|
234
|
-
|
|
234
|
+
const o = Array(20).fill(0);
|
|
235
235
|
for (let i = 0; i < 19; i++) {
|
|
236
236
|
o[i] = randomUIntBelow(3);
|
|
237
237
|
o[19] += 3 - o[i];
|
|
@@ -240,12 +240,12 @@ function random_state() {
|
|
|
240
240
|
return [p, o];
|
|
241
241
|
}
|
|
242
242
|
function stringify_move_sequence(move_sequence) {
|
|
243
|
-
|
|
244
|
-
|
|
243
|
+
const suffixes = ["0", "", "2", "2'", "'"];
|
|
244
|
+
const s = move_sequence.map(([m, r]) => move_names[m] + suffixes[r]);
|
|
245
245
|
return s.join(" ");
|
|
246
246
|
}
|
|
247
247
|
function apply_move_sequence(state, move_sequence) {
|
|
248
|
-
for (
|
|
248
|
+
for (const [m, r] of move_sequence) {
|
|
249
249
|
for (let i = 0; i < r; i++) {
|
|
250
250
|
state = compose_o(state, moves[m]);
|
|
251
251
|
}
|
|
@@ -256,14 +256,14 @@ function generate_random_state_scramble() {
|
|
|
256
256
|
return solve(random_state());
|
|
257
257
|
}
|
|
258
258
|
function solve_phase1(state) {
|
|
259
|
-
|
|
259
|
+
const p = state[0];
|
|
260
260
|
if (p.slice(15, 20).every((x) => x < 15)) {
|
|
261
261
|
return [];
|
|
262
262
|
}
|
|
263
263
|
if (p.slice(0, 5).every((x) => x < 15)) {
|
|
264
264
|
return [[6, 1]];
|
|
265
265
|
}
|
|
266
|
-
|
|
266
|
+
const flags = p.map((x) => x >= 15);
|
|
267
267
|
let depth = 0;
|
|
268
268
|
let sol;
|
|
269
269
|
while (sol === void 0) {
|
|
@@ -285,8 +285,8 @@ function search_phase1(flags, depth, last) {
|
|
|
285
285
|
continue;
|
|
286
286
|
}
|
|
287
287
|
for (let r = 1; r < 5; r++) {
|
|
288
|
-
|
|
289
|
-
|
|
288
|
+
const new_flags = compose(flags, moves_full[move_index][r][0]);
|
|
289
|
+
const sol = search_phase1(new_flags, depth - 1, move_index);
|
|
290
290
|
if (sol !== void 0) {
|
|
291
291
|
return [[move_index, r]].concat(sol);
|
|
292
292
|
}
|
|
@@ -295,73 +295,73 @@ function search_phase1(flags, depth, last) {
|
|
|
295
295
|
return;
|
|
296
296
|
}
|
|
297
297
|
function index_phase2(state) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
298
|
+
const p = state[0].slice(0, 15);
|
|
299
|
+
const o = state[1];
|
|
300
|
+
const index_c = comb_to_index(p.map((x) => +(x >= 15)));
|
|
301
301
|
let index_o = 243 * index_c;
|
|
302
302
|
for (let i = 0, j = 0; i < 15; i++) {
|
|
303
303
|
if (p[i] < 15) {
|
|
304
304
|
continue;
|
|
305
305
|
}
|
|
306
|
-
index_o += o[i] *
|
|
306
|
+
index_o += o[i] * 3 ** j;
|
|
307
307
|
j++;
|
|
308
308
|
}
|
|
309
309
|
let index_p = 0;
|
|
310
310
|
for (let i = 0; i < 5; i++) {
|
|
311
|
-
index_p += p.indexOf(15 + i) *
|
|
311
|
+
index_p += p.indexOf(15 + i) * 15 ** i;
|
|
312
312
|
}
|
|
313
313
|
return [index_o, index_p];
|
|
314
314
|
}
|
|
315
315
|
function solve_phase2(state) {
|
|
316
|
-
|
|
316
|
+
const mtables = [
|
|
317
317
|
generate_phase23_orientation_mtable(),
|
|
318
318
|
generate_phase23_permutation_mtable()
|
|
319
319
|
];
|
|
320
|
-
|
|
320
|
+
const ptables = [
|
|
321
321
|
generate_phase2_orientation_ptable(),
|
|
322
322
|
generate_phase2_permutation_ptable()
|
|
323
323
|
];
|
|
324
324
|
return ida_solve(index_phase2(state), mtables, ptables).concat([[6, 1]]);
|
|
325
325
|
}
|
|
326
326
|
function index_phase3(state) {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
327
|
+
const pieces = [5, 6, 7, 8, 14];
|
|
328
|
+
const p = state[0].slice(0, 15);
|
|
329
|
+
const o = state[1];
|
|
330
|
+
const index_c = comb_to_index(p.map((x) => +(pieces.indexOf(x) !== -1)));
|
|
331
331
|
let index_o = 243 * index_c;
|
|
332
332
|
for (let i = 0, j = 0; i < 15; i++) {
|
|
333
333
|
if (pieces.indexOf(p[i]) === -1) {
|
|
334
334
|
continue;
|
|
335
335
|
}
|
|
336
|
-
index_o += o[i] *
|
|
336
|
+
index_o += o[i] * 3 ** j;
|
|
337
337
|
j++;
|
|
338
338
|
}
|
|
339
339
|
let index_p = 0;
|
|
340
340
|
for (let i = 0; i < 5; i++) {
|
|
341
|
-
index_p += p.indexOf(pieces[i]) *
|
|
341
|
+
index_p += p.indexOf(pieces[i]) * 15 ** i;
|
|
342
342
|
}
|
|
343
343
|
return [index_o, index_p];
|
|
344
344
|
}
|
|
345
345
|
function solve_phase3(state) {
|
|
346
|
-
|
|
346
|
+
const mtables = [
|
|
347
347
|
generate_phase23_orientation_mtable(),
|
|
348
348
|
generate_phase23_permutation_mtable()
|
|
349
349
|
];
|
|
350
|
-
|
|
350
|
+
const ptables = [
|
|
351
351
|
generate_phase3_orientation_ptable(),
|
|
352
352
|
generate_phase3_permutation_ptable()
|
|
353
353
|
];
|
|
354
354
|
return ida_solve(index_phase3(state), mtables, ptables);
|
|
355
355
|
}
|
|
356
356
|
function index_phase4(state) {
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
const p = state[0].slice(0, 14);
|
|
358
|
+
const o = state[1];
|
|
359
359
|
let index_o = 0;
|
|
360
|
-
|
|
360
|
+
const perm = [];
|
|
361
361
|
let j = 0;
|
|
362
|
-
for (
|
|
362
|
+
for (const i of [0, 1, 2, 3, 4, 9, 10, 11, 12, 13]) {
|
|
363
363
|
if (i !== 13) {
|
|
364
|
-
index_o += o[i] *
|
|
364
|
+
index_o += o[i] * 3 ** j;
|
|
365
365
|
}
|
|
366
366
|
perm[j] = p[i] < 5 ? p[i] : p[i] - 4;
|
|
367
367
|
j++;
|
|
@@ -373,13 +373,13 @@ function solve_phase4_fast(state) {
|
|
|
373
373
|
}
|
|
374
374
|
function solve(state) {
|
|
375
375
|
let sol = [];
|
|
376
|
-
for (
|
|
376
|
+
for (const solver of [
|
|
377
377
|
solve_phase1,
|
|
378
378
|
solve_phase2,
|
|
379
379
|
solve_phase3,
|
|
380
380
|
solve_phase4_fast
|
|
381
381
|
]) {
|
|
382
|
-
|
|
382
|
+
const phase_sol = solver(state);
|
|
383
383
|
state = apply_move_sequence(state, phase_sol);
|
|
384
384
|
sol = sol.concat(phase_sol);
|
|
385
385
|
}
|
|
@@ -392,18 +392,18 @@ function generate_phase23_orientation_mtable() {
|
|
|
392
392
|
}
|
|
393
393
|
const C15_5 = C(15, 5);
|
|
394
394
|
const THREE = [1, 3, 9, 27, 81, 243];
|
|
395
|
-
|
|
395
|
+
const phase23om = Array(C(15, 5) * THREE[5]);
|
|
396
396
|
tables.phase23om = phase23om;
|
|
397
397
|
for (let i = 0; i < C15_5; i++) {
|
|
398
|
-
|
|
399
|
-
|
|
398
|
+
const comb = index_to_comb(i, 5, 15).concat(Array(5).fill(0));
|
|
399
|
+
const new_comb_indices = [];
|
|
400
400
|
for (let move_index = 0; move_index < 6; move_index++) {
|
|
401
|
-
|
|
401
|
+
const new_comb = compose(comb, moves[move_index][0]).slice(0, 15);
|
|
402
402
|
new_comb_indices[move_index] = comb_to_index(new_comb);
|
|
403
403
|
}
|
|
404
404
|
for (let j = 0; j < THREE[5]; j++) {
|
|
405
405
|
phase23om[j + 243 * i] = [];
|
|
406
|
-
|
|
406
|
+
const orient_full = [];
|
|
407
407
|
for (let k = 0, l = 0; k < 20; k++) {
|
|
408
408
|
if (comb[k] === 1) {
|
|
409
409
|
orient_full[k] = (j / THREE[l] | 0) % 3;
|
|
@@ -413,12 +413,12 @@ function generate_phase23_orientation_mtable() {
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
for (let move_index = 0; move_index < 6; move_index++) {
|
|
416
|
-
|
|
417
|
-
|
|
416
|
+
const move = moves[move_index];
|
|
417
|
+
const new_orient_full = [];
|
|
418
418
|
for (let k = 0; k < 15; k++) {
|
|
419
419
|
new_orient_full[k] = orient_full[move[0][k]] + move[1][k];
|
|
420
420
|
}
|
|
421
|
-
|
|
421
|
+
const new_orient = new_orient_full.filter((x) => x < 10);
|
|
422
422
|
let J = 0;
|
|
423
423
|
for (let k = 0; k < 5; k++) {
|
|
424
424
|
J += new_orient[k] % 3 * THREE[k];
|
|
@@ -433,37 +433,30 @@ function generate_phase2_orientation_ptable() {
|
|
|
433
433
|
if (tables.phase2op) {
|
|
434
434
|
return tables.phase2op;
|
|
435
435
|
}
|
|
436
|
-
|
|
436
|
+
const mtable = generate_phase23_orientation_mtable();
|
|
437
437
|
return tables.phase2op = bfs(mtable, [243 * 3002]);
|
|
438
438
|
}
|
|
439
439
|
function generate_phase3_orientation_ptable() {
|
|
440
440
|
if (tables.phase3op) {
|
|
441
441
|
return tables.phase3op;
|
|
442
442
|
}
|
|
443
|
-
|
|
443
|
+
const mtable = generate_phase23_orientation_mtable();
|
|
444
444
|
return tables.phase3op = bfs(mtable, [243 * 246]);
|
|
445
445
|
}
|
|
446
446
|
function generate_phase23_permutation_mtable() {
|
|
447
447
|
if (tables.phase23pm) {
|
|
448
448
|
return tables.phase23pm;
|
|
449
449
|
}
|
|
450
|
-
const FIFTEEN = [
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
225,
|
|
454
|
-
Math.pow(15, 3),
|
|
455
|
-
Math.pow(15, 4),
|
|
456
|
-
Math.pow(15, 5)
|
|
457
|
-
];
|
|
458
|
-
let phase23pm = Array(FIFTEEN[5]);
|
|
459
|
-
let single = Array(15);
|
|
450
|
+
const FIFTEEN = [1, 15, 225, 15 ** 3, 15 ** 4, 15 ** 5];
|
|
451
|
+
const phase23pm = Array(FIFTEEN[5]);
|
|
452
|
+
const single = Array(15);
|
|
460
453
|
for (let i = 0; i < 15; i++) {
|
|
461
454
|
single[i] = Array(6);
|
|
462
455
|
for (let move_index = 0; move_index < 6; move_index++) {
|
|
463
456
|
single[i][move_index] = moves[move_index][0].indexOf(i);
|
|
464
457
|
}
|
|
465
458
|
}
|
|
466
|
-
|
|
459
|
+
const locations = [0, 0, 0, 0, 0];
|
|
467
460
|
for (let ind = 0; ind < FIFTEEN[5]; ind++) {
|
|
468
461
|
phase23pm[ind] = Array(6);
|
|
469
462
|
for (let move_index = 0; move_index < 6; move_index++) {
|
|
@@ -487,14 +480,14 @@ function generate_phase2_permutation_ptable() {
|
|
|
487
480
|
if (tables.phase2pp) {
|
|
488
481
|
return tables.phase2pp;
|
|
489
482
|
}
|
|
490
|
-
|
|
483
|
+
const mtable = generate_phase23_permutation_mtable();
|
|
491
484
|
return tables.phase2pp = bfs(mtable, [213090]);
|
|
492
485
|
}
|
|
493
486
|
function generate_phase3_permutation_ptable() {
|
|
494
487
|
if (tables.phase3pp) {
|
|
495
488
|
return tables.phase3pp;
|
|
496
489
|
}
|
|
497
|
-
|
|
490
|
+
const mtable = generate_phase23_permutation_mtable();
|
|
498
491
|
return tables.phase3pp = bfs(mtable, [737420]);
|
|
499
492
|
}
|
|
500
493
|
function generate_phase4_orientation_mtable() {
|
|
@@ -502,19 +495,19 @@ function generate_phase4_orientation_mtable() {
|
|
|
502
495
|
return tables.phase4om;
|
|
503
496
|
}
|
|
504
497
|
const THREE = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049];
|
|
505
|
-
|
|
498
|
+
const mtable = Array(THREE[9]);
|
|
506
499
|
for (let i = 0; i < THREE[9]; i++) {
|
|
507
|
-
|
|
500
|
+
const o = Array(14).fill(0);
|
|
508
501
|
for (let j = 0; j < 9; j++) {
|
|
509
|
-
|
|
502
|
+
const J = j < 5 ? j : j + 4;
|
|
510
503
|
o[J] = (i / THREE[j] | 0) % 3;
|
|
511
504
|
o[13] -= o[J];
|
|
512
505
|
}
|
|
513
506
|
o[13] = (o[13] + 999) % 3;
|
|
514
507
|
mtable[i] = [];
|
|
515
508
|
for (let move_index = 0; move_index < 3; move_index++) {
|
|
516
|
-
|
|
517
|
-
|
|
509
|
+
const move = moves[move_index];
|
|
510
|
+
const new_o = [0, 1, 2, 3, 4, 9, 10, 11, 12, 13].map(
|
|
518
511
|
(i2) => o[move[0][i2]] + move[1][i2]
|
|
519
512
|
);
|
|
520
513
|
let new_i = 0;
|
|
@@ -532,20 +525,20 @@ function generate_phase4_permutation_mtable() {
|
|
|
532
525
|
}
|
|
533
526
|
const HALFFACT10 = factorial(10) / 2;
|
|
534
527
|
const n = 10;
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
528
|
+
const pre = [0, 1, 2, 3, 4, -1, -1, -1, -1, 5, 6, 7, 8, 9];
|
|
529
|
+
const post = [0, 1, 2, 3, 4, 9, 10, 11, 12, 13];
|
|
530
|
+
const move_permutations = [
|
|
538
531
|
compose(pre, compose(move_U[0], post)),
|
|
539
532
|
compose(pre, compose(move_R[0], post)),
|
|
540
533
|
compose(pre, compose(move_F[0], post))
|
|
541
534
|
];
|
|
542
|
-
|
|
543
|
-
|
|
535
|
+
const mtable = Array(HALFFACT10);
|
|
536
|
+
const perm = Array(10);
|
|
544
537
|
for (let i = 0; i < HALFFACT10; i++) {
|
|
545
538
|
index_to_evenpermutation10(i, perm);
|
|
546
539
|
mtable[i] = [];
|
|
547
540
|
for (let move_index = 0; move_index < 3; move_index++) {
|
|
548
|
-
|
|
541
|
+
const new_perm = compose(perm, move_permutations[move_index]);
|
|
549
542
|
mtable[i][move_index] = evenpermutation10_to_index(new_perm);
|
|
550
543
|
}
|
|
551
544
|
}
|
|
@@ -555,33 +548,33 @@ function generate_phase4_orientation_ptable() {
|
|
|
555
548
|
if (tables.phase4op) {
|
|
556
549
|
return tables.phase4op;
|
|
557
550
|
}
|
|
558
|
-
|
|
551
|
+
const mtable = generate_phase4_orientation_mtable();
|
|
559
552
|
return tables.phase4op = bfs(mtable, [0]);
|
|
560
553
|
}
|
|
561
554
|
function generate_phase4_permutation_ptable() {
|
|
562
555
|
if (tables.phase4pp) {
|
|
563
556
|
return tables.phase4pp;
|
|
564
557
|
}
|
|
565
|
-
|
|
558
|
+
const mtable = generate_phase4_permutation_mtable();
|
|
566
559
|
return tables.phase4pp = bfs(mtable, [0]);
|
|
567
560
|
}
|
|
568
561
|
function generate_phase4_near_ptable_list(threshold) {
|
|
569
562
|
if (tables.phase4np_list && tables.phase4np_list.threshold === threshold) {
|
|
570
563
|
return tables.phase4np_list;
|
|
571
564
|
}
|
|
572
|
-
|
|
565
|
+
const mtables = [
|
|
573
566
|
generate_phase4_orientation_mtable(),
|
|
574
567
|
generate_phase4_permutation_mtable()
|
|
575
568
|
];
|
|
576
|
-
|
|
577
|
-
|
|
569
|
+
const base = 3 ** 9;
|
|
570
|
+
const states = [0];
|
|
578
571
|
populate(threshold, [0, 0], -1);
|
|
579
572
|
function populate(depth, state, last2) {
|
|
580
573
|
states.push(state[0] + base * state[1]);
|
|
581
574
|
if (depth === 0) {
|
|
582
575
|
return;
|
|
583
576
|
}
|
|
584
|
-
|
|
577
|
+
const new_state = [];
|
|
585
578
|
for (let move_index = 0; move_index < 3; move_index++) {
|
|
586
579
|
if (move_index === last2) {
|
|
587
580
|
continue;
|
|
@@ -597,9 +590,9 @@ function generate_phase4_near_ptable_list(threshold) {
|
|
|
597
590
|
return;
|
|
598
591
|
}
|
|
599
592
|
states.sort((x, y) => x - y);
|
|
600
|
-
|
|
593
|
+
const unique_states = [];
|
|
601
594
|
let last = -1;
|
|
602
|
-
for (
|
|
595
|
+
for (const state of states) {
|
|
603
596
|
if (state !== last) {
|
|
604
597
|
unique_states.push(last = state);
|
|
605
598
|
}
|
|
@@ -611,7 +604,7 @@ function binary_search(A, x) {
|
|
|
611
604
|
let lo = 0;
|
|
612
605
|
let hi = A.length - 1;
|
|
613
606
|
while (hi - lo > 1) {
|
|
614
|
-
|
|
607
|
+
const mid = lo + hi >> 1;
|
|
615
608
|
if (x > A[mid]) {
|
|
616
609
|
lo = mid + 1;
|
|
617
610
|
} else {
|
|
@@ -621,10 +614,10 @@ function binary_search(A, x) {
|
|
|
621
614
|
return x === A[lo] || x === A[hi];
|
|
622
615
|
}
|
|
623
616
|
function bfs(mtable, goal_states) {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
for (
|
|
617
|
+
const N = mtable.length;
|
|
618
|
+
const nmoves = mtable[0].length;
|
|
619
|
+
const ptable = Array(N).fill(-1);
|
|
620
|
+
for (const state of goal_states) {
|
|
628
621
|
ptable[state] = 0;
|
|
629
622
|
}
|
|
630
623
|
let depth = 0;
|
|
@@ -651,13 +644,13 @@ function bfs(mtable, goal_states) {
|
|
|
651
644
|
return ptable;
|
|
652
645
|
}
|
|
653
646
|
function ida_solve(indices, mtables, ptables) {
|
|
654
|
-
|
|
647
|
+
const ncoords = indices.length;
|
|
655
648
|
let bound = 0;
|
|
656
649
|
for (let i = 0; i < ncoords; i++) {
|
|
657
650
|
bound = Math.max(bound, ptables[i][indices[i]]);
|
|
658
651
|
}
|
|
659
652
|
while (true) {
|
|
660
|
-
|
|
653
|
+
const path = ida_search(indices, mtables, ptables, bound, -1);
|
|
661
654
|
if (path !== void 0) {
|
|
662
655
|
return path;
|
|
663
656
|
}
|
|
@@ -665,8 +658,8 @@ function ida_solve(indices, mtables, ptables) {
|
|
|
665
658
|
}
|
|
666
659
|
}
|
|
667
660
|
function ida_search(indices, mtables, ptables, bound, last) {
|
|
668
|
-
|
|
669
|
-
|
|
661
|
+
const ncoords = indices.length;
|
|
662
|
+
const nmoves = mtables[0][0].length;
|
|
670
663
|
let heuristic = 0;
|
|
671
664
|
for (let i = 0; i < ncoords; i++) {
|
|
672
665
|
heuristic = Math.max(heuristic, ptables[i][indices[i]]);
|
|
@@ -681,13 +674,13 @@ function ida_search(indices, mtables, ptables, bound, last) {
|
|
|
681
674
|
if (m === last) {
|
|
682
675
|
continue;
|
|
683
676
|
}
|
|
684
|
-
|
|
677
|
+
const new_indices = indices.slice();
|
|
685
678
|
for (let c = 0; c < ncoords; c++) {
|
|
686
679
|
new_indices[c] = mtables[c][indices[c]][m];
|
|
687
680
|
}
|
|
688
681
|
let r = 1;
|
|
689
682
|
while (indices.some((_, i) => indices[i] !== new_indices[i])) {
|
|
690
|
-
|
|
683
|
+
const subpath = ida_search(new_indices, mtables, ptables, bound - 1, m);
|
|
691
684
|
if (subpath !== void 0) {
|
|
692
685
|
return [[m, r]].concat(subpath);
|
|
693
686
|
}
|
|
@@ -700,14 +693,14 @@ function ida_search(indices, mtables, ptables, bound, last) {
|
|
|
700
693
|
return;
|
|
701
694
|
}
|
|
702
695
|
function phase4_ida_solve(indices) {
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
696
|
+
const mtable_o = generate_phase4_orientation_mtable();
|
|
697
|
+
const mtable_p = generate_phase4_permutation_mtable();
|
|
698
|
+
const ptable_o = generate_phase4_orientation_ptable();
|
|
699
|
+
const ptable_p = generate_phase4_permutation_ptable();
|
|
700
|
+
const ptable_n = generate_phase4_near_ptable_list(PHASE4_THRESHOLD);
|
|
708
701
|
let bound = Math.max(ptable_o[indices[0]], ptable_p[indices[1]]);
|
|
709
702
|
while (true) {
|
|
710
|
-
|
|
703
|
+
const path = phase4_ida_search(
|
|
711
704
|
indices,
|
|
712
705
|
bound,
|
|
713
706
|
-1,
|
|
@@ -741,11 +734,11 @@ function phase4_ida_search(indices, bound, last, mtable_o, mtable_p, ptable_o, p
|
|
|
741
734
|
if (m === last) {
|
|
742
735
|
continue;
|
|
743
736
|
}
|
|
744
|
-
|
|
737
|
+
const new_indices = indices.slice();
|
|
745
738
|
for (let r = 1; r < 5; r++) {
|
|
746
739
|
new_indices[0] = mtable_o[new_indices[0]][m];
|
|
747
740
|
new_indices[1] = mtable_p[new_indices[1]][m];
|
|
748
|
-
|
|
741
|
+
const subpath = phase4_ida_search(
|
|
749
742
|
new_indices,
|
|
750
743
|
bound - 1,
|
|
751
744
|
m,
|
|
@@ -768,4 +761,3 @@ function getRandomKilominxScramble() {
|
|
|
768
761
|
export {
|
|
769
762
|
getRandomKilominxScramble
|
|
770
763
|
};
|
|
771
|
-
//# sourceMappingURL=search-dynamic-solve-kilominx-KKUOVW5Y.js.map
|