cubing 0.56.0 → 0.57.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/dist/bin/chunks/{chunk-DFQMTDRG.js → chunk-J53ID3VX.js} +2 -2
- package/dist/bin/chunks/chunk-J53ID3VX.js.map +7 -0
- package/dist/bin/order.js +1 -1
- package/dist/bin/order.js.map +2 -2
- package/dist/bin/puzzle-geometry-bin.js +1 -1
- package/dist/bin/puzzle-geometry-bin.js.map +2 -2
- package/dist/bin/scramble.js +1 -1
- package/dist/lib/cubing/{PuzzleLoader-DWqO9l1G.d.ts → PuzzleLoader-Dd4G1VlU.d.ts} +355 -312
- package/dist/lib/cubing/alg/index.d.ts +8 -8
- package/dist/lib/cubing/alg/index.js +1 -1
- package/dist/lib/cubing/bluetooth/index.d.ts +7 -8
- package/dist/lib/cubing/bluetooth/index.js +68 -54
- package/dist/lib/cubing/bluetooth/index.js.map +3 -3
- package/dist/lib/cubing/{bluetooth-puzzle-C6TIIh-Z.d.ts → bluetooth-puzzle-FIXncgc8.d.ts} +1 -1
- package/dist/lib/cubing/chunks/big-puzzle-orientation-IZASZS5A.js +70 -0
- package/dist/lib/cubing/chunks/big-puzzle-orientation-IZASZS5A.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-TQF5J7MH.js → chunk-3YVVF3KK.js} +79 -79
- package/dist/lib/cubing/chunks/chunk-3YVVF3KK.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-XPH22PGR.js → chunk-CGV5LY7H.js} +2 -2
- package/dist/lib/cubing/chunks/chunk-CGV5LY7H.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-KO64SKMG.js → chunk-DWN2US56.js} +11 -11
- package/dist/lib/cubing/chunks/chunk-DWN2US56.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-MA47PABE.js → chunk-EVYENG3X.js} +40 -42
- package/dist/lib/cubing/chunks/chunk-EVYENG3X.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-BQNTAVTA.js → chunk-GKM2CK6T.js} +2 -2
- package/dist/lib/cubing/chunks/{chunk-WOAANT6Y.js → chunk-J6NSY47E.js} +114 -21
- package/dist/lib/cubing/chunks/chunk-J6NSY47E.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-YFGRXDD4.js → chunk-KAXXPFNE.js} +4 -4
- package/dist/lib/cubing/chunks/{chunk-YFGRXDD4.js.map → chunk-KAXXPFNE.js.map} +2 -2
- package/dist/lib/cubing/chunks/{chunk-YQVHA4F6.js → chunk-MITU5GJ5.js} +55 -51
- package/dist/lib/cubing/chunks/{chunk-YQVHA4F6.js.map → chunk-MITU5GJ5.js.map} +3 -3
- package/dist/lib/cubing/chunks/{chunk-M4T7GO54.js → chunk-SNKS5WOA.js} +92 -70
- package/dist/lib/cubing/chunks/chunk-SNKS5WOA.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-2SBMIHZV.js → chunk-SWKNZGJF.js} +100 -108
- package/dist/lib/cubing/chunks/chunk-SWKNZGJF.js.map +7 -0
- package/dist/lib/cubing/chunks/{inside-KAVAZETT.js → inside-AF5A42Y6.js} +18 -18
- package/dist/lib/cubing/chunks/{inside-KAVAZETT.js.map → inside-AF5A42Y6.js.map} +2 -2
- package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-AHFPWEBD.js → puzzles-dynamic-side-events-BOGUHF4Q.js} +1660 -1660
- package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-AHFPWEBD.js.map → puzzles-dynamic-side-events-BOGUHF4Q.js.map} +3 -3
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-FTWMZ5ZJ.js → search-dynamic-sgs-side-events-PVOJWVJF.js} +7 -7
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-FTWMZ5ZJ.js.map → search-dynamic-sgs-side-events-PVOJWVJF.js.map} +2 -2
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-ZYGVRJQK.js → search-dynamic-sgs-unofficial-HRR5D2US.js} +648 -648
- package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-HRR5D2US.js.map +7 -0
- package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-6MKLH6KJ.js → search-dynamic-solve-4x4x4-3CROPIQD.js} +7 -7
- package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-5YRST2XM.js → search-dynamic-solve-fto-NKAFVO65.js} +2 -2
- package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-W64XQPBF.js → search-dynamic-solve-kilominx-EDGE5SP4.js} +2 -2
- package/dist/lib/cubing/chunks/search-worker-entry.js +1 -1
- package/dist/lib/cubing/chunks/{twisty-dynamic-3d-QGRCHB6L.js → twisty-dynamic-3d-EIIPCTEF.js} +63 -57
- package/dist/lib/cubing/chunks/twisty-dynamic-3d-EIIPCTEF.js.map +7 -0
- package/dist/lib/cubing/chunks/{twsearch-ITWEA5PO.js → twsearch-TGLVN7TI.js} +2 -2
- package/dist/lib/cubing/{index-g0IQg962.d.ts → index-Drw5ySJm.d.ts} +2 -2
- package/dist/lib/cubing/kpuzzle/index.d.ts +1 -1
- package/dist/lib/cubing/kpuzzle/index.js +2 -2
- package/dist/lib/cubing/notation/index.d.ts +3 -3
- package/dist/lib/cubing/notation/index.js +4 -4
- package/dist/lib/cubing/protocol/index.d.ts +1 -1
- package/dist/lib/cubing/protocol/index.js +4 -4
- package/dist/lib/cubing/puzzle-geometry/index.d.ts +2 -2
- package/dist/lib/cubing/puzzle-geometry/index.js +456 -438
- package/dist/lib/cubing/puzzle-geometry/index.js.map +3 -3
- package/dist/lib/cubing/puzzles/index.d.ts +1 -1
- package/dist/lib/cubing/puzzles/index.js +4 -4
- package/dist/lib/cubing/scramble/index.d.ts +2 -2
- package/dist/lib/cubing/scramble/index.js +6 -6
- package/dist/lib/cubing/search/index.d.ts +2 -2
- package/dist/lib/cubing/search/index.js +6 -6
- package/dist/lib/cubing/stream/index.d.ts +22 -22
- package/dist/lib/cubing/stream/index.js +41 -41
- package/dist/lib/cubing/stream/index.js.map +3 -3
- package/dist/lib/cubing/twisty/index.d.ts +8 -8
- package/dist/lib/cubing/twisty/index.js +3678 -3638
- package/dist/lib/cubing/twisty/index.js.map +4 -4
- package/package.json +13 -7
- package/dist/bin/chunks/chunk-DFQMTDRG.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-2SBMIHZV.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-KO64SKMG.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-M4T7GO54.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-MA47PABE.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-TQF5J7MH.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-WOAANT6Y.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-XPH22PGR.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-sgs-unofficial-ZYGVRJQK.js.map +0 -7
- package/dist/lib/cubing/chunks/twisty-dynamic-3d-QGRCHB6L.js.map +0 -7
- /package/dist/lib/cubing/chunks/{chunk-BQNTAVTA.js.map → chunk-GKM2CK6T.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-6MKLH6KJ.js.map → search-dynamic-solve-4x4x4-3CROPIQD.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-5YRST2XM.js.map → search-dynamic-solve-fto-NKAFVO65.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-W64XQPBF.js.map → search-dynamic-solve-kilominx-EDGE5SP4.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{twsearch-ITWEA5PO.js.map → twsearch-TGLVN7TI.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { O as AlgNode, s as Alg, M as Move, R as AppendOptions, U as
|
|
2
|
-
export {
|
|
1
|
+
import { O as AlgNode, s as Alg, M as Move, R as AppendOptions, U as Grouping, W as LineComment, X as Commutator, Y as Conjugate, Z as Newline, _ as Pause, $ as KeyMapping, A as AlgLeaf } from '../PuzzleLoader-Dd4G1VlU.js';
|
|
2
|
+
export { a0 as AlgBranch, a5 as AppendCancelOptions, a3 as ExperimentalNotationType, a2 as ExperimentalParsed, a4 as ExperimentalSerializationOptions, a1 as MoveModifications, x as PuzzleSpecificSimplifyOptions, a7 as QuantumMove, a6 as SimplifyOptions } from '../PuzzleLoader-Dd4G1VlU.js';
|
|
3
3
|
import 'three/src/Three.js';
|
|
4
4
|
|
|
5
5
|
/** @deprecated */
|
|
@@ -18,6 +18,10 @@ declare class AlgBuilder {
|
|
|
18
18
|
reset(): void;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
declare function setAlgDebug(options: {
|
|
22
|
+
caretNISSNotationEnabled?: boolean;
|
|
23
|
+
}): void;
|
|
24
|
+
|
|
21
25
|
declare const Example: {
|
|
22
26
|
Sune: Alg;
|
|
23
27
|
AntiSune: Alg;
|
|
@@ -32,6 +36,8 @@ declare const Example: {
|
|
|
32
36
|
TriplePause: Alg;
|
|
33
37
|
};
|
|
34
38
|
|
|
39
|
+
declare function experimentalIs(v: any, c: typeof Alg | typeof Grouping | typeof LineComment | typeof Commutator | typeof Conjugate | typeof Move | typeof Newline | typeof Pause): boolean;
|
|
40
|
+
|
|
35
41
|
declare function keyToMove(keyMapping: KeyMapping | undefined, e: KeyboardEvent): AlgLeaf | null;
|
|
36
42
|
|
|
37
43
|
declare abstract class TraversalDownUp<DataDown, DataAlgUp, DataAlgNodeUp = DataAlgUp> {
|
|
@@ -74,10 +80,4 @@ interface AlgCubingNetOptions {
|
|
|
74
80
|
/** @deprecated */
|
|
75
81
|
declare function experimentalAlgCubingNetLink(options: AlgCubingNetOptions): string;
|
|
76
82
|
|
|
77
|
-
declare function experimentalIs(v: any, c: typeof Alg | typeof Grouping | typeof LineComment | typeof Commutator | typeof Conjugate | typeof Move | typeof Newline | typeof Pause): boolean;
|
|
78
|
-
|
|
79
|
-
declare function setAlgDebug(options: {
|
|
80
|
-
caretNISSNotationEnabled?: boolean;
|
|
81
|
-
}): void;
|
|
82
|
-
|
|
83
83
|
export { Alg, AlgBuilder, type AlgCubingNetOptions, AlgLeaf, AlgNode, Commutator, Conjugate, Example, Grouping, LineComment, Move, Newline, Pause, TraversalDownUp, TraversalUp, type Unit, experimentalAlgCubingNetLink, experimentalAppendMove, experimentalIs, functionFromTraversal, keyToMove, setAlgDebug };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { u as PuzzleID, t as PuzzleLoader, K as KPattern, s as Alg, M as Move } from '../PuzzleLoader-
|
|
2
|
-
import { B as BluetoothPuzzle } from '../bluetooth-puzzle-
|
|
3
|
-
export { A as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-
|
|
1
|
+
import { u as PuzzleID, t as PuzzleLoader, $ as KeyMapping, K as KPattern, s as Alg, M as Move } from '../PuzzleLoader-Dd4G1VlU.js';
|
|
2
|
+
import { B as BluetoothPuzzle } from '../bluetooth-puzzle-FIXncgc8.js';
|
|
3
|
+
export { A as MoveEvent, O as OrientationEvent } from '../bluetooth-puzzle-FIXncgc8.js';
|
|
4
4
|
import 'three/src/Three.js';
|
|
5
5
|
|
|
6
6
|
declare function enableDebugLogging(enable: boolean): void;
|
|
@@ -8,12 +8,11 @@ declare function enableDebugLogging(enable: boolean): void;
|
|
|
8
8
|
/** @category Keyboard Puzzles */
|
|
9
9
|
declare class KeyboardPuzzle extends BluetoothPuzzle {
|
|
10
10
|
private target;
|
|
11
|
-
private
|
|
12
|
-
|
|
13
|
-
listener: (e: KeyboardEvent) => Promise<void>;
|
|
11
|
+
private keyMappingAndPatternPromise;
|
|
12
|
+
listener: EventListener;
|
|
14
13
|
constructor(target: Element, puzzle?: PuzzleID | PuzzleLoader);
|
|
15
14
|
name(): string | undefined;
|
|
16
|
-
|
|
15
|
+
setPuzzleInternal(puzzle: PuzzleID | PuzzleLoader): Promise<[KeyMapping | undefined, KPattern]>;
|
|
17
16
|
disconnect(): void;
|
|
18
17
|
getPattern(): Promise<KPattern>;
|
|
19
18
|
private onKeyDown;
|
|
@@ -116,7 +115,7 @@ declare class GanRobot extends EventTarget {
|
|
|
116
115
|
name(): string | undefined;
|
|
117
116
|
disconnect(): void;
|
|
118
117
|
onDisconnect(): void;
|
|
119
|
-
private
|
|
118
|
+
private algNodeToNibble;
|
|
120
119
|
private writeNibbles;
|
|
121
120
|
private getStatus;
|
|
122
121
|
locked: boolean;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
binaryComponentsToReid3x3x3,
|
|
3
3
|
twizzleBinaryToBinaryComponents
|
|
4
|
-
} from "../chunks/chunk-
|
|
4
|
+
} from "../chunks/chunk-KAXXPFNE.js";
|
|
5
5
|
import {
|
|
6
6
|
cube3x3x3,
|
|
7
7
|
puzzles
|
|
8
|
-
} from "../chunks/chunk-
|
|
8
|
+
} from "../chunks/chunk-J6NSY47E.js";
|
|
9
9
|
import {
|
|
10
10
|
experimental3x3x3KPuzzle
|
|
11
|
-
} from "../chunks/chunk-
|
|
11
|
+
} from "../chunks/chunk-MITU5GJ5.js";
|
|
12
12
|
import {
|
|
13
13
|
KPattern
|
|
14
|
-
} from "../chunks/chunk-
|
|
14
|
+
} from "../chunks/chunk-3YVVF3KK.js";
|
|
15
15
|
import {
|
|
16
16
|
Alg,
|
|
17
17
|
Move,
|
|
18
18
|
experimentalAppendMove,
|
|
19
19
|
keyToMove
|
|
20
|
-
} from "../chunks/chunk-
|
|
20
|
+
} from "../chunks/chunk-SWKNZGJF.js";
|
|
21
21
|
|
|
22
22
|
// src/cubing/bluetooth/debug.ts
|
|
23
23
|
var DEBUG_LOGGING_ENABLED = false;
|
|
@@ -132,6 +132,7 @@ var BluetoothPuzzle = class extends EventTarget {
|
|
|
132
132
|
|
|
133
133
|
// src/cubing/bluetooth/keyboard.ts
|
|
134
134
|
var KeyboardPuzzle = class extends BluetoothPuzzle {
|
|
135
|
+
// (e: KeyboardEvent) => Promise<void>;
|
|
135
136
|
// TODO: Decide on the right arguments.
|
|
136
137
|
// TODO: support tying the puzzle to a TwistyPlayer.
|
|
137
138
|
constructor(target, puzzle = "3x3x3") {
|
|
@@ -139,41 +140,43 @@ var KeyboardPuzzle = class extends BluetoothPuzzle {
|
|
|
139
140
|
this.target = target;
|
|
140
141
|
this.listener = this.onKeyDown.bind(this);
|
|
141
142
|
target.addEventListener("keydown", this.listener);
|
|
142
|
-
this.
|
|
143
|
+
this.keyMappingAndPatternPromise = this.setPuzzleInternal(puzzle);
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
-
pattern;
|
|
145
|
+
keyMappingAndPatternPromise;
|
|
146
146
|
listener;
|
|
147
147
|
name() {
|
|
148
148
|
return "Keyboard Input";
|
|
149
149
|
}
|
|
150
|
-
async
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
this.pattern = (async () => (await kpuzzlePromise).defaultPattern())();
|
|
150
|
+
async setPuzzleInternal(puzzle) {
|
|
151
|
+
const puzzleLoader = await (async () => typeof puzzle === "string" ? (await import("../puzzles/index.js")).puzzles[puzzle] : puzzle)();
|
|
152
|
+
const kpuzzle = await (async () => puzzleLoader.kpuzzle())();
|
|
153
|
+
return Promise.all([puzzleLoader.keyMapping?.(), kpuzzle.defaultPattern()]);
|
|
155
154
|
}
|
|
156
155
|
disconnect() {
|
|
157
156
|
this.target.removeEventListener("keydown", this.listener);
|
|
158
157
|
}
|
|
159
158
|
async getPattern() {
|
|
160
|
-
return this.
|
|
159
|
+
return (await this.keyMappingAndPatternPromise)[1];
|
|
161
160
|
}
|
|
162
161
|
async onKeyDown(e) {
|
|
163
162
|
if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) {
|
|
164
163
|
return;
|
|
165
164
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
165
|
+
this.keyMappingAndPatternPromise = (async () => {
|
|
166
|
+
const [keyMapping, pattern] = await this.keyMappingAndPatternPromise;
|
|
167
|
+
const algLeaf = keyToMove(keyMapping, e);
|
|
168
|
+
let newPattern;
|
|
169
|
+
if (algLeaf) {
|
|
170
|
+
newPattern = pattern.applyAlg(new Alg([algLeaf]));
|
|
171
|
+
this.dispatchAlgLeaf({
|
|
172
|
+
latestAlgLeaf: algLeaf,
|
|
173
|
+
timeStamp: e.timeStamp,
|
|
174
|
+
pattern: newPattern
|
|
175
|
+
});
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
}
|
|
178
|
+
return [keyMapping, newPattern ?? pattern];
|
|
179
|
+
})();
|
|
177
180
|
}
|
|
178
181
|
};
|
|
179
182
|
async function debugKeyboardConnect(target = window, puzzle = "3x3x3") {
|
|
@@ -219,7 +222,7 @@ async function bluetoothConnect(configs, options = {}) {
|
|
|
219
222
|
consecutiveFailures = 0;
|
|
220
223
|
} catch (e) {
|
|
221
224
|
consecutiveFailures++;
|
|
222
|
-
throw
|
|
225
|
+
throw e;
|
|
223
226
|
}
|
|
224
227
|
debugLog("Device:", device);
|
|
225
228
|
if (typeof device.gatt === "undefined") {
|
|
@@ -640,13 +643,13 @@ var GanCube = class _GanCube extends BluetoothPuzzle {
|
|
|
640
643
|
};
|
|
641
644
|
for (const cornerMapping of gan356iCornerMappings) {
|
|
642
645
|
const pieceInfo = pieceMap[cornerMapping.map((i) => faceOrder[stickers[i]]).join("")];
|
|
643
|
-
patternData
|
|
644
|
-
patternData
|
|
646
|
+
patternData["CORNERS"].pieces.push(pieceInfo.piece);
|
|
647
|
+
patternData["CORNERS"].orientation.push(pieceInfo.orientation);
|
|
645
648
|
}
|
|
646
649
|
for (const edgeMapping of gan356iEdgeMappings) {
|
|
647
650
|
const pieceInfo = pieceMap[edgeMapping.map((i) => faceOrder[stickers[i]]).join("")];
|
|
648
|
-
patternData
|
|
649
|
-
patternData
|
|
651
|
+
patternData["EDGES"].pieces.push(pieceInfo.piece);
|
|
652
|
+
patternData["EDGES"].orientation.push(pieceInfo.orientation);
|
|
650
653
|
}
|
|
651
654
|
return new KPattern(this.kpuzzle, patternData);
|
|
652
655
|
}
|
|
@@ -664,7 +667,7 @@ var GanCube = class _GanCube extends BluetoothPuzzle {
|
|
|
664
667
|
}
|
|
665
668
|
async reset() {
|
|
666
669
|
const faceletStatus1Characteristic = await this.faceletStatus1Characteristic();
|
|
667
|
-
await faceletStatus1Characteristic.writeValue(commands
|
|
670
|
+
await faceletStatus1Characteristic.writeValue(commands["reset"]);
|
|
668
671
|
}
|
|
669
672
|
async readFaceletStatus1Characteristic() {
|
|
670
673
|
const faceletStatus1Characteristic = await this.faceletStatus1Characteristic();
|
|
@@ -858,13 +861,13 @@ var GiiKERCube = class _GiiKERCube extends BluetoothPuzzle {
|
|
|
858
861
|
};
|
|
859
862
|
for (let i = 0; i < 12; i++) {
|
|
860
863
|
const gi = epReid333toGiiKER[i];
|
|
861
|
-
patternData
|
|
862
|
-
patternData
|
|
864
|
+
patternData["EDGES"].pieces[i] = epGiiKERtoReid333[getNibble(val, gi + 16) - 1];
|
|
865
|
+
patternData["EDGES"].orientation[i] = this.getBit(val, gi + 112) ^ preEO[patternData["EDGES"].pieces[i]] ^ postEO[i];
|
|
863
866
|
}
|
|
864
867
|
for (let i = 0; i < 8; i++) {
|
|
865
868
|
const gi = cpReid333toGiiKER[i];
|
|
866
|
-
patternData
|
|
867
|
-
patternData
|
|
869
|
+
patternData["CORNERS"].pieces[i] = cpGiiKERtoReid333[getNibble(val, gi) - 1];
|
|
870
|
+
patternData["CORNERS"].orientation[i] = (getNibble(val, gi + 8) * coFlip[gi] + preCO[patternData["CORNERS"].pieces[i]] + postCO[i]) % 3;
|
|
868
871
|
}
|
|
869
872
|
return new KPattern(experimental3x3x3KPuzzle, patternData);
|
|
870
873
|
}
|
|
@@ -1276,9 +1279,9 @@ function isDoubleTurnNibble(nibble) {
|
|
|
1276
1279
|
function nibbleDuration(nibble) {
|
|
1277
1280
|
return isDoubleTurnNibble(nibble) ? DOUBLE_TURN_DURATION_MS : QUANTUM_TURN_DURATION_MS;
|
|
1278
1281
|
}
|
|
1279
|
-
function
|
|
1280
|
-
console.error("invalid
|
|
1281
|
-
throw new Error("invalid
|
|
1282
|
+
function throwInvalidAlgNode(algNode) {
|
|
1283
|
+
console.error("invalid alg node", algNode, algNode.toString());
|
|
1284
|
+
throw new Error("invalid alg node!");
|
|
1282
1285
|
}
|
|
1283
1286
|
function sleep(ms) {
|
|
1284
1287
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1333,10 +1336,14 @@ var GanRobot = class _GanRobot extends EventTarget {
|
|
|
1333
1336
|
onDisconnect() {
|
|
1334
1337
|
this.dispatchEvent(new CustomEvent("disconnect"));
|
|
1335
1338
|
}
|
|
1336
|
-
|
|
1339
|
+
algNodeToNibble(algNode) {
|
|
1340
|
+
const move = algNode.as(Move);
|
|
1341
|
+
if (!move) {
|
|
1342
|
+
throwInvalidAlgNode(algNode);
|
|
1343
|
+
}
|
|
1337
1344
|
const nibble = (this.experimentalOptions.xAngle ? moveMapX : moveMap2)[move.toString()] ?? null;
|
|
1338
1345
|
if (nibble === null) {
|
|
1339
|
-
|
|
1346
|
+
throwInvalidAlgNode(move);
|
|
1340
1347
|
}
|
|
1341
1348
|
return nibble;
|
|
1342
1349
|
}
|
|
@@ -1399,22 +1406,29 @@ var GanRobot = class _GanRobot extends EventTarget {
|
|
|
1399
1406
|
while (this.moveQueue.experimentalNumChildAlgNodes() > 0) {
|
|
1400
1407
|
let algNodes = Array.from(this.moveQueue.childAlgNodes());
|
|
1401
1408
|
if (this.experimentalOptions.singleMoveFixHack && algNodes.length === 1) {
|
|
1402
|
-
const move = algNodes[0];
|
|
1403
|
-
if (move
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1409
|
+
const move = algNodes[0].as(Move);
|
|
1410
|
+
if (move) {
|
|
1411
|
+
if (move.amount === 2) {
|
|
1412
|
+
algNodes = [
|
|
1413
|
+
move.modified({ amount: 1 }),
|
|
1414
|
+
move.modified({ amount: 1 })
|
|
1415
|
+
];
|
|
1416
|
+
} else {
|
|
1417
|
+
algNodes = [
|
|
1418
|
+
move.modified({ amount: -move.amount }),
|
|
1419
|
+
move.modified({ amount: 2 })
|
|
1420
|
+
];
|
|
1421
|
+
}
|
|
1413
1422
|
}
|
|
1414
1423
|
}
|
|
1415
|
-
const
|
|
1416
|
-
|
|
1417
|
-
|
|
1424
|
+
const splicedAlgNodes = algNodes.splice(
|
|
1425
|
+
0,
|
|
1426
|
+
MAX_NIBBLES_PER_WRITE
|
|
1427
|
+
);
|
|
1428
|
+
const nibbles = splicedAlgNodes.map(
|
|
1429
|
+
this.algNodeToNibble.bind(this)
|
|
1430
|
+
);
|
|
1431
|
+
const sending = new Alg(splicedAlgNodes);
|
|
1418
1432
|
this.experimentalDebugLog("SENDING", sending.toString());
|
|
1419
1433
|
if (this.experimentalDebugOnSend) {
|
|
1420
1434
|
this.experimentalDebugOnSend(sending);
|