cubing 0.63.8 → 0.64.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-EWR23OA4.js → chunk-DQNBCFR3.js} +2 -2
- package/dist/bin/chunks/{chunk-EWR23OA4.js.map → chunk-DQNBCFR3.js.map} +1 -1
- package/dist/bin/order.js +1 -1
- package/dist/bin/order.js.map +1 -1
- package/dist/bin/puzzle-geometry-bin.js +1 -1
- package/dist/bin/puzzle-geometry-bin.js.map +1 -1
- package/dist/bin/scramble.js +1 -1
- package/dist/bin/scramble.js.map +1 -1
- package/dist/bin/svg.js +1 -1
- package/dist/bin/svg.js.map +1 -1
- package/dist/lib/cubing/alg/index.d.ts +1 -1
- package/dist/lib/cubing/alg/index.js +1 -1
- package/dist/lib/cubing/bluetooth/index.d.ts +17 -17
- package/dist/lib/cubing/bluetooth/index.js +96 -96
- package/dist/lib/cubing/bluetooth/index.js.map +2 -2
- package/dist/lib/cubing/chunks/{big-puzzle-orientation-ADWIOX6S.js → big-puzzle-orientation-G75BXW2W.js} +2 -2
- package/dist/lib/cubing/chunks/big-puzzle-orientation-G75BXW2W.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-A7FK4XKU.js → chunk-5LBACZOM.js} +173 -144
- package/dist/lib/cubing/chunks/chunk-5LBACZOM.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-5KMTA6PX.js → chunk-7MYDNYZ3.js} +3 -3
- package/dist/lib/cubing/chunks/chunk-7MYDNYZ3.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-7LXHWXCO.js → chunk-ALR6ZQFC.js} +2 -2
- package/dist/lib/cubing/chunks/chunk-ALR6ZQFC.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-H5KMIDAF.js → chunk-DTYBGCI3.js} +5 -5
- package/dist/lib/cubing/chunks/chunk-DTYBGCI3.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-YR72E7KZ.js → chunk-GO2SL6SC.js} +38 -38
- package/dist/lib/cubing/chunks/chunk-GO2SL6SC.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-FUAADKXE.js → chunk-KHUP3BPA.js} +35 -34
- package/dist/lib/cubing/chunks/chunk-KHUP3BPA.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-MQSQDKWH.js → chunk-O2QJENHE.js} +3 -3
- package/dist/lib/cubing/chunks/chunk-O2QJENHE.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-5ONX3JVC.js → chunk-THRYJMRP.js} +8 -8
- package/dist/lib/cubing/chunks/chunk-THRYJMRP.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-UEUJSZTX.js → chunk-UWJ575HH.js} +58 -46
- package/dist/lib/cubing/chunks/chunk-UWJ575HH.js.map +7 -0
- package/dist/lib/cubing/chunks/{chunk-N5FJ5YIA.js → chunk-YFNXHRNE.js} +37 -31
- package/dist/lib/cubing/chunks/chunk-YFNXHRNE.js.map +7 -0
- package/dist/lib/cubing/chunks/{inside-JAJOK2MI.js → inside-A7LIP56H.js} +14 -14
- package/dist/lib/cubing/chunks/inside-A7LIP56H.js.map +7 -0
- package/dist/lib/cubing/chunks/{puzzles-dynamic-side-events-IMYJ533P.js → puzzles-dynamic-side-events-653A7JCM.js} +1 -1
- package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-653A7JCM.js.map +7 -0
- package/dist/lib/cubing/chunks/{puzzles-dynamic-unofficial-P3TW433I.js → puzzles-dynamic-unofficial-2CY6GVZ4.js} +1 -1
- package/dist/lib/cubing/chunks/{puzzles-dynamic-unofficial-P3TW433I.js.map → puzzles-dynamic-unofficial-2CY6GVZ4.js.map} +1 -1
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-side-events-WORUZVF5.js → search-dynamic-sgs-side-events-YSB3MWLK.js} +6 -6
- package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-YSB3MWLK.js.map +7 -0
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-5JQKPNG2.js → search-dynamic-sgs-unofficial-OLK64DE6.js} +6 -6
- package/dist/lib/cubing/chunks/{search-dynamic-sgs-unofficial-5JQKPNG2.js.map → search-dynamic-sgs-unofficial-OLK64DE6.js.map} +1 -1
- package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-BGV4AJVT.js → search-dynamic-solve-4x4x4-WWFUMIDG.js} +7 -7
- package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-I5ID5LXD.js → search-dynamic-solve-fto-ZZKLTONP.js} +2 -2
- package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-Y2D3C74Y.js → search-dynamic-solve-kilominx-PUF4PRHS.js} +2 -2
- package/dist/lib/cubing/chunks/search-worker-entry.js +1 -1
- package/dist/lib/cubing/chunks/search-worker-entry.js.map +2 -2
- package/dist/lib/cubing/chunks/{twips-ZNMKGC5U.js → twips-LHO3IYJC.js} +2 -2
- package/dist/lib/cubing/chunks/{twisty-dynamic-3d-4BEQ76PB.js → twisty-dynamic-3d-A2G22YLA.js} +6 -6
- package/dist/lib/cubing/chunks/twisty-dynamic-3d-A2G22YLA.js.map +7 -0
- package/dist/lib/cubing/{index-B2leUGbW.d.ts → index-C2x6Sc62.d.ts} +52 -47
- package/dist/lib/cubing/{index-BLw2OxXo.d.ts → index-Doa1gNE4.d.ts} +1 -1
- 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 +17 -15
- package/dist/lib/cubing/notation/index.js +4 -4
- package/dist/lib/cubing/{outside-V6_PW1ZK.d.ts → outside-nf-4k7Tp.d.ts} +1 -1
- 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 +1 -1
- package/dist/lib/cubing/puzzle-geometry/index.js +284 -184
- package/dist/lib/cubing/puzzle-geometry/index.js.map +2 -2
- 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 +1 -1
- package/dist/lib/cubing/scramble/index.js +6 -6
- package/dist/lib/cubing/search/index.d.ts +1 -1
- package/dist/lib/cubing/search/index.js +6 -6
- package/dist/lib/cubing/search/index.js.map +1 -1
- package/dist/lib/cubing/stream/index.d.ts +1 -1
- package/dist/lib/cubing/stream/index.js +1 -1
- package/dist/lib/cubing/stream/index.js.map +1 -1
- package/dist/lib/cubing/twisty/index.d.ts +1 -1
- package/dist/lib/cubing/twisty/index.js +189 -177
- package/dist/lib/cubing/twisty/index.js.map +2 -2
- package/package.json +2 -2
- package/dist/lib/cubing/chunks/big-puzzle-orientation-ADWIOX6S.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-5KMTA6PX.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-5ONX3JVC.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-7LXHWXCO.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-A7FK4XKU.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-FUAADKXE.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-H5KMIDAF.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-MQSQDKWH.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-N5FJ5YIA.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-UEUJSZTX.js.map +0 -7
- package/dist/lib/cubing/chunks/chunk-YR72E7KZ.js.map +0 -7
- package/dist/lib/cubing/chunks/inside-JAJOK2MI.js.map +0 -7
- package/dist/lib/cubing/chunks/puzzles-dynamic-side-events-IMYJ533P.js.map +0 -7
- package/dist/lib/cubing/chunks/search-dynamic-sgs-side-events-WORUZVF5.js.map +0 -7
- package/dist/lib/cubing/chunks/twisty-dynamic-3d-4BEQ76PB.js.map +0 -7
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-4x4x4-BGV4AJVT.js.map → search-dynamic-solve-4x4x4-WWFUMIDG.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-fto-I5ID5LXD.js.map → search-dynamic-solve-fto-ZZKLTONP.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{search-dynamic-solve-kilominx-Y2D3C74Y.js.map → search-dynamic-solve-kilominx-PUF4PRHS.js.map} +0 -0
- /package/dist/lib/cubing/chunks/{twips-ZNMKGC5U.js.map → twips-LHO3IYJC.js.map} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
cube3x3x3KPuzzleDefinition
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5LBACZOM.js";
|
|
4
4
|
import {
|
|
5
5
|
TraversalUp,
|
|
6
6
|
functionFromTraversal
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-YFNXHRNE.js";
|
|
8
8
|
|
|
9
9
|
// src/cubing/notation/CountAnimatedLeaves.ts
|
|
10
10
|
var CountAnimatedLeaves = class extends TraversalUp {
|
|
@@ -40,32 +40,44 @@ var CountAnimatedLeaves = class extends TraversalUp {
|
|
|
40
40
|
var countAnimatedLeaves = functionFromTraversal(CountAnimatedLeaves);
|
|
41
41
|
|
|
42
42
|
// src/cubing/notation/commonMetrics.ts
|
|
43
|
-
var CommonMetric =
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
43
|
+
var CommonMetric = {
|
|
44
|
+
// OBTM (Outer Block Turn Metric)
|
|
45
|
+
OuterBlockTurnMetric: "OBTM",
|
|
46
|
+
// RBTM (Range Block Turn Metric)
|
|
47
|
+
RangeBlockTurnMetric: "RBTM",
|
|
48
|
+
// SSTM (Single Slice Turn Metric)
|
|
49
|
+
SingleSliceTurnMetric: "SSTM",
|
|
50
|
+
// OBQTM (Outer Block Quantum Turn Metric)
|
|
51
|
+
OuterBlockQuantumTurnMetric: "OBQTM",
|
|
52
|
+
// RBQTM (Range Block Quantum Turn Metric)
|
|
53
|
+
RangeBlockQuantumTurnMetric: "RBQTM",
|
|
54
|
+
// SSQTM (Single Slice Quantum Turn Metric)
|
|
55
|
+
SingleSliceQuantumTurnMetric: "SSQTM",
|
|
56
|
+
ExecutionTurnMetric: "ETM"
|
|
57
|
+
};
|
|
58
|
+
var CommonMetricAlias = {
|
|
59
|
+
// QTM (Quantum Turn Metric)
|
|
60
|
+
QuantumTurnMetric: "OBQTM",
|
|
61
|
+
// HTM (Hand Turn Metric)
|
|
62
|
+
HandTurnMetric: "OBTM",
|
|
63
|
+
// STM (Slice Turn Metric)
|
|
64
|
+
SliceTurnMetric: "RBTM"
|
|
65
|
+
};
|
|
59
66
|
|
|
60
67
|
// src/cubing/notation/cube3x3x3Metrics.ts
|
|
68
|
+
var MoveType = {
|
|
69
|
+
Rotation: "Rotation",
|
|
70
|
+
Outer: "Outer",
|
|
71
|
+
Inner: "Inner"
|
|
72
|
+
};
|
|
61
73
|
function uncachedMoveCount(moveQuantumString) {
|
|
62
74
|
if (moveQuantumString.endsWith("v") || ["x", "y", "z"].includes(moveQuantumString)) {
|
|
63
|
-
return
|
|
75
|
+
return MoveType.Rotation;
|
|
64
76
|
}
|
|
65
77
|
if (moveQuantumString.startsWith("2") || ["M", "E", "S"].includes(moveQuantumString)) {
|
|
66
|
-
return
|
|
78
|
+
return MoveType.Inner;
|
|
67
79
|
}
|
|
68
|
-
return
|
|
80
|
+
return MoveType.Outer;
|
|
69
81
|
}
|
|
70
82
|
var cache;
|
|
71
83
|
function getCache() {
|
|
@@ -84,30 +96,30 @@ function getCache() {
|
|
|
84
96
|
}
|
|
85
97
|
var costFactorsByMetric = {
|
|
86
98
|
// Note: these are hardcoded for 3x3x3. They will not automatically generalize to any other puzzles.
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[
|
|
90
|
-
[
|
|
99
|
+
[CommonMetric.OuterBlockTurnMetric]: {
|
|
100
|
+
[MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },
|
|
101
|
+
[MoveType.Outer]: { constantFactor: 1, amountFactor: 0, zeroAmount: 0 },
|
|
102
|
+
[MoveType.Inner]: { constantFactor: 2, amountFactor: 0, zeroAmount: 0 }
|
|
91
103
|
},
|
|
92
|
-
[
|
|
93
|
-
[
|
|
94
|
-
[
|
|
95
|
-
[
|
|
104
|
+
[CommonMetric.RangeBlockTurnMetric]: {
|
|
105
|
+
[MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },
|
|
106
|
+
[MoveType.Outer]: { constantFactor: 1, amountFactor: 0, zeroAmount: 0 },
|
|
107
|
+
[MoveType.Inner]: { constantFactor: 1, amountFactor: 0, zeroAmount: 0 }
|
|
96
108
|
},
|
|
97
|
-
[
|
|
98
|
-
[
|
|
99
|
-
[
|
|
100
|
-
[
|
|
109
|
+
[CommonMetric.OuterBlockQuantumTurnMetric]: {
|
|
110
|
+
[MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },
|
|
111
|
+
[MoveType.Outer]: { constantFactor: 0, amountFactor: 1, zeroAmount: 0 },
|
|
112
|
+
[MoveType.Inner]: { constantFactor: 0, amountFactor: 2, zeroAmount: 0 }
|
|
101
113
|
},
|
|
102
|
-
[
|
|
103
|
-
[
|
|
104
|
-
[
|
|
105
|
-
[
|
|
114
|
+
[CommonMetric.RangeBlockQuantumTurnMetric]: {
|
|
115
|
+
[MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },
|
|
116
|
+
[MoveType.Outer]: { constantFactor: 0, amountFactor: 1, zeroAmount: 0 },
|
|
117
|
+
[MoveType.Inner]: { constantFactor: 0, amountFactor: 1, zeroAmount: 0 }
|
|
106
118
|
},
|
|
107
|
-
[
|
|
108
|
-
[
|
|
109
|
-
[
|
|
110
|
-
[
|
|
119
|
+
[CommonMetric.ExecutionTurnMetric]: {
|
|
120
|
+
[MoveType.Rotation]: { constantFactor: 1, amountFactor: 0, zeroAmount: 1 },
|
|
121
|
+
[MoveType.Outer]: { constantFactor: 1, amountFactor: 0, zeroAmount: 1 },
|
|
122
|
+
[MoveType.Inner]: { constantFactor: 1, amountFactor: 0, zeroAmount: 1 }
|
|
111
123
|
}
|
|
112
124
|
};
|
|
113
125
|
function countMove3x3x3(metric, move) {
|
|
@@ -130,11 +142,11 @@ function countMove3x3x3(metric, move) {
|
|
|
130
142
|
|
|
131
143
|
// src/cubing/notation/CountMoves.ts
|
|
132
144
|
var CountMoves = class extends TraversalUp {
|
|
145
|
+
metric;
|
|
133
146
|
constructor(metric) {
|
|
134
147
|
super();
|
|
135
148
|
this.metric = metric;
|
|
136
149
|
}
|
|
137
|
-
metric;
|
|
138
150
|
traverseAlg(alg) {
|
|
139
151
|
let r = 0;
|
|
140
152
|
for (const algNode of alg.childAlgNodes()) {
|
|
@@ -243,15 +255,15 @@ function countMetricMoves(puzzleLoader, metric, alg) {
|
|
|
243
255
|
}
|
|
244
256
|
} else {
|
|
245
257
|
switch (metric) {
|
|
246
|
-
case
|
|
258
|
+
case CommonMetric.ExecutionTurnMetric:
|
|
247
259
|
return countMovesETM(alg);
|
|
248
|
-
case
|
|
260
|
+
case CommonMetric.RangeBlockTurnMetric: {
|
|
249
261
|
if (puzzleLoader.pg) {
|
|
250
262
|
return countRangeBlockMovesPG(alg);
|
|
251
263
|
}
|
|
252
264
|
break;
|
|
253
265
|
}
|
|
254
|
-
case
|
|
266
|
+
case CommonMetric.RangeBlockQuantumTurnMetric: {
|
|
255
267
|
if (puzzleLoader.pg) {
|
|
256
268
|
return countRangeBlockQuantumMovesPG(alg);
|
|
257
269
|
}
|
|
@@ -271,4 +283,4 @@ export {
|
|
|
271
283
|
countLeavesInExpansionForSimultaneousMoveIndexer,
|
|
272
284
|
countMetricMoves
|
|
273
285
|
};
|
|
274
|
-
//# sourceMappingURL=chunk-
|
|
286
|
+
//# sourceMappingURL=chunk-UWJ575HH.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/cubing/notation/CountAnimatedLeaves.ts", "../../../../src/cubing/notation/commonMetrics.ts", "../../../../src/cubing/notation/cube3x3x3Metrics.ts", "../../../../src/cubing/notation/CountMoves.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n type Alg,\n type Commutator,\n type Conjugate,\n functionFromTraversal,\n type Grouping,\n type LineComment,\n type Move,\n type Newline,\n type Pause,\n TraversalUp,\n} from \"../alg/index.ts\";\nimport type { LeafCount } from \"../twisty/controllers/indexer/AlgIndexer.ts\";\n\n// TODO: Include Pause, include amounts\nclass CountAnimatedLeaves extends TraversalUp<LeafCount, LeafCount> {\n public traverseAlg(alg: Alg): LeafCount {\n let total = 0 as LeafCount;\n for (const part of alg.childAlgNodes()) {\n /** @ts-expect-error: ts(2322) Rewriting this would required duplicating `total`. */\n total += this.traverseAlgNode(part);\n }\n return total;\n }\n\n public traverseGrouping(grouping: Grouping): LeafCount {\n return (this.traverseAlg(grouping.alg) *\n Math.abs(grouping.amount)) as LeafCount;\n }\n\n public traverseMove(_move: Move): LeafCount {\n return 1 as LeafCount;\n }\n\n public traverseCommutator(commutator: Commutator): LeafCount {\n return (2 *\n (this.traverseAlg(commutator.A) +\n this.traverseAlg(commutator.B))) as LeafCount;\n }\n\n public traverseConjugate(conjugate: Conjugate): LeafCount {\n return (2 * this.traverseAlg(conjugate.A) +\n this.traverseAlg(conjugate.B)) as LeafCount;\n }\n\n public traversePause(_pause: Pause): LeafCount {\n return 1 as LeafCount;\n }\n\n public traverseNewline(_newline: Newline): LeafCount {\n return 0 as LeafCount;\n }\n\n public traverseLineComment(_comment: LineComment): LeafCount {\n return 0 as LeafCount;\n }\n}\n\nexport const countAnimatedLeaves = functionFromTraversal(CountAnimatedLeaves);\n", "export type CommonMetric = (typeof CommonMetric)[keyof typeof CommonMetric];\nexport const CommonMetric = {\n // OBTM (Outer Block Turn Metric)\n OuterBlockTurnMetric: \"OBTM\",\n // RBTM (Range Block Turn Metric)\n RangeBlockTurnMetric: \"RBTM\",\n // SSTM (Single Slice Turn Metric)\n SingleSliceTurnMetric: \"SSTM\",\n // OBQTM (Outer Block Quantum Turn Metric)\n OuterBlockQuantumTurnMetric: \"OBQTM\",\n // RBQTM (Range Block Quantum Turn Metric)\n RangeBlockQuantumTurnMetric: \"RBQTM\",\n // SSQTM (Single Slice Quantum Turn Metric)\n SingleSliceQuantumTurnMetric: \"SSQTM\",\n ExecutionTurnMetric: \"ETM\",\n};\n\nexport type CommonMetricAlias =\n (typeof CommonMetricAlias)[keyof typeof CommonMetricAlias];\nexport const CommonMetricAlias = {\n // QTM (Quantum Turn Metric)\n QuantumTurnMetric: \"OBQTM\",\n // HTM (Hand Turn Metric)\n HandTurnMetric: \"OBTM\",\n // STM (Slice Turn Metric)\n SliceTurnMetric: \"RBTM\",\n};\n", "// TODO: move this into the 3x3x3 puzzle loader.\n\nimport type { Move } from \"../alg/index.ts\";\nimport { experimentalCube3x3x3KPuzzleDefinition } from \"../puzzles/cubing-private/index.ts\";\nimport { CommonMetric } from \"./commonMetrics.ts\";\n\nexport type MoveType = (typeof MoveType)[keyof typeof MoveType];\nexport const MoveType = {\n Rotation: \"Rotation\",\n Outer: \"Outer\",\n Inner: \"Inner\",\n};\n\nfunction uncachedMoveCount(moveQuantumString: string): MoveType {\n if (\n moveQuantumString.endsWith(\"v\") ||\n [\"x\", \"y\", \"z\"].includes(moveQuantumString)\n ) {\n // Rv\n return MoveType.Rotation;\n }\n if (\n moveQuantumString.startsWith(\"2\") ||\n [\"M\", \"E\", \"S\"].includes(moveQuantumString)\n ) {\n return MoveType.Inner;\n }\n return MoveType.Outer;\n}\n\nlet cache: Record<string, MoveType> | undefined;\nfunction getCache(): Record<string, MoveType> {\n if (cache) {\n return cache;\n }\n cache = {};\n const moveQuantumStrings = [\n ...Object.keys(experimentalCube3x3x3KPuzzleDefinition.moves),\n ...Object.keys(experimentalCube3x3x3KPuzzleDefinition.derivedMoves!),\n ];\n for (const moveQuantumString of moveQuantumStrings) {\n cache[moveQuantumString] = uncachedMoveCount(moveQuantumString);\n }\n return cache;\n}\n\n// Ancient wisdom: https://github.com/cubing/alg.js/blob/0599fad84d81b8d943ad3ea3e5dc191db8b6c157/alg.js#L638-L651\n/**\n * A move with an amount of 0 always has 0 cost. Else, the cost is\n *\n * constantFactor + amountFactor * Math.abs(move.amount)\n *\n */\nexport const costFactorsByMetric: Partial<\n Record<\n CommonMetric,\n Record<\n MoveType,\n {\n constantFactor: number;\n amountFactor: number;\n zeroAmount: number;\n }\n >\n >\n> = {\n // Note: these are hardcoded for 3x3x3. They will not automatically generalize to any other puzzles.\n [CommonMetric.OuterBlockTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },\n [MoveType.Outer]: { constantFactor: 1, amountFactor: 0, zeroAmount: 0 },\n [MoveType.Inner]: { constantFactor: 2, amountFactor: 0, zeroAmount: 0 },\n },\n [CommonMetric.RangeBlockTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },\n [MoveType.Outer]: { constantFactor: 1, amountFactor: 0, zeroAmount: 0 },\n [MoveType.Inner]: { constantFactor: 1, amountFactor: 0, zeroAmount: 0 },\n },\n [CommonMetric.OuterBlockQuantumTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },\n [MoveType.Outer]: { constantFactor: 0, amountFactor: 1, zeroAmount: 0 },\n [MoveType.Inner]: { constantFactor: 0, amountFactor: 2, zeroAmount: 0 },\n },\n [CommonMetric.RangeBlockQuantumTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 0, amountFactor: 0, zeroAmount: 0 },\n [MoveType.Outer]: { constantFactor: 0, amountFactor: 1, zeroAmount: 0 },\n [MoveType.Inner]: { constantFactor: 0, amountFactor: 1, zeroAmount: 0 },\n },\n [CommonMetric.ExecutionTurnMetric]: {\n [MoveType.Rotation]: { constantFactor: 1, amountFactor: 0, zeroAmount: 1 },\n [MoveType.Outer]: { constantFactor: 1, amountFactor: 0, zeroAmount: 1 },\n [MoveType.Inner]: { constantFactor: 1, amountFactor: 0, zeroAmount: 1 },\n },\n};\n\nexport function countMove3x3x3(metric: CommonMetric, move: Move): number {\n const costFactors = costFactorsByMetric[metric];\n if (!costFactors) {\n throw new Error(`Invalid metric for 3x3x3: ${metric}`);\n }\n const cache = getCache();\n const moveQuantumString = move.quantum.toString();\n if (!(moveQuantumString in cache)) {\n throw new Error(`Invalid move for 3x3x3 ${metric}: ${moveQuantumString}`);\n }\n const costType = cache[moveQuantumString];\n const { constantFactor, amountFactor, zeroAmount } = costFactors[costType];\n if (move.amount === 0) {\n return zeroAmount;\n }\n return constantFactor + amountFactor * Math.abs(move.amount);\n}\n", "// TODO: move this file somewhere permanent.\nimport {\n type Alg,\n type Commutator,\n type Conjugate,\n functionFromTraversal,\n type Grouping,\n type LineComment,\n type Move,\n type Newline,\n type Pause,\n TraversalUp,\n} from \"../alg/index.ts\";\nimport type { PuzzleLoader } from \"../puzzles/index.ts\";\nimport { CommonMetric } from \"./commonMetrics.ts\";\nimport { costFactorsByMetric, countMove3x3x3 } from \"./cube3x3x3Metrics.ts\";\n\n/*\n * For movecount, that understands puzzle rotations. This code\n * should be moved to the alg class, probably.\n */\nclass CountMoves extends TraversalUp<number> {\n private metric: (move: Move) => number;\n constructor(metric: (move: Move) => number) {\n super();\n this.metric = metric;\n }\n\n public traverseAlg(alg: Alg): number {\n let r = 0;\n for (const algNode of alg.childAlgNodes()) {\n r += this.traverseAlgNode(algNode);\n }\n return r;\n }\n\n public traverseGrouping(grouping: Grouping): number {\n const alg: Alg = grouping.alg;\n return this.traverseAlg(alg) * Math.abs(grouping.amount);\n }\n\n public traverseMove(move: Move): number {\n return this.metric(move);\n }\n\n public traverseCommutator(commutator: Commutator): number {\n return (\n 2 * (this.traverseAlg(commutator.A) + this.traverseAlg(commutator.B))\n );\n }\n\n public traverseConjugate(conjugate: Conjugate): number {\n return 2 * this.traverseAlg(conjugate.A) + this.traverseAlg(conjugate.B);\n }\n\n // TODO: Remove spaces between repeated pauses (in traverseSequence)\n public traversePause(_pause: Pause): number {\n return 0;\n }\n\n public traverseNewline(_newLine: Newline): number {\n return 0;\n }\n\n // TODO: Enforce being followed by a newline (or the end of the alg)?\n public traverseLineComment(_comment: LineComment): number {\n return 0;\n }\n}\n\n// TODO\nclass CountLeavesInExpansionForSimultaneousMoveIndexer extends TraversalUp<number> {\n public traverseAlg(alg: Alg): number {\n let r = 0;\n for (const algNode of alg.childAlgNodes()) {\n r += this.traverseAlgNode(algNode);\n }\n return r;\n }\n\n public traverseGrouping(grouping: Grouping): number {\n const alg: Alg = grouping.alg;\n return this.traverseAlg(alg) * Math.abs(grouping.amount);\n }\n\n public traverseMove(_move: Move): number {\n return 1;\n }\n\n public traverseCommutator(commutator: Commutator): number {\n return (\n 2 * (this.traverseAlg(commutator.A) + this.traverseAlg(commutator.B))\n );\n }\n\n public traverseConjugate(conjugate: Conjugate): number {\n return 2 * this.traverseAlg(conjugate.A) + this.traverseAlg(conjugate.B);\n }\n\n // TODO: Remove spaces between repeated pauses (in traverseSequence)\n public traversePause(_pause: Pause): number {\n return 1;\n }\n\n public traverseNewline(_newLine: Newline): number {\n return 1;\n }\n\n // TODO: Enforce being followed by a newline (or the end of the alg)?\n public traverseLineComment(_comment: LineComment): number {\n return 1;\n }\n}\n\nfunction isCharUppercase(c: string): boolean {\n return \"A\" <= c && c <= \"Z\";\n}\n\n// TODO: Implement a puzzle-specific way to calculate this.\nfunction baseMetric(move: Move): number {\n const fam = move.family;\n if (\n (isCharUppercase(fam[0]) && fam[fam.length - 1] === \"v\") ||\n fam === \"x\" ||\n fam === \"y\" ||\n fam === \"z\" ||\n fam === \"T\"\n ) {\n return 0;\n } else {\n return 1;\n }\n}\n\nfunction etmMetric(_move: Move): number {\n return 1;\n}\n\n// TODO: Implement a puzzle-specific way to calculate this.\nfunction rangeBlockTurnMetric(move: Move): number {\n const fam = move.family;\n if (\n (isCharUppercase(fam[0]) && fam[fam.length - 1] === \"v\") ||\n fam === \"x\" ||\n fam === \"y\" ||\n fam === \"z\" ||\n fam === \"T\"\n ) {\n return 0;\n } else {\n return 1;\n }\n}\n\n// TODO: Implement a puzzle-specific way to calculate this.\nfunction quantumMetric(move: Move): number {\n return Math.abs(move.amount) * rangeBlockTurnMetric(move);\n}\n\nexport const countMoves = functionFromTraversal(CountMoves, [baseMetric]);\nexport const countMovesETM = functionFromTraversal(CountMoves, [etmMetric]);\nexport const countRangeBlockQuantumMovesPG = functionFromTraversal(CountMoves, [\n quantumMetric,\n]);\nexport const countRangeBlockMovesPG = functionFromTraversal(CountMoves, [\n rangeBlockTurnMetric,\n]);\n\nexport const countLeavesInExpansionForSimultaneousMoveIndexer =\n functionFromTraversal(CountLeavesInExpansionForSimultaneousMoveIndexer, []);\n\n/**\n * Only implemented so far:\n *\n * - 3x3x3: OBTM, RBTM, ETM\n */\nexport function countMetricMoves(\n puzzleLoader: PuzzleLoader,\n metric: CommonMetric,\n alg: Alg,\n): number {\n if (puzzleLoader.id === \"3x3x3\") {\n if (metric in costFactorsByMetric) {\n return functionFromTraversal(CountMoves, [\n (move: Move) => countMove3x3x3(metric, move),\n ])(alg);\n }\n } else {\n switch (metric) {\n case CommonMetric.ExecutionTurnMetric:\n return countMovesETM(alg);\n case CommonMetric.RangeBlockTurnMetric: {\n if (puzzleLoader.pg) {\n return countRangeBlockMovesPG(alg);\n }\n break;\n }\n case CommonMetric.RangeBlockQuantumTurnMetric: {\n if (puzzleLoader.pg) {\n return countRangeBlockQuantumMovesPG(alg);\n }\n break;\n }\n }\n }\n throw new Error(\"Unsupported puzzle or metric.\");\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;AAeA,IA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AA,EAC7E;AACF,CAAC;AACM,IAAM,yBAAyB,sBAAsB,YAAY;AAAA,EACtE;AACF,CAAC;AAEM,IAAM,mDACX,sBAAsB,kDAAkD,CAAC,CAAC;AAOrE,SAAS,iBACd,cACA,QACA,KACQ;AACR,MAAI,aAAa,OAAO,SAAS;AAC/B,QAAI,UAAU,qBAAqB;AACjC,aAAO,sBAAsB,YAAY;AAAA,QACvC,CAAC,SAAe,eAAe,QAAQ,IAAI;AAAA,MAC7C,CAAC,EAAE,GAAG;AAAA,IACR;AAAA,EACF,OAAO;AACL,YAAQ,QAAQ;AAAA,MACd,KAAK,aAAa;AAChB,eAAO,cAAc,GAAG;AAAA,MAC1B,KAAK,aAAa,sBAAsB;AACtC,YAAI,aAAa,IAAI;AACnB,iBAAO,uBAAuB,GAAG;AAAA,QACnC;AACA;AAAA,MACF;AAAA,MACA,KAAK,aAAa,6BAA6B;AAC7C,YAAI,aAAa,IAAI;AACnB,iBAAO,8BAA8B,GAAG;AAAA,QAC1C;AACA;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,QAAM,IAAI,MAAM,+BAA+B;AACjD;",
|
|
6
|
+
"names": ["cache"]
|
|
7
|
+
}
|
|
@@ -25,25 +25,30 @@ var AlgCommon = class extends Comparable {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// src/cubing/alg/iteration.ts
|
|
28
|
+
var IterationDirection = {
|
|
29
|
+
Forwards: 1,
|
|
30
|
+
Backwards: -1
|
|
31
|
+
};
|
|
28
32
|
function toggleDirection(iterationDirection, flip = true) {
|
|
29
33
|
if (!flip) {
|
|
30
34
|
return iterationDirection;
|
|
31
35
|
}
|
|
32
36
|
switch (iterationDirection) {
|
|
33
|
-
case
|
|
34
|
-
return
|
|
35
|
-
case
|
|
36
|
-
return
|
|
37
|
+
case IterationDirection.Forwards:
|
|
38
|
+
return IterationDirection.Backwards;
|
|
39
|
+
case IterationDirection.Backwards:
|
|
40
|
+
return IterationDirection.Forwards;
|
|
37
41
|
}
|
|
42
|
+
throw new Error("Invalid input iteration direction.");
|
|
38
43
|
}
|
|
39
44
|
function direct(g, iterDir) {
|
|
40
|
-
return iterDir ===
|
|
45
|
+
return iterDir === IterationDirection.Backwards ? Array.from(g).reverse() : g;
|
|
41
46
|
}
|
|
42
47
|
function reverse(g) {
|
|
43
48
|
return Array.from(g).reverse();
|
|
44
49
|
}
|
|
45
50
|
function* directedGenerator(g, direction) {
|
|
46
|
-
direction ===
|
|
51
|
+
direction === IterationDirection.Backwards ? yield* reverseGenerator(g) : yield* g;
|
|
47
52
|
}
|
|
48
53
|
function* reverseGenerator(g) {
|
|
49
54
|
for (const t of Array.from(g).reverse()) {
|
|
@@ -73,43 +78,43 @@ var Commutator = class _Commutator extends AlgCommon {
|
|
|
73
78
|
invert() {
|
|
74
79
|
return new _Commutator(this.#B, this.#A);
|
|
75
80
|
}
|
|
76
|
-
*experimentalExpand(iterDir =
|
|
81
|
+
*experimentalExpand(iterDir = IterationDirection.Forwards, depth) {
|
|
77
82
|
depth ??= Infinity;
|
|
78
83
|
if (depth === 0) {
|
|
79
|
-
yield iterDir ===
|
|
84
|
+
yield iterDir === IterationDirection.Forwards ? this : this.invert();
|
|
80
85
|
} else {
|
|
81
|
-
if (iterDir ===
|
|
86
|
+
if (iterDir === IterationDirection.Forwards) {
|
|
82
87
|
yield* this.A.experimentalExpand(
|
|
83
|
-
|
|
88
|
+
IterationDirection.Forwards,
|
|
84
89
|
depth - 1
|
|
85
90
|
);
|
|
86
91
|
yield* this.B.experimentalExpand(
|
|
87
|
-
|
|
92
|
+
IterationDirection.Forwards,
|
|
88
93
|
depth - 1
|
|
89
94
|
);
|
|
90
95
|
yield* this.A.experimentalExpand(
|
|
91
|
-
|
|
96
|
+
IterationDirection.Backwards,
|
|
92
97
|
depth - 1
|
|
93
98
|
);
|
|
94
99
|
yield* this.B.experimentalExpand(
|
|
95
|
-
|
|
100
|
+
IterationDirection.Backwards,
|
|
96
101
|
depth - 1
|
|
97
102
|
);
|
|
98
103
|
} else {
|
|
99
104
|
yield* this.B.experimentalExpand(
|
|
100
|
-
|
|
105
|
+
IterationDirection.Forwards,
|
|
101
106
|
depth - 1
|
|
102
107
|
);
|
|
103
108
|
yield* this.A.experimentalExpand(
|
|
104
|
-
|
|
109
|
+
IterationDirection.Forwards,
|
|
105
110
|
depth - 1
|
|
106
111
|
);
|
|
107
112
|
yield* this.B.experimentalExpand(
|
|
108
|
-
|
|
113
|
+
IterationDirection.Backwards,
|
|
109
114
|
depth - 1
|
|
110
115
|
);
|
|
111
116
|
yield* this.A.experimentalExpand(
|
|
112
|
-
|
|
117
|
+
IterationDirection.Backwards,
|
|
113
118
|
depth - 1
|
|
114
119
|
);
|
|
115
120
|
}
|
|
@@ -145,11 +150,11 @@ var Conjugate = class _Conjugate extends AlgCommon {
|
|
|
145
150
|
*experimentalExpand(iterDir, depth) {
|
|
146
151
|
depth ??= Infinity;
|
|
147
152
|
if (depth === 0) {
|
|
148
|
-
yield iterDir ===
|
|
153
|
+
yield iterDir === IterationDirection.Forwards ? this : this.invert();
|
|
149
154
|
} else {
|
|
150
|
-
yield* this.A.experimentalExpand(
|
|
155
|
+
yield* this.A.experimentalExpand(IterationDirection.Forwards, depth - 1);
|
|
151
156
|
yield* this.B.experimentalExpand(iterDir, depth - 1);
|
|
152
|
-
yield* this.A.experimentalExpand(
|
|
157
|
+
yield* this.A.experimentalExpand(IterationDirection.Backwards, depth - 1);
|
|
153
158
|
}
|
|
154
159
|
}
|
|
155
160
|
toString(experimentalSerializationOptions) {
|
|
@@ -208,7 +213,7 @@ var LineComment = class _LineComment extends AlgCommon {
|
|
|
208
213
|
invert() {
|
|
209
214
|
return this;
|
|
210
215
|
}
|
|
211
|
-
*experimentalExpand(_iterDir =
|
|
216
|
+
*experimentalExpand(_iterDir = IterationDirection.Forwards, _depth = Infinity) {
|
|
212
217
|
yield this;
|
|
213
218
|
}
|
|
214
219
|
toString(_experimentalSerializationOptions) {
|
|
@@ -233,7 +238,7 @@ var Newline = class _Newline extends AlgCommon {
|
|
|
233
238
|
invert() {
|
|
234
239
|
return this;
|
|
235
240
|
}
|
|
236
|
-
*experimentalExpand(_iterDir =
|
|
241
|
+
*experimentalExpand(_iterDir = IterationDirection.Forwards, _depth = Infinity) {
|
|
237
242
|
yield this;
|
|
238
243
|
}
|
|
239
244
|
};
|
|
@@ -251,7 +256,7 @@ var Pause = class _Pause extends AlgCommon {
|
|
|
251
256
|
invert() {
|
|
252
257
|
return this;
|
|
253
258
|
}
|
|
254
|
-
*experimentalExpand(_iterDir =
|
|
259
|
+
*experimentalExpand(_iterDir = IterationDirection.Forwards, _depth = Infinity) {
|
|
255
260
|
yield this;
|
|
256
261
|
}
|
|
257
262
|
};
|
|
@@ -815,8 +820,8 @@ var Move = class _Move extends AlgCommon {
|
|
|
815
820
|
)
|
|
816
821
|
);
|
|
817
822
|
}
|
|
818
|
-
*experimentalExpand(iterDir =
|
|
819
|
-
if (iterDir ===
|
|
823
|
+
*experimentalExpand(iterDir = IterationDirection.Forwards) {
|
|
824
|
+
if (iterDir === IterationDirection.Forwards) {
|
|
820
825
|
yield this;
|
|
821
826
|
} else {
|
|
822
827
|
yield this.modified({
|
|
@@ -963,10 +968,10 @@ var Grouping = class _Grouping extends AlgCommon {
|
|
|
963
968
|
-this.#quantumWithAmount.amount
|
|
964
969
|
);
|
|
965
970
|
}
|
|
966
|
-
*experimentalExpand(iterDir =
|
|
971
|
+
*experimentalExpand(iterDir = IterationDirection.Forwards, depth) {
|
|
967
972
|
depth ??= Infinity;
|
|
968
973
|
if (depth === 0) {
|
|
969
|
-
yield iterDir ===
|
|
974
|
+
yield iterDir === IterationDirection.Forwards ? this : this.invert();
|
|
970
975
|
} else {
|
|
971
976
|
yield* this.#quantumWithAmount.experimentalExpand(iterDir, depth - 1);
|
|
972
977
|
}
|
|
@@ -1013,10 +1018,10 @@ function experimentalIsAlgNode(v) {
|
|
|
1013
1018
|
// src/cubing/alg/simplify/options.ts
|
|
1014
1019
|
var DEFAULT_DIRECTIONAL = "any-direction";
|
|
1015
1020
|
var AppendOptionsHelper = class {
|
|
1021
|
+
config;
|
|
1016
1022
|
constructor(config = {}) {
|
|
1017
1023
|
this.config = config;
|
|
1018
1024
|
}
|
|
1019
|
-
config;
|
|
1020
1025
|
cancelQuantum() {
|
|
1021
1026
|
const { cancel } = this.config;
|
|
1022
1027
|
if (cancel === true) {
|
|
@@ -1447,7 +1452,7 @@ var Alg = class _Alg extends AlgCommon {
|
|
|
1447
1452
|
return new _Alg(reverse(Array.from(this.#algNodes).map((u) => u.invert())));
|
|
1448
1453
|
}
|
|
1449
1454
|
/** @deprecated Use {@link Alg.expand} instead. */
|
|
1450
|
-
*experimentalExpand(iterDir =
|
|
1455
|
+
*experimentalExpand(iterDir = IterationDirection.Forwards, depth) {
|
|
1451
1456
|
depth ??= Infinity;
|
|
1452
1457
|
for (const algNode of direct(this.#algNodes, iterDir)) {
|
|
1453
1458
|
yield* algNode.experimentalExpand(iterDir, depth);
|
|
@@ -1474,7 +1479,7 @@ var Alg = class _Alg extends AlgCommon {
|
|
|
1474
1479
|
expand(options) {
|
|
1475
1480
|
return new _Alg(
|
|
1476
1481
|
this.experimentalExpand(
|
|
1477
|
-
|
|
1482
|
+
IterationDirection.Forwards,
|
|
1478
1483
|
options?.depth ?? Infinity
|
|
1479
1484
|
)
|
|
1480
1485
|
);
|
|
@@ -1848,6 +1853,7 @@ function experimentalAlgCubingNetLink(options) {
|
|
|
1848
1853
|
}
|
|
1849
1854
|
|
|
1850
1855
|
export {
|
|
1856
|
+
IterationDirection,
|
|
1851
1857
|
direct,
|
|
1852
1858
|
directedGenerator,
|
|
1853
1859
|
Commutator,
|
|
@@ -1873,4 +1879,4 @@ export {
|
|
|
1873
1879
|
keyToMove,
|
|
1874
1880
|
experimentalAlgCubingNetLink
|
|
1875
1881
|
};
|
|
1876
|
-
//# sourceMappingURL=chunk-
|
|
1882
|
+
//# sourceMappingURL=chunk-YFNXHRNE.js.map
|