cube-state-engine 1.4.0 → 1.6.0
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/.claude/settings.local.json +9 -0
- package/.idea/AICommit.xml +6 -0
- package/.idea/awsToolkit.xml +11 -0
- package/.idea/cube-state-engine.iml +8 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/dist/index.d.mts +1388 -656
- package/dist/index.d.ts +1388 -656
- package/dist/index.js +961 -462
- package/dist/index.mjs +954 -461
- package/package.json +2 -2
- package/.idea/workspace.xml +0 -304
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -20,6 +22,7 @@ var __spreadValues = (a, b) => {
|
|
|
20
22
|
}
|
|
21
23
|
return a;
|
|
22
24
|
};
|
|
25
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
26
|
var __export = (target, all) => {
|
|
24
27
|
for (var name in all)
|
|
25
28
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -35,24 +38,864 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
35
38
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
39
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
37
40
|
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
41
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
38
42
|
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
43
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
39
44
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
40
45
|
|
|
41
46
|
// src/index.js
|
|
42
47
|
var src_exports = {};
|
|
43
48
|
__export(src_exports, {
|
|
44
49
|
COLOR: () => COLOR,
|
|
45
|
-
CubeEngine: () => CubeEngine
|
|
50
|
+
CubeEngine: () => CubeEngine,
|
|
51
|
+
analyzeSolution: () => analyzeSolution,
|
|
52
|
+
getMovePermutations: () => getMovePermutations,
|
|
53
|
+
invertSequence: () => invertSequence,
|
|
54
|
+
simplifyMoves: () => simplifyMoves
|
|
46
55
|
});
|
|
47
56
|
module.exports = __toCommonJS(src_exports);
|
|
48
|
-
|
|
57
|
+
|
|
58
|
+
// src/simplify.js
|
|
59
|
+
function canMerge(a, b) {
|
|
60
|
+
return typeof a === "string" && a === b && !a.includes("2");
|
|
61
|
+
}
|
|
62
|
+
function doubled(tok) {
|
|
63
|
+
return tok.replace("'", "") + "2";
|
|
64
|
+
}
|
|
65
|
+
function simplifyTokens(tokens) {
|
|
66
|
+
const out = [];
|
|
67
|
+
for (let i = 0; i < tokens.length; ) {
|
|
68
|
+
const a = tokens[i];
|
|
69
|
+
const b = tokens[i + 1];
|
|
70
|
+
if (i + 1 < tokens.length && canMerge(a, b)) {
|
|
71
|
+
out.push(doubled(a));
|
|
72
|
+
i += 2;
|
|
73
|
+
} else {
|
|
74
|
+
out.push(a);
|
|
75
|
+
i += 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
79
|
+
}
|
|
80
|
+
function simplifyTimed(moves) {
|
|
81
|
+
const out = [];
|
|
82
|
+
for (let i = 0; i < moves.length; ) {
|
|
83
|
+
const a = moves[i];
|
|
84
|
+
const b = moves[i + 1];
|
|
85
|
+
if (i + 1 < moves.length && canMerge(a == null ? void 0 : a.m, b == null ? void 0 : b.m)) {
|
|
86
|
+
out.push({ m: doubled(a.m), t: b.t });
|
|
87
|
+
i += 2;
|
|
88
|
+
} else {
|
|
89
|
+
out.push(a);
|
|
90
|
+
i += 1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
function simplifyMoves(moves) {
|
|
96
|
+
if (typeof moves === "string") {
|
|
97
|
+
const tokens = moves.split(/\s+/).filter((t) => t.length > 0);
|
|
98
|
+
return simplifyTokens(tokens).join(" ");
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(moves)) {
|
|
101
|
+
if (moves.length === 0) return [];
|
|
102
|
+
if (typeof moves[0] === "string") return simplifyTokens(moves);
|
|
103
|
+
return simplifyTimed(moves);
|
|
104
|
+
}
|
|
105
|
+
return moves;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// src/analyzer.js
|
|
109
|
+
var FACE_NAMES = ["UPPER", "LEFT", "FRONT", "RIGHT", "BACK", "DOWN"];
|
|
110
|
+
var FACE_MOVE_TO_INDEX = { U: 0, L: 1, F: 2, R: 3, B: 4, D: 5 };
|
|
111
|
+
var SUPPORTED_BASES = /* @__PURE__ */ new Set([
|
|
112
|
+
"U",
|
|
113
|
+
"D",
|
|
114
|
+
"L",
|
|
115
|
+
"R",
|
|
116
|
+
"F",
|
|
117
|
+
"B",
|
|
118
|
+
"x",
|
|
119
|
+
"y",
|
|
120
|
+
"z",
|
|
121
|
+
"M",
|
|
122
|
+
"E",
|
|
123
|
+
"S",
|
|
124
|
+
"Uw",
|
|
125
|
+
"Dw",
|
|
126
|
+
"Rw",
|
|
127
|
+
"Lw",
|
|
128
|
+
"Fw"
|
|
129
|
+
]);
|
|
130
|
+
var WIDE_LOWER = { r: "Rw", u: "Uw", f: "Fw", l: "Lw", d: "Dw", b: "Bw" };
|
|
131
|
+
function normalizeToken(raw) {
|
|
132
|
+
const m = String(raw).trim().match(/^([A-Za-z]w?)('?2?|2?'?)$/);
|
|
133
|
+
if (!m) return { token: raw, base: null };
|
|
134
|
+
let base = m[1];
|
|
135
|
+
if (base.length === 1 && WIDE_LOWER[base]) base = WIDE_LOWER[base];
|
|
136
|
+
return { token: base + m[2], base };
|
|
137
|
+
}
|
|
138
|
+
var GEOMETRY_CACHE = /* @__PURE__ */ new Map();
|
|
139
|
+
function buildGeometry(size) {
|
|
140
|
+
if (GEOMETRY_CACHE.has(size)) return GEOMETRY_CACHE.get(size);
|
|
141
|
+
const perms = getMovePermutations(size);
|
|
142
|
+
const per = size * size;
|
|
143
|
+
const total = per * 6;
|
|
144
|
+
const faceMoves = Object.keys(FACE_MOVE_TO_INDEX);
|
|
145
|
+
const edgeMap = /* @__PURE__ */ new Map();
|
|
146
|
+
const cornerMap = /* @__PURE__ */ new Map();
|
|
147
|
+
for (let i = 0; i < total; i++) {
|
|
148
|
+
const faces = [];
|
|
149
|
+
for (const mv of faceMoves) {
|
|
150
|
+
if (perms[mv].cw[i] !== i) faces.push(FACE_MOVE_TO_INDEX[mv]);
|
|
151
|
+
}
|
|
152
|
+
faces.sort((a, b) => a - b);
|
|
153
|
+
const key = faces.join(",");
|
|
154
|
+
if (faces.length === 2) {
|
|
155
|
+
if (!edgeMap.has(key)) edgeMap.set(key, []);
|
|
156
|
+
edgeMap.get(key).push(i);
|
|
157
|
+
} else if (faces.length === 3) {
|
|
158
|
+
if (!cornerMap.has(key)) cornerMap.set(key, []);
|
|
159
|
+
cornerMap.get(key).push(i);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
const edges = [...edgeMap.entries()].map(([key, indices]) => ({
|
|
163
|
+
faces: key.split(",").map(Number),
|
|
164
|
+
indices
|
|
165
|
+
}));
|
|
166
|
+
const corners = [...cornerMap.entries()].map(([key, indices]) => ({
|
|
167
|
+
faces: key.split(",").map(Number),
|
|
168
|
+
indices
|
|
169
|
+
}));
|
|
170
|
+
const neighbors = Array.from({ length: 6 }, () => /* @__PURE__ */ new Set());
|
|
171
|
+
for (const e of edges) {
|
|
172
|
+
const [a, b] = e.faces;
|
|
173
|
+
neighbors[a].add(b);
|
|
174
|
+
neighbors[b].add(a);
|
|
175
|
+
}
|
|
176
|
+
const opposite = new Array(6).fill(-1);
|
|
177
|
+
for (let f = 0; f < 6; f++) {
|
|
178
|
+
for (let g = 0; g < 6; g++) {
|
|
179
|
+
if (g !== f && !neighbors[f].has(g)) {
|
|
180
|
+
opposite[f] = g;
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const geo = {
|
|
186
|
+
size,
|
|
187
|
+
per,
|
|
188
|
+
centerIndex: (f) => f * per + Math.floor(per / 2),
|
|
189
|
+
edges,
|
|
190
|
+
corners,
|
|
191
|
+
neighbors,
|
|
192
|
+
opposite,
|
|
193
|
+
edgesByFace: (f) => edges.filter((e) => e.faces.includes(f)),
|
|
194
|
+
cornersByFace: (f) => corners.filter((c) => c.faces.includes(f)),
|
|
195
|
+
edgeByPair: (a, b) => edges.find(
|
|
196
|
+
(e) => e.faces[0] === a && e.faces[1] === b || e.faces[0] === b && e.faces[1] === a
|
|
197
|
+
)
|
|
198
|
+
};
|
|
199
|
+
GEOMETRY_CACHE.set(size, geo);
|
|
200
|
+
return geo;
|
|
201
|
+
}
|
|
202
|
+
function invertToken(tok) {
|
|
203
|
+
if (tok.endsWith("2")) return tok;
|
|
204
|
+
if (tok.endsWith("'")) return tok.slice(0, -1);
|
|
205
|
+
return tok + "'";
|
|
206
|
+
}
|
|
207
|
+
function invertSequence(tokens) {
|
|
208
|
+
return tokens.slice().reverse().map(invertToken);
|
|
209
|
+
}
|
|
210
|
+
function flattenState(state) {
|
|
211
|
+
const out = [];
|
|
212
|
+
for (const name of FACE_NAMES) {
|
|
213
|
+
const matrix = state[name];
|
|
214
|
+
for (const row of matrix) {
|
|
215
|
+
for (const v of row) out.push(v);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
function centersOf(st, geo) {
|
|
221
|
+
const centers = new Array(6);
|
|
222
|
+
for (let f = 0; f < 6; f++) centers[f] = st[geo.centerIndex(f)];
|
|
223
|
+
return centers;
|
|
224
|
+
}
|
|
225
|
+
function slotCorrect(st, centers, indices, per) {
|
|
226
|
+
for (const x of indices) {
|
|
227
|
+
if (st[x] !== centers[Math.floor(x / per)]) return false;
|
|
228
|
+
}
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
function isSolvedFlat(st, per) {
|
|
232
|
+
for (let f = 0; f < 6; f++) {
|
|
233
|
+
const base = f * per;
|
|
234
|
+
const c = st[base];
|
|
235
|
+
for (let i = 1; i < per; i++) if (st[base + i] !== c) return false;
|
|
236
|
+
}
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
function crossDone(st, geo, color) {
|
|
240
|
+
const centers = centersOf(st, geo);
|
|
241
|
+
const C = centers.indexOf(color);
|
|
242
|
+
if (C < 0) return false;
|
|
243
|
+
return geo.edgesByFace(C).every((e) => slotCorrect(st, centers, e.indices, geo.per));
|
|
244
|
+
}
|
|
245
|
+
function f2lSlotStates(st, geo, color) {
|
|
246
|
+
const centers = centersOf(st, geo);
|
|
247
|
+
const C = centers.indexOf(color);
|
|
248
|
+
const result = {};
|
|
249
|
+
if (C < 0) return result;
|
|
250
|
+
for (const corner of geo.cornersByFace(C)) {
|
|
251
|
+
const sides = corner.faces.filter((f) => f !== C);
|
|
252
|
+
if (sides.length !== 2) continue;
|
|
253
|
+
const [a, b] = sides;
|
|
254
|
+
const edge = geo.edgeByPair(a, b);
|
|
255
|
+
const cornerOk = slotCorrect(st, centers, corner.indices, geo.per);
|
|
256
|
+
const edgeOk = edge ? slotCorrect(st, centers, edge.indices, geo.per) : false;
|
|
257
|
+
const key = [centers[a], centers[b]].sort().join("-");
|
|
258
|
+
result[key] = cornerOk && edgeOk;
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
function ollDone(st, geo, color) {
|
|
263
|
+
const centers = centersOf(st, geo);
|
|
264
|
+
const C = centers.indexOf(color);
|
|
265
|
+
if (C < 0) return false;
|
|
266
|
+
const O = geo.opposite[C];
|
|
267
|
+
const base = O * geo.per;
|
|
268
|
+
for (let i = 0; i < geo.per; i++) {
|
|
269
|
+
if (st[base + i] !== centers[O]) return false;
|
|
270
|
+
}
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
function rouxBlockPieces(geo, sideFace, upFace) {
|
|
274
|
+
const downFace = geo.opposite[upFace];
|
|
275
|
+
const edges = geo.edgesByFace(sideFace).filter((e) => !e.faces.includes(upFace));
|
|
276
|
+
const corners = geo.cornersByFace(sideFace).filter((c) => c.faces.includes(downFace));
|
|
277
|
+
return { edges, corners };
|
|
278
|
+
}
|
|
279
|
+
function rouxBlockDone(st, centers, geo, sideFace, upFace) {
|
|
280
|
+
const { edges, corners } = rouxBlockPieces(geo, sideFace, upFace);
|
|
281
|
+
if (edges.length !== 3 || corners.length !== 2) return false;
|
|
282
|
+
for (const e of edges)
|
|
283
|
+
if (!slotCorrect(st, centers, e.indices, geo.per)) return false;
|
|
284
|
+
for (const c of corners)
|
|
285
|
+
if (!slotCorrect(st, centers, c.indices, geo.per)) return false;
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
function applyPerm(st, perm) {
|
|
289
|
+
const out = new Array(st.length);
|
|
290
|
+
for (let i = 0; i < st.length; i++) out[i] = st[perm[i]];
|
|
291
|
+
return out;
|
|
292
|
+
}
|
|
293
|
+
function cmllDone(st, geo, upFace, mPerm) {
|
|
294
|
+
let cur = st;
|
|
295
|
+
const corners = geo.cornersByFace(upFace);
|
|
296
|
+
for (let m = 0; m < 4; m++) {
|
|
297
|
+
if (m > 0) cur = applyPerm(cur, mPerm);
|
|
298
|
+
const centers = centersOf(cur, geo);
|
|
299
|
+
if (corners.every((c) => slotCorrect(cur, centers, c.indices, geo.per)))
|
|
300
|
+
return true;
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
function completionIndex(bools) {
|
|
305
|
+
const n = bools.length;
|
|
306
|
+
if (n === 0 || !bools[n - 1]) return null;
|
|
307
|
+
for (let i = 0; i < n; i++) if (bools[i]) return i;
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
function buildForCross(snapshots, geo, color) {
|
|
311
|
+
const n = snapshots.length;
|
|
312
|
+
const crossBools = snapshots.map((st) => crossDone(st, geo, color));
|
|
313
|
+
const crossIdx = completionIndex(crossBools);
|
|
314
|
+
const slotSeries = /* @__PURE__ */ new Map();
|
|
315
|
+
for (let i = 0; i < n; i++) {
|
|
316
|
+
const states = f2lSlotStates(snapshots[i], geo, color);
|
|
317
|
+
for (const [key, val] of Object.entries(states)) {
|
|
318
|
+
if (!slotSeries.has(key)) slotSeries.set(key, new Array(n).fill(false));
|
|
319
|
+
slotSeries.get(key)[i] = crossBools[i] && val;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const f2lSlots = [...slotSeries.entries()].map(([slot, bools]) => ({ slot, idx: completionIndex(bools) })).filter((s) => s.idx != null).sort((a, b) => a.idx - b.idx);
|
|
323
|
+
const f2lComplete = new Array(n).fill(false);
|
|
324
|
+
for (let i = 0; i < n; i++) {
|
|
325
|
+
if (!crossBools[i] || slotSeries.size < 4) continue;
|
|
326
|
+
let all = true;
|
|
327
|
+
for (const bools of slotSeries.values()) {
|
|
328
|
+
if (!bools[i]) {
|
|
329
|
+
all = false;
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
f2lComplete[i] = all;
|
|
334
|
+
}
|
|
335
|
+
const ollIdx = completionIndex(
|
|
336
|
+
snapshots.map((st, i) => f2lComplete[i] && ollDone(st, geo, color))
|
|
337
|
+
);
|
|
338
|
+
const pllIdx = completionIndex(snapshots.map((st) => isSolvedFlat(st, geo.per)));
|
|
339
|
+
return { crossIdx, f2lSlots, ollIdx, pllIdx };
|
|
340
|
+
}
|
|
341
|
+
function isCFOP(build) {
|
|
342
|
+
const { crossIdx, f2lSlots, ollIdx, pllIdx } = build;
|
|
343
|
+
if (crossIdx == null || pllIdx == null || ollIdx == null) return false;
|
|
344
|
+
if (f2lSlots.length !== 4) return false;
|
|
345
|
+
if (!f2lSlots.every((s) => s.idx >= crossIdx)) return false;
|
|
346
|
+
const lastF2L = f2lSlots[3].idx;
|
|
347
|
+
return ollIdx >= lastF2L && pllIdx >= ollIdx;
|
|
348
|
+
}
|
|
349
|
+
function buildForRoux(snapshots, geo, sideA, upFace, mPerm) {
|
|
350
|
+
const n = snapshots.length;
|
|
351
|
+
const sideB = geo.opposite[sideA];
|
|
352
|
+
const centersAt = snapshots.map((st) => centersOf(st, geo));
|
|
353
|
+
const aDone = snapshots.map(
|
|
354
|
+
(st, i) => rouxBlockDone(st, centersAt[i], geo, sideA, upFace)
|
|
355
|
+
);
|
|
356
|
+
const bDone = snapshots.map(
|
|
357
|
+
(st, i) => rouxBlockDone(st, centersAt[i], geo, sideB, upFace)
|
|
358
|
+
);
|
|
359
|
+
const aIdx = completionIndex(aDone);
|
|
360
|
+
const bIdx = completionIndex(bDone);
|
|
361
|
+
let firstSide = sideA;
|
|
362
|
+
let secondSide = sideB;
|
|
363
|
+
let fbBools = aDone;
|
|
364
|
+
let sbBools = bDone;
|
|
365
|
+
if ((bIdx != null ? bIdx : Infinity) < (aIdx != null ? aIdx : Infinity)) {
|
|
366
|
+
firstSide = sideB;
|
|
367
|
+
secondSide = sideA;
|
|
368
|
+
fbBools = bDone;
|
|
369
|
+
sbBools = aDone;
|
|
370
|
+
}
|
|
371
|
+
const fbIdx = completionIndex(fbBools);
|
|
372
|
+
const secondBlockBools = snapshots.map((_, i) => fbBools[i] && sbBools[i]);
|
|
373
|
+
const sbIdx = completionIndex(secondBlockBools);
|
|
374
|
+
const cmllIdx = completionIndex(
|
|
375
|
+
snapshots.map(
|
|
376
|
+
(st, i) => secondBlockBools[i] && cmllDone(st, geo, upFace, mPerm)
|
|
377
|
+
)
|
|
378
|
+
);
|
|
379
|
+
const lseIdx = completionIndex(snapshots.map((st) => isSolvedFlat(st, geo.per)));
|
|
380
|
+
return { firstSide, secondSide, upFace, fbIdx, sbIdx, cmllIdx, lseIdx };
|
|
381
|
+
}
|
|
382
|
+
function isRoux(build) {
|
|
383
|
+
const { fbIdx, sbIdx, cmllIdx, lseIdx } = build;
|
|
384
|
+
if (fbIdx == null || sbIdx == null || cmllIdx == null || lseIdx == null)
|
|
385
|
+
return false;
|
|
386
|
+
return fbIdx <= sbIdx && sbIdx <= cmllIdx && cmllIdx <= lseIdx;
|
|
387
|
+
}
|
|
388
|
+
function analyzeSolution(moves, options = {}) {
|
|
389
|
+
var _a, _b;
|
|
390
|
+
const size = options.size === 2 ? 2 : 3;
|
|
391
|
+
const unsupported = [];
|
|
392
|
+
const seq = (Array.isArray(moves) ? moves : []).map((x) => {
|
|
393
|
+
var _a2;
|
|
394
|
+
const m = String((_a2 = x == null ? void 0 : x.m) != null ? _a2 : "").trim();
|
|
395
|
+
const { token, base: base2 } = normalizeToken(m);
|
|
396
|
+
const supported = base2 != null && SUPPORTED_BASES.has(base2);
|
|
397
|
+
if (m.length > 0 && !supported) unsupported.push(m);
|
|
398
|
+
return { m, mm: supported ? token : "", t: Number(x == null ? void 0 : x.t) };
|
|
399
|
+
}).filter((x) => x.m.length > 0);
|
|
400
|
+
const n = seq.length;
|
|
401
|
+
const simplifiedMoves = simplifyMoves(
|
|
402
|
+
(Array.isArray(moves) ? moves : []).filter((x) => x == null ? void 0 : x.m)
|
|
403
|
+
);
|
|
404
|
+
const simplifiedCount = simplifiedMoves.length;
|
|
405
|
+
const empty = {
|
|
406
|
+
size,
|
|
407
|
+
method: "unknown",
|
|
408
|
+
solved: false,
|
|
409
|
+
total: n > 0 ? seq[n - 1].t : 0,
|
|
410
|
+
tps: 0,
|
|
411
|
+
moves: simplifiedMoves,
|
|
412
|
+
cross: null,
|
|
413
|
+
f2l: [],
|
|
414
|
+
oll: null,
|
|
415
|
+
pll: null,
|
|
416
|
+
firstBlock: null,
|
|
417
|
+
secondBlock: null,
|
|
418
|
+
cmll: null,
|
|
419
|
+
lse: null,
|
|
420
|
+
allCrosses: {},
|
|
421
|
+
unsupported
|
|
422
|
+
};
|
|
423
|
+
if (n === 0) return empty;
|
|
424
|
+
const engine = new CubeEngine("", { size });
|
|
425
|
+
const scramble = invertSequence(seq.map((x) => x.mm).filter(Boolean)).join(" ");
|
|
426
|
+
engine.applyMoves(scramble, { record: false });
|
|
427
|
+
const geo = buildGeometry(size);
|
|
428
|
+
const snapshots = new Array(n);
|
|
429
|
+
for (let i = 0; i < n; i++) {
|
|
430
|
+
if (seq[i].mm) engine.applyMoves(seq[i].mm, { record: false });
|
|
431
|
+
snapshots[i] = flattenState(engine.state());
|
|
432
|
+
}
|
|
433
|
+
const solved = isSolvedFlat(snapshots[n - 1], geo.per);
|
|
434
|
+
const pllIdxOnly = completionIndex(
|
|
435
|
+
snapshots.map((st) => isSolvedFlat(st, geo.per))
|
|
436
|
+
);
|
|
437
|
+
const milestone = (idx, prevAt2) => {
|
|
438
|
+
if (idx == null) return { record: null, at: prevAt2 };
|
|
439
|
+
const at = seq[idx].t;
|
|
440
|
+
return {
|
|
441
|
+
record: { at, duration: at - prevAt2, moveIndex: idx, move: seq[idx].m },
|
|
442
|
+
at
|
|
443
|
+
};
|
|
444
|
+
};
|
|
445
|
+
if (size !== 3) {
|
|
446
|
+
const pll = milestone(pllIdxOnly, 0);
|
|
447
|
+
const total2 = seq[n - 1].t;
|
|
448
|
+
return __spreadProps(__spreadValues({}, empty), {
|
|
449
|
+
solved,
|
|
450
|
+
total: total2,
|
|
451
|
+
tps: total2 > 0 ? simplifiedCount / (total2 / 1e3) : 0,
|
|
452
|
+
pll: pll.record
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
const finalCenters = centersOf(snapshots[n - 1], geo);
|
|
456
|
+
const colors = [...new Set(finalCenters)];
|
|
457
|
+
const allCrosses = {};
|
|
458
|
+
for (const color of colors) {
|
|
459
|
+
const idx = completionIndex(
|
|
460
|
+
snapshots.map((st) => crossDone(st, geo, color))
|
|
461
|
+
);
|
|
462
|
+
allCrosses[color] = idx == null ? null : { at: seq[idx].t, moveIndex: idx, move: seq[idx].m };
|
|
463
|
+
}
|
|
464
|
+
const ordered = colors.map((color) => ({ color, build: buildForCross(snapshots, geo, color) })).sort((a, b) => {
|
|
465
|
+
var _a2, _b2;
|
|
466
|
+
const ai = (_a2 = a.build.crossIdx) != null ? _a2 : Infinity;
|
|
467
|
+
const bi = (_b2 = b.build.crossIdx) != null ? _b2 : Infinity;
|
|
468
|
+
return ai - bi;
|
|
469
|
+
});
|
|
470
|
+
const cfopChosen = (_a = ordered.find((c) => isCFOP(c.build))) != null ? _a : ordered[0];
|
|
471
|
+
const cfopValid = !!cfopChosen && isCFOP(cfopChosen.build);
|
|
472
|
+
const mPerm = getMovePermutations(size)["M"].cw;
|
|
473
|
+
const rouxCandidates = [];
|
|
474
|
+
for (let s = 0; s < 6; s++) {
|
|
475
|
+
for (const u of geo.neighbors[s]) {
|
|
476
|
+
rouxCandidates.push(buildForRoux(snapshots, geo, s, u, mPerm));
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
const rouxBuild = (_b = rouxCandidates.filter((b) => isRoux(b)).sort((a, b) => a.fbIdx - b.fbIdx)[0]) != null ? _b : null;
|
|
480
|
+
let method = "unknown";
|
|
481
|
+
if (cfopValid && rouxBuild) {
|
|
482
|
+
method = cfopChosen.build.crossIdx <= rouxBuild.fbIdx ? "CFOP" : "Roux";
|
|
483
|
+
} else if (cfopValid) {
|
|
484
|
+
method = "CFOP";
|
|
485
|
+
} else if (rouxBuild) {
|
|
486
|
+
method = "Roux";
|
|
487
|
+
}
|
|
488
|
+
const total = seq[n - 1].t;
|
|
489
|
+
const base = {
|
|
490
|
+
size,
|
|
491
|
+
method,
|
|
492
|
+
solved,
|
|
493
|
+
total,
|
|
494
|
+
tps: total > 0 ? simplifiedCount / (total / 1e3) : 0,
|
|
495
|
+
moves: simplifiedMoves,
|
|
496
|
+
cross: null,
|
|
497
|
+
f2l: [],
|
|
498
|
+
oll: null,
|
|
499
|
+
pll: null,
|
|
500
|
+
firstBlock: null,
|
|
501
|
+
secondBlock: null,
|
|
502
|
+
cmll: null,
|
|
503
|
+
lse: null,
|
|
504
|
+
allCrosses,
|
|
505
|
+
unsupported
|
|
506
|
+
};
|
|
507
|
+
if (method === "Roux") {
|
|
508
|
+
const fbM = milestone(rouxBuild.fbIdx, 0);
|
|
509
|
+
const sbM = milestone(rouxBuild.sbIdx, fbM.at);
|
|
510
|
+
const cmllM = milestone(rouxBuild.cmllIdx, sbM.at);
|
|
511
|
+
const lseM = milestone(rouxBuild.lseIdx, cmllM.at);
|
|
512
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
513
|
+
firstBlock: fbM.record ? __spreadValues({ side: finalCenters[rouxBuild.firstSide] }, fbM.record) : null,
|
|
514
|
+
secondBlock: sbM.record ? __spreadValues({ side: finalCenters[rouxBuild.secondSide] }, sbM.record) : null,
|
|
515
|
+
cmll: cmllM.record,
|
|
516
|
+
lse: lseM.record
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
const { color: crossColor, build } = cfopChosen;
|
|
520
|
+
const crossM = milestone(build.crossIdx, 0);
|
|
521
|
+
const cross = crossM.record ? __spreadValues({ color: crossColor }, crossM.record) : null;
|
|
522
|
+
let prevAt = crossM.at;
|
|
523
|
+
const f2l = [];
|
|
524
|
+
for (const slot of build.f2lSlots) {
|
|
525
|
+
const m = milestone(slot.idx, prevAt);
|
|
526
|
+
if (m.record) {
|
|
527
|
+
f2l.push(__spreadValues({ slot: slot.slot }, m.record));
|
|
528
|
+
prevAt = m.at;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
const ollM = milestone(build.ollIdx, prevAt);
|
|
532
|
+
prevAt = ollM.at;
|
|
533
|
+
const pllM = milestone(build.pllIdx, prevAt);
|
|
534
|
+
return __spreadProps(__spreadValues({}, base), {
|
|
535
|
+
cross,
|
|
536
|
+
f2l,
|
|
537
|
+
oll: ollM.record,
|
|
538
|
+
pll: pllM.record
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// src/index.js
|
|
543
|
+
var FACE_NAMES2 = ["UPPER", "LEFT", "FRONT", "RIGHT", "BACK", "DOWN"];
|
|
544
|
+
var FACE_COLORS = ["W", "O", "G", "R", "B", "Y"];
|
|
545
|
+
var NOOP_SIZE2 = /* @__PURE__ */ new Set(["Uw", "Dw", "Rw", "Lw", "Fw", "M", "E", "S"]);
|
|
546
|
+
var MOVE_FNS = {
|
|
547
|
+
U: "rotateU",
|
|
548
|
+
D: "rotateD",
|
|
549
|
+
L: "rotateL",
|
|
550
|
+
R: "rotateR",
|
|
551
|
+
F: "rotateF",
|
|
552
|
+
B: "rotateB",
|
|
553
|
+
x: "rotateX",
|
|
554
|
+
y: "rotateY",
|
|
555
|
+
z: "rotateZ",
|
|
556
|
+
M: "rotateM",
|
|
557
|
+
E: "rotateE",
|
|
558
|
+
S: "rotateS",
|
|
559
|
+
Uw: "rotateUw",
|
|
560
|
+
Dw: "rotateDw",
|
|
561
|
+
Rw: "rotateRw",
|
|
562
|
+
Lw: "rotateLw",
|
|
563
|
+
Fw: "rotateFw"
|
|
564
|
+
};
|
|
565
|
+
var PERM_CACHE = /* @__PURE__ */ new Map();
|
|
566
|
+
var _OracleCube = class {
|
|
567
|
+
constructor(size) {
|
|
568
|
+
this.size = size;
|
|
569
|
+
this.STATES = {};
|
|
570
|
+
for (let f = 0; f < FACE_NAMES2.length; f++) {
|
|
571
|
+
const face = [];
|
|
572
|
+
for (let r = 0; r < size; r++) {
|
|
573
|
+
const row = [];
|
|
574
|
+
for (let c = 0; c < size; c++) {
|
|
575
|
+
row.push(f * size * size + r * size + c);
|
|
576
|
+
}
|
|
577
|
+
face.push(row);
|
|
578
|
+
}
|
|
579
|
+
this.STATES[FACE_NAMES2[f]] = face;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
// Concatenate every face row-major into a single flat array of tags.
|
|
583
|
+
flatten() {
|
|
584
|
+
const out = [];
|
|
585
|
+
for (const name of FACE_NAMES2) {
|
|
586
|
+
const face = this.STATES[name];
|
|
587
|
+
for (let r = 0; r < this.size; r++) {
|
|
588
|
+
for (let c = 0; c < this.size; c++) {
|
|
589
|
+
out.push(face[r][c]);
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return out;
|
|
594
|
+
}
|
|
595
|
+
switchMatrix(matrix, clockwise = true) {
|
|
596
|
+
const clone = structuredClone(matrix);
|
|
597
|
+
const size = this.size;
|
|
598
|
+
let tempMatrix = [];
|
|
599
|
+
for (let i = 0; i < size; i++) {
|
|
600
|
+
tempMatrix = [...tempMatrix, ...clone[i]];
|
|
601
|
+
}
|
|
602
|
+
if (size === 2) {
|
|
603
|
+
if (clockwise) {
|
|
604
|
+
return [
|
|
605
|
+
[tempMatrix[2], tempMatrix[0]],
|
|
606
|
+
[tempMatrix[3], tempMatrix[1]]
|
|
607
|
+
];
|
|
608
|
+
} else {
|
|
609
|
+
return [
|
|
610
|
+
[tempMatrix[1], tempMatrix[3]],
|
|
611
|
+
[tempMatrix[0], tempMatrix[2]]
|
|
612
|
+
];
|
|
613
|
+
}
|
|
614
|
+
} else {
|
|
615
|
+
if (clockwise) {
|
|
616
|
+
return [
|
|
617
|
+
[tempMatrix[6], tempMatrix[3], tempMatrix[0]],
|
|
618
|
+
[tempMatrix[7], tempMatrix[4], tempMatrix[1]],
|
|
619
|
+
[tempMatrix[8], tempMatrix[5], tempMatrix[2]]
|
|
620
|
+
];
|
|
621
|
+
} else {
|
|
622
|
+
return [
|
|
623
|
+
[tempMatrix[2], tempMatrix[5], tempMatrix[8]],
|
|
624
|
+
[tempMatrix[1], tempMatrix[4], tempMatrix[7]],
|
|
625
|
+
[tempMatrix[0], tempMatrix[3], tempMatrix[6]]
|
|
626
|
+
];
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
specialFlip(matrix) {
|
|
631
|
+
return structuredClone(matrix).reverse().map((row) => [...row].reverse());
|
|
632
|
+
}
|
|
633
|
+
rotateU(clockwise = true) {
|
|
634
|
+
if (clockwise) {
|
|
635
|
+
this.STATES.UPPER = this.switchMatrix(this.STATES.UPPER, true);
|
|
636
|
+
const tempFront = [...this.STATES.FRONT[0]];
|
|
637
|
+
const tempRight = [...this.STATES.RIGHT[0]];
|
|
638
|
+
const tempLeft = [...this.STATES.LEFT[0]];
|
|
639
|
+
const tempBack = [...this.STATES.BACK[0]];
|
|
640
|
+
this.STATES.FRONT[0] = [...tempRight];
|
|
641
|
+
this.STATES.LEFT[0] = [...tempFront];
|
|
642
|
+
this.STATES.BACK[0] = [...tempLeft];
|
|
643
|
+
this.STATES.RIGHT[0] = [...tempBack];
|
|
644
|
+
} else {
|
|
645
|
+
this.STATES.UPPER = this.switchMatrix(this.STATES.UPPER, false);
|
|
646
|
+
const tempFront = [...this.STATES.FRONT[0]];
|
|
647
|
+
const tempRight = [...this.STATES.RIGHT[0]];
|
|
648
|
+
const tempLeft = [...this.STATES.LEFT[0]];
|
|
649
|
+
const tempBack = [...this.STATES.BACK[0]];
|
|
650
|
+
this.STATES.FRONT[0] = [...tempLeft];
|
|
651
|
+
this.STATES.LEFT[0] = [...tempBack];
|
|
652
|
+
this.STATES.BACK[0] = [...tempRight];
|
|
653
|
+
this.STATES.RIGHT[0] = [...tempFront];
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
rotateF(clockwise = true) {
|
|
657
|
+
if (clockwise) {
|
|
658
|
+
this.rotateX(true);
|
|
659
|
+
this.rotateU(true);
|
|
660
|
+
this.rotateX(false);
|
|
661
|
+
} else {
|
|
662
|
+
this.rotateX(true);
|
|
663
|
+
this.rotateU(false);
|
|
664
|
+
this.rotateX(false);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
rotateB(clockwise = true) {
|
|
668
|
+
this.rotateY(true);
|
|
669
|
+
this.rotateY(true);
|
|
670
|
+
if (clockwise) {
|
|
671
|
+
this.rotateF(true);
|
|
672
|
+
} else {
|
|
673
|
+
this.rotateF(false);
|
|
674
|
+
}
|
|
675
|
+
this.rotateY(false);
|
|
676
|
+
this.rotateY(false);
|
|
677
|
+
}
|
|
678
|
+
rotateR(clockwise = true) {
|
|
679
|
+
if (clockwise) {
|
|
680
|
+
this.rotateY(true);
|
|
681
|
+
this.rotateX(true);
|
|
682
|
+
this.rotateU(true);
|
|
683
|
+
this.rotateX(false);
|
|
684
|
+
this.rotateY(false);
|
|
685
|
+
} else {
|
|
686
|
+
this.rotateY(true);
|
|
687
|
+
this.rotateX(true);
|
|
688
|
+
this.rotateU(false);
|
|
689
|
+
this.rotateX(false);
|
|
690
|
+
this.rotateY(false);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
rotateL(clockwise = true) {
|
|
694
|
+
if (clockwise) {
|
|
695
|
+
this.rotateY(false);
|
|
696
|
+
this.rotateX(true);
|
|
697
|
+
this.rotateU(true);
|
|
698
|
+
this.rotateX(false);
|
|
699
|
+
this.rotateY(true);
|
|
700
|
+
} else {
|
|
701
|
+
this.rotateY(false);
|
|
702
|
+
this.rotateX(true);
|
|
703
|
+
this.rotateU(false);
|
|
704
|
+
this.rotateX(false);
|
|
705
|
+
this.rotateY(true);
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
rotateD(clockwise = true) {
|
|
709
|
+
if (clockwise) {
|
|
710
|
+
this.rotateX(true);
|
|
711
|
+
this.rotateF(true);
|
|
712
|
+
this.rotateX(false);
|
|
713
|
+
} else {
|
|
714
|
+
this.rotateX(true);
|
|
715
|
+
this.rotateF(false);
|
|
716
|
+
this.rotateX(false);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
rotateDw(clockwise = true) {
|
|
720
|
+
if (this.size === 2) return;
|
|
721
|
+
if (clockwise) {
|
|
722
|
+
this.rotateY(false);
|
|
723
|
+
this.rotateU(true);
|
|
724
|
+
} else {
|
|
725
|
+
this.rotateY(true);
|
|
726
|
+
this.rotateU(false);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
rotateUw(clockwise = true) {
|
|
730
|
+
if (this.size === 2) return;
|
|
731
|
+
if (clockwise) {
|
|
732
|
+
this.rotateY(true);
|
|
733
|
+
this.rotateD(true);
|
|
734
|
+
} else {
|
|
735
|
+
this.rotateY(false);
|
|
736
|
+
this.rotateD(false);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
rotateRw(clockwise = true) {
|
|
740
|
+
if (this.size === 2) return;
|
|
741
|
+
if (clockwise) {
|
|
742
|
+
this.rotateX(true);
|
|
743
|
+
this.rotateL(true);
|
|
744
|
+
} else {
|
|
745
|
+
this.rotateX(false);
|
|
746
|
+
this.rotateL(false);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
rotateLw(clockwise = true) {
|
|
750
|
+
if (this.size === 2) return;
|
|
751
|
+
if (clockwise) {
|
|
752
|
+
this.rotateX(false);
|
|
753
|
+
this.rotateR(true);
|
|
754
|
+
} else {
|
|
755
|
+
this.rotateX(true);
|
|
756
|
+
this.rotateR(false);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
rotateM(clockwise = true) {
|
|
760
|
+
if (this.size === 2) return;
|
|
761
|
+
if (clockwise) {
|
|
762
|
+
this.rotateLw(true);
|
|
763
|
+
this.rotateL(false);
|
|
764
|
+
} else {
|
|
765
|
+
this.rotateLw(false);
|
|
766
|
+
this.rotateL(true);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
rotateE(clockwise = true) {
|
|
770
|
+
if (this.size === 2) return;
|
|
771
|
+
if (clockwise) {
|
|
772
|
+
this.rotateDw(true);
|
|
773
|
+
this.rotateD(false);
|
|
774
|
+
} else {
|
|
775
|
+
this.rotateDw(false);
|
|
776
|
+
this.rotateD(true);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
779
|
+
rotateFw(clockwise = true) {
|
|
780
|
+
if (this.size === 2) return;
|
|
781
|
+
if (clockwise) {
|
|
782
|
+
this.rotateZ(true);
|
|
783
|
+
this.rotateB(true);
|
|
784
|
+
} else {
|
|
785
|
+
this.rotateZ(false);
|
|
786
|
+
this.rotateB(false);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
rotateS(clockwise = true) {
|
|
790
|
+
if (this.size === 2) return;
|
|
791
|
+
if (clockwise) {
|
|
792
|
+
this.rotateFw(true);
|
|
793
|
+
this.rotateF(false);
|
|
794
|
+
} else {
|
|
795
|
+
this.rotateFw(false);
|
|
796
|
+
this.rotateF(true);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
rotateX(clockwise = true) {
|
|
800
|
+
const tempFront = structuredClone(this.STATES.FRONT);
|
|
801
|
+
const tempDown = structuredClone(this.STATES.DOWN);
|
|
802
|
+
const tempUpper = structuredClone(this.STATES.UPPER);
|
|
803
|
+
const tempBack = structuredClone(this.STATES.BACK);
|
|
804
|
+
const tempLeft = structuredClone(this.STATES.LEFT);
|
|
805
|
+
const tempRight = structuredClone(this.STATES.RIGHT);
|
|
806
|
+
if (clockwise) {
|
|
807
|
+
this.STATES.LEFT = this.switchMatrix(tempLeft, false);
|
|
808
|
+
this.STATES.RIGHT = this.switchMatrix(tempRight, true);
|
|
809
|
+
this.STATES.FRONT = [...tempDown];
|
|
810
|
+
this.STATES.UPPER = [...tempFront];
|
|
811
|
+
this.STATES.BACK = this.specialFlip(tempUpper);
|
|
812
|
+
this.STATES.DOWN = this.specialFlip(tempBack);
|
|
813
|
+
} else {
|
|
814
|
+
this.STATES.LEFT = this.switchMatrix(tempLeft, true);
|
|
815
|
+
this.STATES.RIGHT = this.switchMatrix(tempRight, false);
|
|
816
|
+
this.STATES.FRONT = [...tempUpper];
|
|
817
|
+
this.STATES.DOWN = [...tempFront];
|
|
818
|
+
this.STATES.BACK = this.specialFlip(tempDown);
|
|
819
|
+
this.STATES.UPPER = this.specialFlip(tempBack);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
rotateZ(clockwise = true) {
|
|
823
|
+
const tempUpper = structuredClone(this.STATES.UPPER);
|
|
824
|
+
const tempRight = structuredClone(this.STATES.RIGHT);
|
|
825
|
+
const tempDown = structuredClone(this.STATES.DOWN);
|
|
826
|
+
const tempLeft = structuredClone(this.STATES.LEFT);
|
|
827
|
+
const tempFront = structuredClone(this.STATES.FRONT);
|
|
828
|
+
const tempBack = structuredClone(this.STATES.BACK);
|
|
829
|
+
if (clockwise) {
|
|
830
|
+
this.STATES.FRONT = this.switchMatrix(tempFront, true);
|
|
831
|
+
this.STATES.BACK = this.switchMatrix(tempBack, false);
|
|
832
|
+
this.STATES.RIGHT = this.switchMatrix(tempUpper, true);
|
|
833
|
+
this.STATES.DOWN = this.switchMatrix(tempRight, true);
|
|
834
|
+
this.STATES.LEFT = this.switchMatrix(tempDown, true);
|
|
835
|
+
this.STATES.UPPER = this.switchMatrix(tempLeft, true);
|
|
836
|
+
} else {
|
|
837
|
+
this.STATES.FRONT = this.switchMatrix(tempFront, false);
|
|
838
|
+
this.STATES.BACK = this.switchMatrix(tempBack, true);
|
|
839
|
+
this.STATES.RIGHT = this.switchMatrix(tempDown, false);
|
|
840
|
+
this.STATES.DOWN = this.switchMatrix(tempLeft, false);
|
|
841
|
+
this.STATES.LEFT = this.switchMatrix(tempUpper, false);
|
|
842
|
+
this.STATES.UPPER = this.switchMatrix(tempRight, false);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
rotateY(clockwise = true) {
|
|
846
|
+
const tempFront = structuredClone(this.STATES.FRONT);
|
|
847
|
+
const tempRight = structuredClone(this.STATES.RIGHT);
|
|
848
|
+
const tempBack = structuredClone(this.STATES.BACK);
|
|
849
|
+
const tempLeft = structuredClone(this.STATES.LEFT);
|
|
850
|
+
if (clockwise) {
|
|
851
|
+
this.STATES.UPPER = this.switchMatrix(this.STATES.UPPER, true);
|
|
852
|
+
this.STATES.DOWN = this.switchMatrix(this.STATES.DOWN, false);
|
|
853
|
+
this.STATES.FRONT = [...tempRight];
|
|
854
|
+
this.STATES.RIGHT = [...tempBack];
|
|
855
|
+
this.STATES.LEFT = [...tempFront];
|
|
856
|
+
this.STATES.BACK = [...tempLeft];
|
|
857
|
+
} else {
|
|
858
|
+
this.STATES.UPPER = this.switchMatrix(this.STATES.UPPER, false);
|
|
859
|
+
this.STATES.DOWN = this.switchMatrix(this.STATES.DOWN, true);
|
|
860
|
+
this.STATES.FRONT = [...tempLeft];
|
|
861
|
+
this.STATES.RIGHT = [...tempFront];
|
|
862
|
+
this.STATES.LEFT = [...tempBack];
|
|
863
|
+
this.STATES.BACK = [...tempRight];
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
};
|
|
867
|
+
function buildPerm(size, fnName, clockwise) {
|
|
868
|
+
const oracle = new _OracleCube(size);
|
|
869
|
+
oracle[fnName](clockwise);
|
|
870
|
+
return oracle.flatten();
|
|
871
|
+
}
|
|
872
|
+
function getPerms(size) {
|
|
873
|
+
if (PERM_CACHE.has(size)) return PERM_CACHE.get(size);
|
|
874
|
+
const perms = {};
|
|
875
|
+
for (const key of Object.keys(MOVE_FNS)) {
|
|
876
|
+
perms[key] = {
|
|
877
|
+
cw: buildPerm(size, MOVE_FNS[key], true),
|
|
878
|
+
ccw: buildPerm(size, MOVE_FNS[key], false)
|
|
879
|
+
};
|
|
880
|
+
}
|
|
881
|
+
PERM_CACHE.set(size, perms);
|
|
882
|
+
return perms;
|
|
883
|
+
}
|
|
884
|
+
function getMovePermutations(size = 3) {
|
|
885
|
+
const allowedSizes = [2, 3];
|
|
886
|
+
return getPerms(allowedSizes.includes(size) ? size : 3);
|
|
887
|
+
}
|
|
888
|
+
var _stickers, _perms, _CubeEngine_instances, initializeState_fn, applyPerm_fn, apply_fn, faceMatrix_fn, applyMovesFromString_fn;
|
|
49
889
|
var CubeEngine = class {
|
|
50
890
|
constructor(initialScramble = "", options = { size: 3 }) {
|
|
51
891
|
__privateAdd(this, _CubeEngine_instances);
|
|
52
892
|
__publicField(this, "MOVES", []);
|
|
53
893
|
__publicField(this, "size", 3);
|
|
894
|
+
__privateAdd(this, _stickers, []);
|
|
895
|
+
__privateAdd(this, _perms, null);
|
|
54
896
|
const allowedSizes = [2, 3];
|
|
55
897
|
this.size = allowedSizes.includes(options.size) ? options.size : 3;
|
|
898
|
+
__privateSet(this, _perms, getPerms(this.size));
|
|
56
899
|
__privateMethod(this, _CubeEngine_instances, initializeState_fn).call(this);
|
|
57
900
|
if (typeof initialScramble === "string" && initialScramble.trim().length > 0) {
|
|
58
901
|
__privateMethod(this, _CubeEngine_instances, applyMovesFromString_fn).call(this, initialScramble, false);
|
|
@@ -63,195 +906,131 @@ var CubeEngine = class {
|
|
|
63
906
|
* Rotates the (UPPER) layer clockwise or counterclockwise.
|
|
64
907
|
*/
|
|
65
908
|
rotateU(clockwise = true) {
|
|
66
|
-
|
|
67
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, true);
|
|
68
|
-
this.MOVES.push("U");
|
|
69
|
-
} else {
|
|
70
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, false);
|
|
71
|
-
this.MOVES.push("U'");
|
|
72
|
-
}
|
|
909
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "U", clockwise ? "cw" : "ccw", true);
|
|
73
910
|
}
|
|
74
911
|
/**
|
|
75
912
|
* Rotates the (FRONT) layer clockwise or counterclockwise.
|
|
76
913
|
*/
|
|
77
914
|
rotateF(clockwise = true) {
|
|
78
|
-
|
|
79
|
-
__privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, true);
|
|
80
|
-
this.MOVES.push("F");
|
|
81
|
-
} else {
|
|
82
|
-
__privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, false);
|
|
83
|
-
this.MOVES.push("F'");
|
|
84
|
-
}
|
|
915
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "F", clockwise ? "cw" : "ccw", true);
|
|
85
916
|
}
|
|
86
917
|
/**
|
|
87
918
|
* Rotates the (BACK) layer clockwise or counterclockwise.
|
|
88
919
|
*/
|
|
89
920
|
rotateB(clockwise = true) {
|
|
90
|
-
|
|
91
|
-
__privateMethod(this, _CubeEngine_instances, rotateB_fn).call(this, true);
|
|
92
|
-
this.MOVES.push("B");
|
|
93
|
-
} else {
|
|
94
|
-
__privateMethod(this, _CubeEngine_instances, rotateB_fn).call(this, false);
|
|
95
|
-
this.MOVES.push("B'");
|
|
96
|
-
}
|
|
921
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "B", clockwise ? "cw" : "ccw", true);
|
|
97
922
|
}
|
|
98
923
|
/**
|
|
99
924
|
* Rotates the (RIGHT) layer clockwise or counterclockwise.
|
|
100
925
|
*/
|
|
101
926
|
rotateR(clockwise = true) {
|
|
102
|
-
|
|
103
|
-
__privateMethod(this, _CubeEngine_instances, rotateR_fn).call(this, true);
|
|
104
|
-
this.MOVES.push("R");
|
|
105
|
-
} else {
|
|
106
|
-
__privateMethod(this, _CubeEngine_instances, rotateR_fn).call(this, false);
|
|
107
|
-
this.MOVES.push("R'");
|
|
108
|
-
}
|
|
927
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "R", clockwise ? "cw" : "ccw", true);
|
|
109
928
|
}
|
|
110
929
|
/**
|
|
111
930
|
* Rotates the (LEFT) layer clockwise or counterclockwise.
|
|
112
931
|
*/
|
|
113
932
|
rotateL(clockwise = true) {
|
|
114
|
-
|
|
115
|
-
__privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, true);
|
|
116
|
-
this.MOVES.push("L");
|
|
117
|
-
} else {
|
|
118
|
-
__privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, false);
|
|
119
|
-
this.MOVES.push("L'");
|
|
120
|
-
}
|
|
933
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "L", clockwise ? "cw" : "ccw", true);
|
|
121
934
|
}
|
|
122
935
|
/**
|
|
123
936
|
* Rotates the (DOWN) layer clockwise or counterclockwise.
|
|
124
937
|
*/
|
|
125
938
|
rotateD(clockwise = true) {
|
|
126
|
-
|
|
127
|
-
__privateMethod(this, _CubeEngine_instances, rotateD_fn).call(this, true);
|
|
128
|
-
this.MOVES.push("D");
|
|
129
|
-
} else {
|
|
130
|
-
__privateMethod(this, _CubeEngine_instances, rotateD_fn).call(this, false);
|
|
131
|
-
this.MOVES.push("D'");
|
|
132
|
-
}
|
|
939
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "D", clockwise ? "cw" : "ccw", true);
|
|
133
940
|
}
|
|
134
941
|
/**
|
|
135
942
|
* Rotates the wide (DOWN two layers) clockwise or counterclockwise.
|
|
136
943
|
*/
|
|
137
944
|
rotateDw(clockwise = true) {
|
|
138
|
-
|
|
139
|
-
if (clockwise) {
|
|
140
|
-
__privateMethod(this, _CubeEngine_instances, rotateDw_fn).call(this, true);
|
|
141
|
-
this.MOVES.push("Dw");
|
|
142
|
-
} else {
|
|
143
|
-
__privateMethod(this, _CubeEngine_instances, rotateDw_fn).call(this, false);
|
|
144
|
-
this.MOVES.push("Dw'");
|
|
145
|
-
}
|
|
945
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "Dw", clockwise ? "cw" : "ccw", true);
|
|
146
946
|
}
|
|
147
947
|
/**
|
|
148
948
|
* Rotates the wide (UPPER two layers) clockwise or counterclockwise.
|
|
149
949
|
*/
|
|
150
950
|
rotateUw(clockwise = true) {
|
|
151
|
-
|
|
152
|
-
if (clockwise) {
|
|
153
|
-
__privateMethod(this, _CubeEngine_instances, rotateUw_fn).call(this, true);
|
|
154
|
-
this.MOVES.push("Uw");
|
|
155
|
-
} else {
|
|
156
|
-
__privateMethod(this, _CubeEngine_instances, rotateUw_fn).call(this, false);
|
|
157
|
-
this.MOVES.push("Uw'");
|
|
158
|
-
}
|
|
951
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "Uw", clockwise ? "cw" : "ccw", true);
|
|
159
952
|
}
|
|
160
953
|
/**
|
|
161
954
|
* Rotates the wide (RIGHT two layers) clockwise or counterclockwise.
|
|
162
955
|
*/
|
|
163
956
|
rotateRw(clockwise = true) {
|
|
164
|
-
|
|
165
|
-
if (clockwise) {
|
|
166
|
-
__privateMethod(this, _CubeEngine_instances, rotateRw_fn).call(this, true);
|
|
167
|
-
this.MOVES.push("Rw");
|
|
168
|
-
} else {
|
|
169
|
-
__privateMethod(this, _CubeEngine_instances, rotateRw_fn).call(this, false);
|
|
170
|
-
this.MOVES.push("Rw'");
|
|
171
|
-
}
|
|
957
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "Rw", clockwise ? "cw" : "ccw", true);
|
|
172
958
|
}
|
|
173
959
|
/**
|
|
174
960
|
* Rotates the wide (LEFT two layers) clockwise or counterclockwise.
|
|
175
961
|
*/
|
|
176
962
|
rotateLw(clockwise = true) {
|
|
177
|
-
|
|
178
|
-
if (clockwise) {
|
|
179
|
-
__privateMethod(this, _CubeEngine_instances, rotateLw_fn).call(this, true);
|
|
180
|
-
this.MOVES.push("Lw");
|
|
181
|
-
} else {
|
|
182
|
-
__privateMethod(this, _CubeEngine_instances, rotateLw_fn).call(this, false);
|
|
183
|
-
this.MOVES.push("Lw'");
|
|
184
|
-
}
|
|
963
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "Lw", clockwise ? "cw" : "ccw", true);
|
|
185
964
|
}
|
|
186
965
|
/**
|
|
187
966
|
* Rotates the middle slice (M) parallel to L/R. Clockwise corresponds to Lw followed by L'.
|
|
188
967
|
*/
|
|
189
968
|
rotateM(clockwise = true) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
969
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "M", clockwise ? "cw" : "ccw", true);
|
|
970
|
+
}
|
|
971
|
+
/**
|
|
972
|
+
* Rotates the equatorial slice (E) parallel to U/D. Clockwise follows the D direction (E = Dw D').
|
|
973
|
+
*/
|
|
974
|
+
rotateE(clockwise = true) {
|
|
975
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "E", clockwise ? "cw" : "ccw", true);
|
|
976
|
+
}
|
|
977
|
+
/**
|
|
978
|
+
* Rotates the wide (FRONT two layers) clockwise or counterclockwise. Equivalent to z B.
|
|
979
|
+
*/
|
|
980
|
+
rotateFw(clockwise = true) {
|
|
981
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "Fw", clockwise ? "cw" : "ccw", true);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Rotates the standing slice (S) parallel to F/B. Clockwise follows the F direction (S = Fw F').
|
|
985
|
+
*/
|
|
986
|
+
rotateS(clockwise = true) {
|
|
987
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "S", clockwise ? "cw" : "ccw", true);
|
|
198
988
|
}
|
|
199
989
|
/**
|
|
200
990
|
* Rotates the (x) axis clockwise or counterclockwise.
|
|
201
991
|
*/
|
|
202
992
|
rotateX(clockwise = true) {
|
|
203
|
-
|
|
204
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
205
|
-
this.MOVES.push("x");
|
|
206
|
-
} else {
|
|
207
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
208
|
-
this.MOVES.push("x'");
|
|
209
|
-
}
|
|
993
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "x", clockwise ? "cw" : "ccw", true);
|
|
210
994
|
}
|
|
211
995
|
/**
|
|
212
996
|
* Rotates the (z) axis clockwise or counterclockwise.
|
|
213
997
|
*/
|
|
214
998
|
rotateZ(clockwise = true) {
|
|
215
|
-
|
|
216
|
-
__privateMethod(this, _CubeEngine_instances, rotateZ_fn).call(this, true);
|
|
217
|
-
this.MOVES.push("z");
|
|
218
|
-
} else {
|
|
219
|
-
__privateMethod(this, _CubeEngine_instances, rotateZ_fn).call(this, false);
|
|
220
|
-
this.MOVES.push("z'");
|
|
221
|
-
}
|
|
999
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "z", clockwise ? "cw" : "ccw", true);
|
|
222
1000
|
}
|
|
223
1001
|
/**
|
|
224
1002
|
* Rotates the (y) axis clockwise or counterclockwise.
|
|
225
1003
|
*/
|
|
226
1004
|
rotateY(clockwise = true) {
|
|
227
|
-
|
|
228
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
229
|
-
this.MOVES.push("y");
|
|
230
|
-
} else {
|
|
231
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
232
|
-
this.MOVES.push("y'");
|
|
233
|
-
}
|
|
1005
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, "y", clockwise ? "cw" : "ccw", true);
|
|
234
1006
|
}
|
|
235
1007
|
/**
|
|
236
1008
|
* Logs the current state of the cube.
|
|
237
1009
|
*/
|
|
238
1010
|
state() {
|
|
239
|
-
return
|
|
1011
|
+
return {
|
|
1012
|
+
UPPER: __privateMethod(this, _CubeEngine_instances, faceMatrix_fn).call(this, 0),
|
|
1013
|
+
LEFT: __privateMethod(this, _CubeEngine_instances, faceMatrix_fn).call(this, 1),
|
|
1014
|
+
FRONT: __privateMethod(this, _CubeEngine_instances, faceMatrix_fn).call(this, 2),
|
|
1015
|
+
RIGHT: __privateMethod(this, _CubeEngine_instances, faceMatrix_fn).call(this, 3),
|
|
1016
|
+
BACK: __privateMethod(this, _CubeEngine_instances, faceMatrix_fn).call(this, 4),
|
|
1017
|
+
DOWN: __privateMethod(this, _CubeEngine_instances, faceMatrix_fn).call(this, 5)
|
|
1018
|
+
};
|
|
240
1019
|
}
|
|
241
1020
|
/**
|
|
242
1021
|
* Indicates if the cube is solve or not in all layers.
|
|
243
1022
|
*/
|
|
244
1023
|
isSolved() {
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
1024
|
+
const per = this.size * this.size;
|
|
1025
|
+
const centerOffset = this.size === 2 ? 0 : 4;
|
|
1026
|
+
for (let f = 0; f < FACE_COLORS.length; f++) {
|
|
1027
|
+
const base = f * per;
|
|
1028
|
+
const centerColor = __privateGet(this, _stickers)[base + centerOffset];
|
|
1029
|
+
for (let i = 0; i < per; i++) {
|
|
1030
|
+
if (__privateGet(this, _stickers)[base + i] !== centerColor) return false;
|
|
250
1031
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
});
|
|
254
|
-
return layersSolved.every((isLayerSolved) => isLayerSolved);
|
|
1032
|
+
}
|
|
1033
|
+
return true;
|
|
255
1034
|
}
|
|
256
1035
|
/**
|
|
257
1036
|
* Returns the history of all movements made.
|
|
@@ -271,8 +1050,8 @@ var CubeEngine = class {
|
|
|
271
1050
|
}
|
|
272
1051
|
/**
|
|
273
1052
|
* Applies a sequence of moves provided as a string.
|
|
274
|
-
* Supports: U, D, L, R, F, x, y, z; slice moves: M; and wide moves: Dw, Uw, Rw, Lw with optional ' for counterclockwise and 2 for double turns.
|
|
275
|
-
* @param {string} sequence - e.g. "R U' F R2 D Dw Uw Rw Rw' Lw Lw2 M M' M2"
|
|
1053
|
+
* Supports: U, D, L, R, F, B, x, y, z; slice moves: M, E, S; and wide moves: Dw, Uw, Rw, Lw, Fw with optional ' for counterclockwise and 2 for double turns.
|
|
1054
|
+
* @param {string} sequence - e.g. "R U' F R2 D Dw Uw Rw Rw' Lw Lw2 M M' M2 E E' S S2 Fw"
|
|
276
1055
|
* @param {object} options - { record: boolean } whether to record moves in history (default true)
|
|
277
1056
|
*/
|
|
278
1057
|
applyMoves(sequence, options = { record: false }) {
|
|
@@ -280,269 +1059,51 @@ var CubeEngine = class {
|
|
|
280
1059
|
__privateMethod(this, _CubeEngine_instances, applyMovesFromString_fn).call(this, sequence, record);
|
|
281
1060
|
}
|
|
282
1061
|
};
|
|
1062
|
+
_stickers = new WeakMap();
|
|
1063
|
+
_perms = new WeakMap();
|
|
283
1064
|
_CubeEngine_instances = new WeakSet();
|
|
284
1065
|
initializeState_fn = function() {
|
|
285
|
-
this.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
};
|
|
293
|
-
};
|
|
294
|
-
// Create a face matrix based on cube size
|
|
295
|
-
createFace_fn = function(color) {
|
|
296
|
-
const face = [];
|
|
297
|
-
for (let i = 0; i < this.size; i++) {
|
|
298
|
-
const row = [];
|
|
299
|
-
for (let j = 0; j < this.size; j++) {
|
|
300
|
-
row.push(color);
|
|
1066
|
+
const per = this.size * this.size;
|
|
1067
|
+
const stickers = new Array(FACE_COLORS.length * per);
|
|
1068
|
+
for (let f = 0; f < FACE_COLORS.length; f++) {
|
|
1069
|
+
const color = FACE_COLORS[f];
|
|
1070
|
+
const base = f * per;
|
|
1071
|
+
for (let i = 0; i < per; i++) {
|
|
1072
|
+
stickers[base + i] = color;
|
|
301
1073
|
}
|
|
302
|
-
face.push(row);
|
|
303
1074
|
}
|
|
304
|
-
|
|
1075
|
+
__privateSet(this, _stickers, stickers);
|
|
305
1076
|
};
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const tempBack = [...this.STATES.BACK[0]];
|
|
313
|
-
this.STATES.FRONT[0] = [...tempRight];
|
|
314
|
-
this.STATES.LEFT[0] = [...tempFront];
|
|
315
|
-
this.STATES.BACK[0] = [...tempLeft];
|
|
316
|
-
this.STATES.RIGHT[0] = [...tempBack];
|
|
317
|
-
} else {
|
|
318
|
-
this.STATES.UPPER = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, this.STATES.UPPER, false);
|
|
319
|
-
const tempFront = [...this.STATES.FRONT[0]];
|
|
320
|
-
const tempRight = [...this.STATES.RIGHT[0]];
|
|
321
|
-
const tempLeft = [...this.STATES.LEFT[0]];
|
|
322
|
-
const tempBack = [...this.STATES.BACK[0]];
|
|
323
|
-
this.STATES.FRONT[0] = [...tempLeft];
|
|
324
|
-
this.STATES.LEFT[0] = [...tempBack];
|
|
325
|
-
this.STATES.BACK[0] = [...tempRight];
|
|
326
|
-
this.STATES.RIGHT[0] = [...tempFront];
|
|
1077
|
+
// Apply a precomputed permutation: newState[i] = oldState[perm[i]].
|
|
1078
|
+
applyPerm_fn = function(perm) {
|
|
1079
|
+
const current = __privateGet(this, _stickers);
|
|
1080
|
+
const next = new Array(current.length);
|
|
1081
|
+
for (let i = 0; i < current.length; i++) {
|
|
1082
|
+
next[i] = current[perm[i]];
|
|
327
1083
|
}
|
|
1084
|
+
__privateSet(this, _stickers, next);
|
|
328
1085
|
};
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
} else {
|
|
335
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
336
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, false);
|
|
337
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
338
|
-
}
|
|
339
|
-
};
|
|
340
|
-
rotateB_fn = function(clockwise = true) {
|
|
341
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
342
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
343
|
-
if (clockwise) {
|
|
344
|
-
__privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, true);
|
|
345
|
-
} else {
|
|
346
|
-
__privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, false);
|
|
347
|
-
}
|
|
348
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
349
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
350
|
-
};
|
|
351
|
-
rotateR_fn = function(clockwise = true) {
|
|
352
|
-
if (clockwise) {
|
|
353
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
354
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
355
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, true);
|
|
356
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
357
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
358
|
-
} else {
|
|
359
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
360
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
361
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, false);
|
|
362
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
363
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
364
|
-
}
|
|
365
|
-
};
|
|
366
|
-
rotateL_fn = function(clockwise = true) {
|
|
367
|
-
if (clockwise) {
|
|
368
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
369
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
370
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, true);
|
|
371
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
372
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
373
|
-
} else {
|
|
374
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
375
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
376
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, false);
|
|
377
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
378
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
379
|
-
}
|
|
380
|
-
};
|
|
381
|
-
rotateD_fn = function(clockwise = true) {
|
|
382
|
-
if (clockwise) {
|
|
383
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
384
|
-
__privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, true);
|
|
385
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
386
|
-
} else {
|
|
387
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
388
|
-
__privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, false);
|
|
389
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
390
|
-
}
|
|
391
|
-
};
|
|
392
|
-
rotateDw_fn = function(clockwise = true) {
|
|
393
|
-
if (clockwise) {
|
|
394
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
395
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, true);
|
|
396
|
-
} else {
|
|
397
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
398
|
-
__privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, false);
|
|
399
|
-
}
|
|
400
|
-
};
|
|
401
|
-
rotateUw_fn = function(clockwise = true) {
|
|
402
|
-
if (clockwise) {
|
|
403
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true);
|
|
404
|
-
__privateMethod(this, _CubeEngine_instances, rotateD_fn).call(this, true);
|
|
405
|
-
} else {
|
|
406
|
-
__privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false);
|
|
407
|
-
__privateMethod(this, _CubeEngine_instances, rotateD_fn).call(this, false);
|
|
408
|
-
}
|
|
1086
|
+
// Core move dispatch. dir is "cw" or "ccw"; record controls history logging.
|
|
1087
|
+
apply_fn = function(key, dir, record) {
|
|
1088
|
+
if (this.size === 2 && NOOP_SIZE2.has(key)) return;
|
|
1089
|
+
__privateMethod(this, _CubeEngine_instances, applyPerm_fn).call(this, __privateGet(this, _perms)[key][dir]);
|
|
1090
|
+
if (record) this.MOVES.push(dir === "ccw" ? key + "'" : key);
|
|
409
1091
|
};
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
413
|
-
__privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, true);
|
|
414
|
-
} else {
|
|
415
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
416
|
-
__privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, false);
|
|
417
|
-
}
|
|
418
|
-
};
|
|
419
|
-
rotateLw_fn = function(clockwise = true) {
|
|
420
|
-
if (clockwise) {
|
|
421
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false);
|
|
422
|
-
__privateMethod(this, _CubeEngine_instances, rotateR_fn).call(this, true);
|
|
423
|
-
} else {
|
|
424
|
-
__privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true);
|
|
425
|
-
__privateMethod(this, _CubeEngine_instances, rotateR_fn).call(this, false);
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
rotateM_fn = function(clockwise = true) {
|
|
429
|
-
if (clockwise) {
|
|
430
|
-
__privateMethod(this, _CubeEngine_instances, rotateLw_fn).call(this, true);
|
|
431
|
-
__privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, false);
|
|
432
|
-
} else {
|
|
433
|
-
__privateMethod(this, _CubeEngine_instances, rotateLw_fn).call(this, false);
|
|
434
|
-
__privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, true);
|
|
435
|
-
}
|
|
436
|
-
};
|
|
437
|
-
rotateX_fn = function(clockwise = true) {
|
|
438
|
-
const tempFront = structuredClone(this.STATES.FRONT);
|
|
439
|
-
const tempDown = structuredClone(this.STATES.DOWN);
|
|
440
|
-
const tempUpper = structuredClone(this.STATES.UPPER);
|
|
441
|
-
const tempBack = structuredClone(this.STATES.BACK);
|
|
442
|
-
const tempLeft = structuredClone(this.STATES.LEFT);
|
|
443
|
-
const tempRight = structuredClone(this.STATES.RIGHT);
|
|
444
|
-
if (clockwise) {
|
|
445
|
-
this.STATES.LEFT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempLeft, false);
|
|
446
|
-
this.STATES.RIGHT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempRight, true);
|
|
447
|
-
this.STATES.FRONT = [...tempDown];
|
|
448
|
-
this.STATES.UPPER = [...tempFront];
|
|
449
|
-
this.STATES.BACK = __privateMethod(this, _CubeEngine_instances, specialFlip_fn).call(this, tempUpper);
|
|
450
|
-
this.STATES.DOWN = __privateMethod(this, _CubeEngine_instances, specialFlip_fn).call(this, tempBack);
|
|
451
|
-
} else {
|
|
452
|
-
this.STATES.LEFT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempLeft, true);
|
|
453
|
-
this.STATES.RIGHT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempRight, false);
|
|
454
|
-
this.STATES.FRONT = [...tempUpper];
|
|
455
|
-
this.STATES.DOWN = [...tempFront];
|
|
456
|
-
this.STATES.BACK = __privateMethod(this, _CubeEngine_instances, specialFlip_fn).call(this, tempDown);
|
|
457
|
-
this.STATES.UPPER = __privateMethod(this, _CubeEngine_instances, specialFlip_fn).call(this, tempBack);
|
|
458
|
-
}
|
|
459
|
-
};
|
|
460
|
-
rotateZ_fn = function(clockwise = true) {
|
|
461
|
-
const tempUpper = structuredClone(this.STATES.UPPER);
|
|
462
|
-
const tempRight = structuredClone(this.STATES.RIGHT);
|
|
463
|
-
const tempDown = structuredClone(this.STATES.DOWN);
|
|
464
|
-
const tempLeft = structuredClone(this.STATES.LEFT);
|
|
465
|
-
const tempFront = structuredClone(this.STATES.FRONT);
|
|
466
|
-
const tempBack = structuredClone(this.STATES.BACK);
|
|
467
|
-
if (clockwise) {
|
|
468
|
-
this.STATES.FRONT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempFront, true);
|
|
469
|
-
this.STATES.BACK = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempBack, false);
|
|
470
|
-
this.STATES.RIGHT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempUpper, true);
|
|
471
|
-
this.STATES.DOWN = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempRight, true);
|
|
472
|
-
this.STATES.LEFT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempDown, true);
|
|
473
|
-
this.STATES.UPPER = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempLeft, true);
|
|
474
|
-
} else {
|
|
475
|
-
this.STATES.FRONT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempFront, false);
|
|
476
|
-
this.STATES.BACK = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempBack, true);
|
|
477
|
-
this.STATES.RIGHT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempDown, false);
|
|
478
|
-
this.STATES.DOWN = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempLeft, false);
|
|
479
|
-
this.STATES.LEFT = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempUpper, false);
|
|
480
|
-
this.STATES.UPPER = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, tempRight, false);
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
rotateY_fn = function(clockwise = true) {
|
|
484
|
-
const tempFront = structuredClone(this.STATES.FRONT);
|
|
485
|
-
const tempRight = structuredClone(this.STATES.RIGHT);
|
|
486
|
-
const tempBack = structuredClone(this.STATES.BACK);
|
|
487
|
-
const tempLeft = structuredClone(this.STATES.LEFT);
|
|
488
|
-
if (clockwise) {
|
|
489
|
-
this.STATES.UPPER = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, this.STATES.UPPER, true);
|
|
490
|
-
this.STATES.DOWN = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, this.STATES.DOWN, false);
|
|
491
|
-
this.STATES.FRONT = [...tempRight];
|
|
492
|
-
this.STATES.RIGHT = [...tempBack];
|
|
493
|
-
this.STATES.LEFT = [...tempFront];
|
|
494
|
-
this.STATES.BACK = [...tempLeft];
|
|
495
|
-
} else {
|
|
496
|
-
this.STATES.UPPER = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, this.STATES.UPPER, false);
|
|
497
|
-
this.STATES.DOWN = __privateMethod(this, _CubeEngine_instances, switchMatrix_fn).call(this, this.STATES.DOWN, true);
|
|
498
|
-
this.STATES.FRONT = [...tempLeft];
|
|
499
|
-
this.STATES.RIGHT = [...tempFront];
|
|
500
|
-
this.STATES.LEFT = [...tempBack];
|
|
501
|
-
this.STATES.BACK = [...tempRight];
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
/**
|
|
505
|
-
* Rotate the entire face in the direction set
|
|
506
|
-
*/
|
|
507
|
-
switchMatrix_fn = function(matrix, clockwise = true) {
|
|
508
|
-
const clone = structuredClone(matrix);
|
|
1092
|
+
// Build a single face matrix from the flat sticker array.
|
|
1093
|
+
faceMatrix_fn = function(faceIndex) {
|
|
509
1094
|
const size = this.size;
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
return [
|
|
517
|
-
[tempMatrix[2], tempMatrix[0]],
|
|
518
|
-
[tempMatrix[3], tempMatrix[1]]
|
|
519
|
-
];
|
|
520
|
-
} else {
|
|
521
|
-
return [
|
|
522
|
-
[tempMatrix[1], tempMatrix[3]],
|
|
523
|
-
[tempMatrix[0], tempMatrix[2]]
|
|
524
|
-
];
|
|
525
|
-
}
|
|
526
|
-
} else {
|
|
527
|
-
if (clockwise) {
|
|
528
|
-
return [
|
|
529
|
-
[tempMatrix[6], tempMatrix[3], tempMatrix[0]],
|
|
530
|
-
[tempMatrix[7], tempMatrix[4], tempMatrix[1]],
|
|
531
|
-
[tempMatrix[8], tempMatrix[5], tempMatrix[2]]
|
|
532
|
-
];
|
|
533
|
-
} else {
|
|
534
|
-
return [
|
|
535
|
-
[tempMatrix[2], tempMatrix[5], tempMatrix[8]],
|
|
536
|
-
[tempMatrix[1], tempMatrix[4], tempMatrix[7]],
|
|
537
|
-
[tempMatrix[0], tempMatrix[3], tempMatrix[6]]
|
|
538
|
-
];
|
|
1095
|
+
const base = faceIndex * size * size;
|
|
1096
|
+
const matrix = [];
|
|
1097
|
+
for (let r = 0; r < size; r++) {
|
|
1098
|
+
const row = [];
|
|
1099
|
+
for (let c = 0; c < size; c++) {
|
|
1100
|
+
row.push(__privateGet(this, _stickers)[base + r * size + c]);
|
|
539
1101
|
}
|
|
1102
|
+
matrix.push(row);
|
|
540
1103
|
}
|
|
1104
|
+
return matrix;
|
|
541
1105
|
};
|
|
542
|
-
|
|
543
|
-
return structuredClone(matrix).reverse().map((row) => [...row].reverse());
|
|
544
|
-
};
|
|
545
|
-
// Internal: parses and applies moves. If record=false, uses private methods to avoid logging.
|
|
1106
|
+
// Internal: parses and applies moves, optionally recording them in history.
|
|
546
1107
|
applyMovesFromString_fn = function(sequence, record = true) {
|
|
547
1108
|
if (typeof sequence !== "string") return;
|
|
548
1109
|
const tokens = sequence.split(/\s+/).map((t) => t.trim()).filter((t) => t.length > 0);
|
|
@@ -551,121 +1112,55 @@ applyMovesFromString_fn = function(sequence, record = true) {
|
|
|
551
1112
|
const rest = token.slice(1);
|
|
552
1113
|
const isDouble = rest.includes("2");
|
|
553
1114
|
const isPrime = rest.includes("'");
|
|
554
|
-
const
|
|
555
|
-
|
|
556
|
-
fnClockwise();
|
|
557
|
-
fnClockwise();
|
|
558
|
-
} else {
|
|
559
|
-
if (isPrime) {
|
|
560
|
-
fnCounter();
|
|
561
|
-
} else {
|
|
562
|
-
fnClockwise();
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
};
|
|
1115
|
+
const isWide = /w/i.test(rest);
|
|
1116
|
+
let key;
|
|
566
1117
|
switch (base) {
|
|
567
1118
|
case "U":
|
|
568
|
-
|
|
569
|
-
const isWide = /w/i.test(rest);
|
|
570
|
-
if (isWide) {
|
|
571
|
-
exec(
|
|
572
|
-
() => record ? this.rotateUw(true) : __privateMethod(this, _CubeEngine_instances, rotateUw_fn).call(this, true),
|
|
573
|
-
() => record ? this.rotateUw(false) : __privateMethod(this, _CubeEngine_instances, rotateUw_fn).call(this, false)
|
|
574
|
-
);
|
|
575
|
-
} else {
|
|
576
|
-
exec(
|
|
577
|
-
() => record ? this.rotateU(true) : __privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, true),
|
|
578
|
-
() => record ? this.rotateU(false) : __privateMethod(this, _CubeEngine_instances, rotateU_fn).call(this, false)
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
1119
|
+
key = isWide ? "Uw" : "U";
|
|
582
1120
|
break;
|
|
583
1121
|
case "D":
|
|
584
|
-
|
|
585
|
-
const isWide = /w/i.test(rest);
|
|
586
|
-
if (isWide) {
|
|
587
|
-
exec(
|
|
588
|
-
() => record ? this.rotateDw(true) : __privateMethod(this, _CubeEngine_instances, rotateDw_fn).call(this, true),
|
|
589
|
-
() => record ? this.rotateDw(false) : __privateMethod(this, _CubeEngine_instances, rotateDw_fn).call(this, false)
|
|
590
|
-
);
|
|
591
|
-
} else {
|
|
592
|
-
exec(
|
|
593
|
-
() => record ? this.rotateD(true) : __privateMethod(this, _CubeEngine_instances, rotateD_fn).call(this, true),
|
|
594
|
-
() => record ? this.rotateD(false) : __privateMethod(this, _CubeEngine_instances, rotateD_fn).call(this, false)
|
|
595
|
-
);
|
|
596
|
-
}
|
|
597
|
-
}
|
|
1122
|
+
key = isWide ? "Dw" : "D";
|
|
598
1123
|
break;
|
|
599
1124
|
case "L":
|
|
600
|
-
|
|
601
|
-
const isWide = /w/i.test(rest);
|
|
602
|
-
if (isWide) {
|
|
603
|
-
exec(
|
|
604
|
-
() => record ? this.rotateLw(true) : __privateMethod(this, _CubeEngine_instances, rotateLw_fn).call(this, true),
|
|
605
|
-
() => record ? this.rotateLw(false) : __privateMethod(this, _CubeEngine_instances, rotateLw_fn).call(this, false)
|
|
606
|
-
);
|
|
607
|
-
} else {
|
|
608
|
-
exec(
|
|
609
|
-
() => record ? this.rotateL(true) : __privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, true),
|
|
610
|
-
() => record ? this.rotateL(false) : __privateMethod(this, _CubeEngine_instances, rotateL_fn).call(this, false)
|
|
611
|
-
);
|
|
612
|
-
}
|
|
613
|
-
}
|
|
1125
|
+
key = isWide ? "Lw" : "L";
|
|
614
1126
|
break;
|
|
615
1127
|
case "R":
|
|
616
|
-
|
|
617
|
-
const isWide = /w/i.test(rest);
|
|
618
|
-
if (isWide) {
|
|
619
|
-
exec(
|
|
620
|
-
() => record ? this.rotateRw(true) : __privateMethod(this, _CubeEngine_instances, rotateRw_fn).call(this, true),
|
|
621
|
-
() => record ? this.rotateRw(false) : __privateMethod(this, _CubeEngine_instances, rotateRw_fn).call(this, false)
|
|
622
|
-
);
|
|
623
|
-
} else {
|
|
624
|
-
exec(
|
|
625
|
-
() => record ? this.rotateR(true) : __privateMethod(this, _CubeEngine_instances, rotateR_fn).call(this, true),
|
|
626
|
-
() => record ? this.rotateR(false) : __privateMethod(this, _CubeEngine_instances, rotateR_fn).call(this, false)
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
1128
|
+
key = isWide ? "Rw" : "R";
|
|
630
1129
|
break;
|
|
631
1130
|
case "F":
|
|
632
|
-
|
|
633
|
-
() => record ? this.rotateF(true) : __privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, true),
|
|
634
|
-
() => record ? this.rotateF(false) : __privateMethod(this, _CubeEngine_instances, rotateF_fn).call(this, false)
|
|
635
|
-
);
|
|
1131
|
+
key = isWide ? "Fw" : "F";
|
|
636
1132
|
break;
|
|
637
1133
|
case "B":
|
|
638
|
-
|
|
639
|
-
() => record ? this.rotateB(true) : __privateMethod(this, _CubeEngine_instances, rotateB_fn).call(this, true),
|
|
640
|
-
() => record ? this.rotateB(false) : __privateMethod(this, _CubeEngine_instances, rotateB_fn).call(this, false)
|
|
641
|
-
);
|
|
1134
|
+
key = "B";
|
|
642
1135
|
break;
|
|
643
1136
|
case "x":
|
|
644
|
-
|
|
645
|
-
() => record ? this.rotateX(true) : __privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, true),
|
|
646
|
-
() => record ? this.rotateX(false) : __privateMethod(this, _CubeEngine_instances, rotateX_fn).call(this, false)
|
|
647
|
-
);
|
|
1137
|
+
key = "x";
|
|
648
1138
|
break;
|
|
649
1139
|
case "y":
|
|
650
|
-
|
|
651
|
-
() => record ? this.rotateY(true) : __privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, true),
|
|
652
|
-
() => record ? this.rotateY(false) : __privateMethod(this, _CubeEngine_instances, rotateY_fn).call(this, false)
|
|
653
|
-
);
|
|
1140
|
+
key = "y";
|
|
654
1141
|
break;
|
|
655
1142
|
case "z":
|
|
656
|
-
|
|
657
|
-
() => record ? this.rotateZ(true) : __privateMethod(this, _CubeEngine_instances, rotateZ_fn).call(this, true),
|
|
658
|
-
() => record ? this.rotateZ(false) : __privateMethod(this, _CubeEngine_instances, rotateZ_fn).call(this, false)
|
|
659
|
-
);
|
|
1143
|
+
key = "z";
|
|
660
1144
|
break;
|
|
661
1145
|
case "M":
|
|
662
|
-
|
|
663
|
-
() => record ? this.rotateM(true) : __privateMethod(this, _CubeEngine_instances, rotateM_fn).call(this, true),
|
|
664
|
-
() => record ? this.rotateM(false) : __privateMethod(this, _CubeEngine_instances, rotateM_fn).call(this, false)
|
|
665
|
-
);
|
|
1146
|
+
key = "M";
|
|
666
1147
|
break;
|
|
667
|
-
|
|
1148
|
+
case "E":
|
|
1149
|
+
key = "E";
|
|
668
1150
|
break;
|
|
1151
|
+
case "S":
|
|
1152
|
+
key = "S";
|
|
1153
|
+
break;
|
|
1154
|
+
default:
|
|
1155
|
+
continue;
|
|
1156
|
+
}
|
|
1157
|
+
if (isDouble) {
|
|
1158
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, key, "cw", record);
|
|
1159
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, key, "cw", record);
|
|
1160
|
+
} else if (isPrime) {
|
|
1161
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, key, "ccw", record);
|
|
1162
|
+
} else {
|
|
1163
|
+
__privateMethod(this, _CubeEngine_instances, apply_fn).call(this, key, "cw", record);
|
|
669
1164
|
}
|
|
670
1165
|
}
|
|
671
1166
|
};
|
|
@@ -680,5 +1175,9 @@ var COLOR = {
|
|
|
680
1175
|
// Annotate the CommonJS export names for ESM import in node:
|
|
681
1176
|
0 && (module.exports = {
|
|
682
1177
|
COLOR,
|
|
683
|
-
CubeEngine
|
|
1178
|
+
CubeEngine,
|
|
1179
|
+
analyzeSolution,
|
|
1180
|
+
getMovePermutations,
|
|
1181
|
+
invertSequence,
|
|
1182
|
+
simplifyMoves
|
|
684
1183
|
});
|