@cubingcenter/scrambler 0.1.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/README.md +169 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +10 -0
- package/dist/cli/run.d.ts +9 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +139 -0
- package/dist/core/api.d.ts +19 -0
- package/dist/core/api.d.ts.map +1 -0
- package/dist/core/api.js +94 -0
- package/dist/core/errors.d.ts +21 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +34 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +3 -0
- package/dist/core/registry.d.ts +10 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +35 -0
- package/dist/core/types.d.ts +34 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/puzzles/clock/index.d.ts +2 -0
- package/dist/puzzles/clock/index.d.ts.map +1 -0
- package/dist/puzzles/clock/index.js +1 -0
- package/dist/puzzles/clock/scrambler.d.ts +4 -0
- package/dist/puzzles/clock/scrambler.d.ts.map +1 -0
- package/dist/puzzles/clock/scrambler.js +50 -0
- package/dist/puzzles/cube2/facelets.d.ts +5 -0
- package/dist/puzzles/cube2/facelets.d.ts.map +1 -0
- package/dist/puzzles/cube2/facelets.js +53 -0
- package/dist/puzzles/cube2/index.d.ts +10 -0
- package/dist/puzzles/cube2/index.d.ts.map +1 -0
- package/dist/puzzles/cube2/index.js +8 -0
- package/dist/puzzles/cube2/moves.d.ts +9 -0
- package/dist/puzzles/cube2/moves.d.ts.map +1 -0
- package/dist/puzzles/cube2/moves.js +79 -0
- package/dist/puzzles/cube2/random-state.d.ts +3 -0
- package/dist/puzzles/cube2/random-state.d.ts.map +1 -0
- package/dist/puzzles/cube2/random-state.js +51 -0
- package/dist/puzzles/cube2/scrambler.d.ts +6 -0
- package/dist/puzzles/cube2/scrambler.d.ts.map +1 -0
- package/dist/puzzles/cube2/scrambler.js +54 -0
- package/dist/puzzles/cube2/solver/browser-loader.d.ts +12 -0
- package/dist/puzzles/cube2/solver/browser-loader.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/browser-loader.js +80 -0
- package/dist/puzzles/cube2/solver/generated/distances.bin +1 -0
- package/dist/puzzles/cube2/solver/generated/manifest.json +21 -0
- package/dist/puzzles/cube2/solver/generated/orientation-distances.bin +0 -0
- package/dist/puzzles/cube2/solver/generated/orientation-table.bin +0 -0
- package/dist/puzzles/cube2/solver/generated/permutation-distances.bin +0 -0
- package/dist/puzzles/cube2/solver/generated/permutation-table.bin +0 -0
- package/dist/puzzles/cube2/solver/generated-assets.d.ts +6 -0
- package/dist/puzzles/cube2/solver/generated-assets.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/generated-assets.js +25 -0
- package/dist/puzzles/cube2/solver/index.d.ts +3 -0
- package/dist/puzzles/cube2/solver/index.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/index.js +1 -0
- package/dist/puzzles/cube2/solver/node-loader.d.ts +6 -0
- package/dist/puzzles/cube2/solver/node-loader.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/node-loader.js +83 -0
- package/dist/puzzles/cube2/solver/search.d.ts +8 -0
- package/dist/puzzles/cube2/solver/search.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/search.js +50 -0
- package/dist/puzzles/cube2/solver/table-metadata.d.ts +16 -0
- package/dist/puzzles/cube2/solver/table-metadata.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/table-metadata.js +15 -0
- package/dist/puzzles/cube2/solver/tables.d.ts +14 -0
- package/dist/puzzles/cube2/solver/tables.d.ts.map +1 -0
- package/dist/puzzles/cube2/solver/tables.js +82 -0
- package/dist/puzzles/cube2/state.d.ts +6 -0
- package/dist/puzzles/cube2/state.d.ts.map +1 -0
- package/dist/puzzles/cube2/state.js +30 -0
- package/dist/puzzles/cube2/types.d.ts +23 -0
- package/dist/puzzles/cube2/types.d.ts.map +1 -0
- package/dist/puzzles/cube2/types.js +21 -0
- package/dist/puzzles/cube2/validation.d.ts +6 -0
- package/dist/puzzles/cube2/validation.d.ts.map +1 -0
- package/dist/puzzles/cube2/validation.js +72 -0
- package/dist/puzzles/cube3/facelets.d.ts +5 -0
- package/dist/puzzles/cube3/facelets.d.ts.map +1 -0
- package/dist/puzzles/cube3/facelets.js +89 -0
- package/dist/puzzles/cube3/index.d.ts +10 -0
- package/dist/puzzles/cube3/index.d.ts.map +1 -0
- package/dist/puzzles/cube3/index.js +8 -0
- package/dist/puzzles/cube3/moves.d.ts +9 -0
- package/dist/puzzles/cube3/moves.d.ts.map +1 -0
- package/dist/puzzles/cube3/moves.js +210 -0
- package/dist/puzzles/cube3/random-state.d.ts +3 -0
- package/dist/puzzles/cube3/random-state.d.ts.map +1 -0
- package/dist/puzzles/cube3/random-state.js +59 -0
- package/dist/puzzles/cube3/scrambler.d.ts +6 -0
- package/dist/puzzles/cube3/scrambler.d.ts.map +1 -0
- package/dist/puzzles/cube3/scrambler.js +59 -0
- package/dist/puzzles/cube3/solver/browser-loader.d.ts +5 -0
- package/dist/puzzles/cube3/solver/browser-loader.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/browser-loader.js +134 -0
- package/dist/puzzles/cube3/solver/browser-worker-pool.d.ts +31 -0
- package/dist/puzzles/cube3/solver/browser-worker-pool.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/browser-worker-pool.js +118 -0
- package/dist/puzzles/cube3/solver/browser-worker.d.ts +2 -0
- package/dist/puzzles/cube3/solver/browser-worker.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/browser-worker.js +71 -0
- package/dist/puzzles/cube3/solver/coordinates.d.ts +34 -0
- package/dist/puzzles/cube3/solver/coordinates.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/coordinates.js +266 -0
- package/dist/puzzles/cube3/solver/generated/manifest.json +404 -0
- package/dist/puzzles/cube3/solver/generated/move-cornerOrientation.bin +0 -0
- package/dist/puzzles/cube3/solver/generated/move-cornerPermutation.bin +0 -0
- package/dist/puzzles/cube3/solver/generated/move-edgeOrientation.bin +0 -0
- package/dist/puzzles/cube3/solver/generated/move-slicePermutation.bin +0 -0
- package/dist/puzzles/cube3/solver/generated/move-udEdgePermutation.bin +0 -0
- package/dist/puzzles/cube3/solver/generated/move-udSlice.bin +0 -0
- package/dist/puzzles/cube3/solver/generated/pruning-cornerOrientation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-cornerOrientationEdgeOrientation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-cornerPermutation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-cornerPermutationSlicePermutation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-edgeOrientation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-slicePermutation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-udEdgePermutation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-udEdgePermutationSlicePermutation.bin +1 -0
- package/dist/puzzles/cube3/solver/generated/pruning-udSlice.bin +0 -0
- package/dist/puzzles/cube3/solver/generated-assets.d.ts +5 -0
- package/dist/puzzles/cube3/solver/generated-assets.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/generated-assets.js +60 -0
- package/dist/puzzles/cube3/solver/index.d.ts +10 -0
- package/dist/puzzles/cube3/solver/index.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/index.js +5 -0
- package/dist/puzzles/cube3/solver/node-loader.d.ts +3 -0
- package/dist/puzzles/cube3/solver/node-loader.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/node-loader.js +120 -0
- package/dist/puzzles/cube3/solver/phase1.d.ts +28 -0
- package/dist/puzzles/cube3/solver/phase1.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/phase1.js +150 -0
- package/dist/puzzles/cube3/solver/phase2.d.ts +44 -0
- package/dist/puzzles/cube3/solver/phase2.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/phase2.js +270 -0
- package/dist/puzzles/cube3/solver/search-utils.d.ts +9 -0
- package/dist/puzzles/cube3/solver/search-utils.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/search-utils.js +41 -0
- package/dist/puzzles/cube3/solver/table-metadata.d.ts +97 -0
- package/dist/puzzles/cube3/solver/table-metadata.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/table-metadata.js +21 -0
- package/dist/puzzles/cube3/solver/tables.d.ts +72 -0
- package/dist/puzzles/cube3/solver/tables.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/tables.js +202 -0
- package/dist/puzzles/cube3/solver/worker-pool.d.ts +18 -0
- package/dist/puzzles/cube3/solver/worker-pool.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/worker-pool.js +116 -0
- package/dist/puzzles/cube3/solver/worker.d.ts +2 -0
- package/dist/puzzles/cube3/solver/worker.d.ts.map +1 -0
- package/dist/puzzles/cube3/solver/worker.js +73 -0
- package/dist/puzzles/cube3/state.d.ts +6 -0
- package/dist/puzzles/cube3/state.d.ts.map +1 -0
- package/dist/puzzles/cube3/state.js +40 -0
- package/dist/puzzles/cube3/subset-state.d.ts +4 -0
- package/dist/puzzles/cube3/subset-state.d.ts.map +1 -0
- package/dist/puzzles/cube3/subset-state.js +163 -0
- package/dist/puzzles/cube3/types.d.ts +29 -0
- package/dist/puzzles/cube3/types.d.ts.map +1 -0
- package/dist/puzzles/cube3/types.js +22 -0
- package/dist/puzzles/cube3/validation.d.ts +6 -0
- package/dist/puzzles/cube3/validation.d.ts.map +1 -0
- package/dist/puzzles/cube3/validation.js +83 -0
- package/dist/puzzles/cube4/facelets.d.ts +5 -0
- package/dist/puzzles/cube4/facelets.d.ts.map +1 -0
- package/dist/puzzles/cube4/facelets.js +135 -0
- package/dist/puzzles/cube4/index.d.ts +7 -0
- package/dist/puzzles/cube4/index.d.ts.map +1 -0
- package/dist/puzzles/cube4/index.js +8 -0
- package/dist/puzzles/cube4/moves.d.ts +37 -0
- package/dist/puzzles/cube4/moves.d.ts.map +1 -0
- package/dist/puzzles/cube4/moves.js +243 -0
- package/dist/puzzles/cube4/scrambler.d.ts +4 -0
- package/dist/puzzles/cube4/scrambler.d.ts.map +1 -0
- package/dist/puzzles/cube4/scrambler.js +98 -0
- package/dist/puzzles/cube4/state.d.ts +16 -0
- package/dist/puzzles/cube4/state.d.ts.map +1 -0
- package/dist/puzzles/cube4/state.js +84 -0
- package/dist/puzzles/cube4/types.d.ts +76 -0
- package/dist/puzzles/cube4/types.d.ts.map +1 -0
- package/dist/puzzles/cube4/types.js +62 -0
- package/dist/puzzles/cube5x5/index.d.ts +4 -0
- package/dist/puzzles/cube5x5/index.d.ts.map +1 -0
- package/dist/puzzles/cube5x5/index.js +2 -0
- package/dist/puzzles/cube5x5/scrambler.d.ts +4 -0
- package/dist/puzzles/cube5x5/scrambler.d.ts.map +1 -0
- package/dist/puzzles/cube5x5/scrambler.js +93 -0
- package/dist/puzzles/cube5x5/types.d.ts +4 -0
- package/dist/puzzles/cube5x5/types.d.ts.map +1 -0
- package/dist/puzzles/cube5x5/types.js +4 -0
- package/dist/puzzles/cube6x6/index.d.ts +4 -0
- package/dist/puzzles/cube6x6/index.d.ts.map +1 -0
- package/dist/puzzles/cube6x6/index.js +2 -0
- package/dist/puzzles/cube6x6/scrambler.d.ts +4 -0
- package/dist/puzzles/cube6x6/scrambler.d.ts.map +1 -0
- package/dist/puzzles/cube6x6/scrambler.js +105 -0
- package/dist/puzzles/cube6x6/types.d.ts +4 -0
- package/dist/puzzles/cube6x6/types.d.ts.map +1 -0
- package/dist/puzzles/cube6x6/types.js +8 -0
- package/dist/puzzles/cube7x7/index.d.ts +4 -0
- package/dist/puzzles/cube7x7/index.d.ts.map +1 -0
- package/dist/puzzles/cube7x7/index.js +2 -0
- package/dist/puzzles/cube7x7/scrambler.d.ts +4 -0
- package/dist/puzzles/cube7x7/scrambler.d.ts.map +1 -0
- package/dist/puzzles/cube7x7/scrambler.js +93 -0
- package/dist/puzzles/cube7x7/types.d.ts +4 -0
- package/dist/puzzles/cube7x7/types.d.ts.map +1 -0
- package/dist/puzzles/cube7x7/types.js +8 -0
- package/dist/puzzles/index.d.ts +10 -0
- package/dist/puzzles/index.d.ts.map +1 -0
- package/dist/puzzles/index.js +28 -0
- package/dist/puzzles/megaminx/index.d.ts +4 -0
- package/dist/puzzles/megaminx/index.d.ts.map +1 -0
- package/dist/puzzles/megaminx/index.js +2 -0
- package/dist/puzzles/megaminx/scrambler.d.ts +4 -0
- package/dist/puzzles/megaminx/scrambler.d.ts.map +1 -0
- package/dist/puzzles/megaminx/scrambler.js +56 -0
- package/dist/puzzles/megaminx/types.d.ts +6 -0
- package/dist/puzzles/megaminx/types.d.ts.map +1 -0
- package/dist/puzzles/megaminx/types.js +4 -0
- package/dist/puzzles/pyraminx/index.d.ts +9 -0
- package/dist/puzzles/pyraminx/index.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/index.js +7 -0
- package/dist/puzzles/pyraminx/moves.d.ts +9 -0
- package/dist/puzzles/pyraminx/moves.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/moves.js +117 -0
- package/dist/puzzles/pyraminx/random-state.d.ts +3 -0
- package/dist/puzzles/pyraminx/random-state.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/random-state.js +53 -0
- package/dist/puzzles/pyraminx/scrambler.d.ts +6 -0
- package/dist/puzzles/pyraminx/scrambler.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/scrambler.js +56 -0
- package/dist/puzzles/pyraminx/solver.d.ts +10 -0
- package/dist/puzzles/pyraminx/solver.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/solver.js +160 -0
- package/dist/puzzles/pyraminx/state.d.ts +6 -0
- package/dist/puzzles/pyraminx/state.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/state.js +32 -0
- package/dist/puzzles/pyraminx/types.d.ts +17 -0
- package/dist/puzzles/pyraminx/types.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/types.js +7 -0
- package/dist/puzzles/pyraminx/validation.d.ts +8 -0
- package/dist/puzzles/pyraminx/validation.d.ts.map +1 -0
- package/dist/puzzles/pyraminx/validation.js +79 -0
- package/dist/random/index.d.ts +3 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/random/index.js +1 -0
- package/dist/random/prng.d.ts +7 -0
- package/dist/random/prng.d.ts.map +1 -0
- package/dist/random/prng.js +60 -0
- package/dist-cjs/cli/index.js +12 -0
- package/dist-cjs/cli/run.js +142 -0
- package/dist-cjs/core/api.js +102 -0
- package/dist-cjs/core/errors.js +42 -0
- package/dist-cjs/core/index.js +19 -0
- package/dist-cjs/core/registry.js +39 -0
- package/dist-cjs/core/types.js +2 -0
- package/dist-cjs/index.js +19 -0
- package/dist-cjs/package.json +3 -0
- package/dist-cjs/puzzles/clock/index.js +6 -0
- package/dist-cjs/puzzles/clock/scrambler.js +54 -0
- package/dist-cjs/puzzles/cube2/facelets.js +58 -0
- package/dist-cjs/puzzles/cube2/index.js +67 -0
- package/dist-cjs/puzzles/cube2/moves.js +88 -0
- package/dist-cjs/puzzles/cube2/random-state.js +54 -0
- package/dist-cjs/puzzles/cube2/scrambler.js +58 -0
- package/dist-cjs/puzzles/cube2/solver/browser-loader.js +85 -0
- package/dist-cjs/puzzles/cube2/solver/generated/distances.bin +1 -0
- package/dist-cjs/puzzles/cube2/solver/generated/manifest.json +21 -0
- package/dist-cjs/puzzles/cube2/solver/generated/orientation-distances.bin +0 -0
- package/dist-cjs/puzzles/cube2/solver/generated/orientation-table.bin +0 -0
- package/dist-cjs/puzzles/cube2/solver/generated/permutation-distances.bin +0 -0
- package/dist-cjs/puzzles/cube2/solver/generated/permutation-table.bin +0 -0
- package/dist-cjs/puzzles/cube2/solver/generated-assets.js +61 -0
- package/dist-cjs/puzzles/cube2/solver/index.js +5 -0
- package/dist-cjs/puzzles/cube2/solver/node-loader.js +89 -0
- package/dist-cjs/puzzles/cube2/solver/search.js +53 -0
- package/dist-cjs/puzzles/cube2/solver/table-metadata.js +18 -0
- package/dist-cjs/puzzles/cube2/solver/tables.js +91 -0
- package/dist-cjs/puzzles/cube2/state.js +36 -0
- package/dist-cjs/puzzles/cube2/types.js +24 -0
- package/dist-cjs/puzzles/cube2/validation.js +78 -0
- package/dist-cjs/puzzles/cube3/facelets.js +94 -0
- package/dist-cjs/puzzles/cube3/index.js +68 -0
- package/dist-cjs/puzzles/cube3/moves.js +219 -0
- package/dist-cjs/puzzles/cube3/random-state.js +62 -0
- package/dist-cjs/puzzles/cube3/scrambler.js +63 -0
- package/dist-cjs/puzzles/cube3/solver/browser-loader.js +139 -0
- package/dist-cjs/puzzles/cube3/solver/coordinates.js +285 -0
- package/dist-cjs/puzzles/cube3/solver/generated/manifest.json +404 -0
- package/dist-cjs/puzzles/cube3/solver/generated/move-cornerOrientation.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated/move-cornerPermutation.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated/move-edgeOrientation.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated/move-slicePermutation.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated/move-udEdgePermutation.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated/move-udSlice.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-cornerOrientation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-cornerOrientationEdgeOrientation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-cornerPermutation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-cornerPermutationSlicePermutation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-edgeOrientation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-slicePermutation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-udEdgePermutation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-udEdgePermutationSlicePermutation.bin +1 -0
- package/dist-cjs/puzzles/cube3/solver/generated/pruning-udSlice.bin +0 -0
- package/dist-cjs/puzzles/cube3/solver/generated-assets.js +98 -0
- package/dist-cjs/puzzles/cube3/solver/index.js +49 -0
- package/dist-cjs/puzzles/cube3/solver/node-loader.js +126 -0
- package/dist-cjs/puzzles/cube3/solver/phase1.js +158 -0
- package/dist-cjs/puzzles/cube3/solver/phase2.js +279 -0
- package/dist-cjs/puzzles/cube3/solver/search-utils.js +49 -0
- package/dist-cjs/puzzles/cube3/solver/table-metadata.js +24 -0
- package/dist-cjs/puzzles/cube3/solver/tables.js +216 -0
- package/dist-cjs/puzzles/cube3/state.js +46 -0
- package/dist-cjs/puzzles/cube3/subset-state.js +166 -0
- package/dist-cjs/puzzles/cube3/types.js +25 -0
- package/dist-cjs/puzzles/cube3/validation.js +89 -0
- package/dist-cjs/puzzles/cube4/facelets.js +140 -0
- package/dist-cjs/puzzles/cube4/index.js +45 -0
- package/dist-cjs/puzzles/cube4/moves.js +251 -0
- package/dist-cjs/puzzles/cube4/scrambler.js +135 -0
- package/dist-cjs/puzzles/cube4/state.js +92 -0
- package/dist-cjs/puzzles/cube4/types.js +65 -0
- package/dist-cjs/puzzles/cube5x5/index.js +9 -0
- package/dist-cjs/puzzles/cube5x5/scrambler.js +97 -0
- package/dist-cjs/puzzles/cube5x5/types.js +7 -0
- package/dist-cjs/puzzles/cube6x6/index.js +9 -0
- package/dist-cjs/puzzles/cube6x6/scrambler.js +109 -0
- package/dist-cjs/puzzles/cube6x6/types.js +11 -0
- package/dist-cjs/puzzles/cube7x7/index.js +9 -0
- package/dist-cjs/puzzles/cube7x7/scrambler.js +97 -0
- package/dist-cjs/puzzles/cube7x7/types.js +11 -0
- package/dist-cjs/puzzles/index.js +64 -0
- package/dist-cjs/puzzles/megaminx/index.js +11 -0
- package/dist-cjs/puzzles/megaminx/scrambler.js +60 -0
- package/dist-cjs/puzzles/megaminx/types.js +7 -0
- package/dist-cjs/puzzles/pyraminx/index.js +30 -0
- package/dist-cjs/puzzles/pyraminx/moves.js +126 -0
- package/dist-cjs/puzzles/pyraminx/random-state.js +56 -0
- package/dist-cjs/puzzles/pyraminx/scrambler.js +60 -0
- package/dist-cjs/puzzles/pyraminx/solver.js +170 -0
- package/dist-cjs/puzzles/pyraminx/state.js +38 -0
- package/dist-cjs/puzzles/pyraminx/types.js +10 -0
- package/dist-cjs/puzzles/pyraminx/validation.js +84 -0
- package/dist-cjs/random/index.js +5 -0
- package/dist-cjs/random/prng.js +63 -0
- package/docs/cubingcenter-integration.md +69 -0
- package/docs/development.md +44 -0
- package/docs/facelets.md +64 -0
- package/docs/getting-started.md +73 -0
- package/examples/cli-json.md +30 -0
- package/examples/commonjs.cjs +11 -0
- package/examples/esm.mjs +9 -0
- package/examples/timer-preview.mjs +29 -0
- package/package.json +53 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyCube3Move = applyCube3Move;
|
|
4
|
+
exports.applyCube3Algorithm = applyCube3Algorithm;
|
|
5
|
+
exports.invertCube3Algorithm = invertCube3Algorithm;
|
|
6
|
+
exports.parseCube3Algorithm = parseCube3Algorithm;
|
|
7
|
+
exports.formatCube3Algorithm = formatCube3Algorithm;
|
|
8
|
+
exports.parseCube3Move = parseCube3Move;
|
|
9
|
+
exports.invertCube3Move = invertCube3Move;
|
|
10
|
+
const types_js_1 = require("./types.js");
|
|
11
|
+
const state_js_1 = require("./state.js");
|
|
12
|
+
const FACE_MOVE_TABLES = {
|
|
13
|
+
U: {
|
|
14
|
+
corners: { permutation: [3, 0, 1, 2, 4, 5, 6, 7], orientation: [0, 0, 0, 0, 0, 0, 0, 0] },
|
|
15
|
+
edges: { permutation: [3, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11], orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
|
|
16
|
+
},
|
|
17
|
+
D: {
|
|
18
|
+
corners: { permutation: [0, 1, 2, 3, 5, 6, 7, 4], orientation: [0, 0, 0, 0, 0, 0, 0, 0] },
|
|
19
|
+
edges: { permutation: [0, 1, 2, 3, 5, 6, 7, 4, 8, 9, 10, 11], orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
|
|
20
|
+
},
|
|
21
|
+
R: {
|
|
22
|
+
corners: { permutation: [4, 1, 2, 0, 7, 5, 6, 3], orientation: [2, 0, 0, 1, 1, 0, 0, 2] },
|
|
23
|
+
edges: { permutation: [8, 1, 2, 3, 11, 5, 6, 7, 4, 9, 10, 0], orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
|
|
24
|
+
},
|
|
25
|
+
L: {
|
|
26
|
+
corners: { permutation: [0, 2, 6, 3, 4, 1, 5, 7], orientation: [0, 1, 2, 0, 0, 2, 1, 0] },
|
|
27
|
+
edges: { permutation: [0, 1, 10, 3, 4, 5, 9, 7, 8, 2, 6, 11], orientation: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }
|
|
28
|
+
},
|
|
29
|
+
F: {
|
|
30
|
+
corners: { permutation: [1, 5, 2, 3, 0, 4, 6, 7], orientation: [1, 2, 0, 0, 2, 1, 0, 0] },
|
|
31
|
+
edges: { permutation: [0, 9, 2, 3, 4, 8, 6, 7, 1, 5, 10, 11], orientation: [0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0] }
|
|
32
|
+
},
|
|
33
|
+
B: {
|
|
34
|
+
corners: { permutation: [0, 1, 3, 7, 4, 5, 2, 6], orientation: [0, 0, 1, 2, 0, 0, 2, 1] },
|
|
35
|
+
edges: { permutation: [0, 1, 2, 11, 4, 5, 6, 10, 8, 9, 3, 7], orientation: [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1] }
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
function applyCube3Move(state, move) {
|
|
39
|
+
const { face, turns } = parseMoveParts(move);
|
|
40
|
+
let next = (0, state_js_1.cloneCube3State)(state);
|
|
41
|
+
for (let index = 0; index < turns; index += 1) {
|
|
42
|
+
next = applyFaceMove(next, FACE_MOVE_TABLES[face]);
|
|
43
|
+
}
|
|
44
|
+
return next;
|
|
45
|
+
}
|
|
46
|
+
function applyCube3Algorithm(state, moves) {
|
|
47
|
+
return moves.reduce((current, move) => applyCube3Move(current, move), state);
|
|
48
|
+
}
|
|
49
|
+
function invertCube3Algorithm(moves) {
|
|
50
|
+
return [...moves].reverse().map(invertCube3Move);
|
|
51
|
+
}
|
|
52
|
+
function parseCube3Algorithm(algorithm) {
|
|
53
|
+
const trimmed = algorithm.trim();
|
|
54
|
+
if (trimmed.length === 0) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
const faces = { U: 'U', D: 'D', R: 'R', L: 'L', F: 'F', B: 'B' };
|
|
58
|
+
const rotateX = (times) => {
|
|
59
|
+
for (let i = 0; i < times; i++) {
|
|
60
|
+
const tempU = faces.U, tempF = faces.F, tempD = faces.D, tempB = faces.B;
|
|
61
|
+
faces.U = tempF;
|
|
62
|
+
faces.F = tempD;
|
|
63
|
+
faces.D = tempB;
|
|
64
|
+
faces.B = tempU;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const rotateY = (times) => {
|
|
68
|
+
for (let i = 0; i < times; i++) {
|
|
69
|
+
const tempF = faces.F, tempL = faces.L, tempB = faces.B, tempR = faces.R;
|
|
70
|
+
faces.F = tempR;
|
|
71
|
+
faces.R = tempB;
|
|
72
|
+
faces.B = tempL;
|
|
73
|
+
faces.L = tempF;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const rotateZ = (times) => {
|
|
77
|
+
for (let i = 0; i < times; i++) {
|
|
78
|
+
const tempU = faces.U, tempR = faces.R, tempD = faces.D, tempL = faces.L;
|
|
79
|
+
faces.U = tempL;
|
|
80
|
+
faces.L = tempD;
|
|
81
|
+
faces.D = tempR;
|
|
82
|
+
faces.R = tempU;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const result = [];
|
|
86
|
+
const tokens = trimmed.split(/\s+/).filter(Boolean);
|
|
87
|
+
for (const token of tokens) {
|
|
88
|
+
const base = token[0];
|
|
89
|
+
if (!base)
|
|
90
|
+
continue;
|
|
91
|
+
let isWide = false;
|
|
92
|
+
let isPrime = false;
|
|
93
|
+
let isDouble = false;
|
|
94
|
+
let moveName = base;
|
|
95
|
+
if (token.length > 1) {
|
|
96
|
+
if (token.includes('w')) {
|
|
97
|
+
isWide = true;
|
|
98
|
+
moveName = base.toUpperCase();
|
|
99
|
+
}
|
|
100
|
+
if (token.includes("'"))
|
|
101
|
+
isPrime = true;
|
|
102
|
+
if (token.includes("2"))
|
|
103
|
+
isDouble = true;
|
|
104
|
+
}
|
|
105
|
+
if (base >= 'a' && base <= 'z' && base !== 'x' && base !== 'y' && base !== 'z') {
|
|
106
|
+
isWide = true;
|
|
107
|
+
moveName = base.toUpperCase();
|
|
108
|
+
}
|
|
109
|
+
const suffix = isDouble ? "2" : isPrime ? "'" : "";
|
|
110
|
+
const oppSuffix = isDouble ? "2" : isPrime ? "" : "'";
|
|
111
|
+
const times = isDouble ? 2 : isPrime ? 3 : 1;
|
|
112
|
+
const emit = (f, suff) => result.push(`${faces[f]}${suff}`);
|
|
113
|
+
switch (moveName) {
|
|
114
|
+
case 'U':
|
|
115
|
+
case 'D':
|
|
116
|
+
case 'R':
|
|
117
|
+
case 'L':
|
|
118
|
+
case 'F':
|
|
119
|
+
case 'B':
|
|
120
|
+
if (isWide) {
|
|
121
|
+
if (moveName === 'R') {
|
|
122
|
+
emit('R', suffix);
|
|
123
|
+
emit('L', oppSuffix);
|
|
124
|
+
rotateX(times);
|
|
125
|
+
}
|
|
126
|
+
else if (moveName === 'L') {
|
|
127
|
+
emit('L', suffix);
|
|
128
|
+
emit('R', oppSuffix);
|
|
129
|
+
rotateX((4 - times) % 4);
|
|
130
|
+
}
|
|
131
|
+
else if (moveName === 'U') {
|
|
132
|
+
emit('U', suffix);
|
|
133
|
+
emit('D', oppSuffix);
|
|
134
|
+
rotateY(times);
|
|
135
|
+
}
|
|
136
|
+
else if (moveName === 'D') {
|
|
137
|
+
emit('D', suffix);
|
|
138
|
+
emit('U', oppSuffix);
|
|
139
|
+
rotateY((4 - times) % 4);
|
|
140
|
+
}
|
|
141
|
+
else if (moveName === 'F') {
|
|
142
|
+
emit('F', suffix);
|
|
143
|
+
emit('B', oppSuffix);
|
|
144
|
+
rotateZ(times);
|
|
145
|
+
}
|
|
146
|
+
else if (moveName === 'B') {
|
|
147
|
+
emit('B', suffix);
|
|
148
|
+
emit('F', oppSuffix);
|
|
149
|
+
rotateZ((4 - times) % 4);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
emit(moveName, suffix);
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case 'M':
|
|
157
|
+
emit('L', suffix);
|
|
158
|
+
emit('R', oppSuffix);
|
|
159
|
+
rotateX((4 - times) % 4);
|
|
160
|
+
break;
|
|
161
|
+
case 'E':
|
|
162
|
+
emit('D', suffix);
|
|
163
|
+
emit('U', oppSuffix);
|
|
164
|
+
rotateY((4 - times) % 4);
|
|
165
|
+
break;
|
|
166
|
+
case 'S':
|
|
167
|
+
emit('F', suffix);
|
|
168
|
+
emit('B', oppSuffix);
|
|
169
|
+
rotateZ(times);
|
|
170
|
+
break;
|
|
171
|
+
case 'x':
|
|
172
|
+
rotateX(times);
|
|
173
|
+
break;
|
|
174
|
+
case 'y':
|
|
175
|
+
rotateY(times);
|
|
176
|
+
break;
|
|
177
|
+
case 'z':
|
|
178
|
+
rotateZ(times);
|
|
179
|
+
break;
|
|
180
|
+
default:
|
|
181
|
+
throw new Error(`Invalid 3x3 move: ${token}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
function formatCube3Algorithm(moves) {
|
|
187
|
+
return moves.join(" ");
|
|
188
|
+
}
|
|
189
|
+
function parseCube3Move(value) {
|
|
190
|
+
if (types_js_1.CUBE3_MOVES.includes(value)) {
|
|
191
|
+
return value;
|
|
192
|
+
}
|
|
193
|
+
throw new Error(`Invalid 3x3 move: ${value}`);
|
|
194
|
+
}
|
|
195
|
+
function invertCube3Move(move) {
|
|
196
|
+
const { face, suffix } = parseMoveParts(move);
|
|
197
|
+
if (suffix === "2") {
|
|
198
|
+
return move;
|
|
199
|
+
}
|
|
200
|
+
return `${face}${suffix === "'" ? "" : "'"}`;
|
|
201
|
+
}
|
|
202
|
+
function applyFaceMove(state, table) {
|
|
203
|
+
return {
|
|
204
|
+
corners: {
|
|
205
|
+
permutation: table.corners.permutation.map((source) => state.corners.permutation[source]),
|
|
206
|
+
orientation: table.corners.permutation.map((source, target) => ((state.corners.orientation[source] + table.corners.orientation[target]) % 3))
|
|
207
|
+
},
|
|
208
|
+
edges: {
|
|
209
|
+
permutation: table.edges.permutation.map((source) => state.edges.permutation[source]),
|
|
210
|
+
orientation: table.edges.permutation.map((source, target) => ((state.edges.orientation[source] + table.edges.orientation[target]) % 2))
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function parseMoveParts(move) {
|
|
215
|
+
const face = move[0];
|
|
216
|
+
const suffix = move.slice(1);
|
|
217
|
+
const turns = suffix === "2" ? 2 : suffix === "'" ? 3 : 1;
|
|
218
|
+
return { face, suffix, turns };
|
|
219
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateRandomCube3State = generateRandomCube3State;
|
|
4
|
+
const index_js_1 = require("../../random/index.js");
|
|
5
|
+
const types_js_1 = require("./types.js");
|
|
6
|
+
const validation_js_1 = require("./validation.js");
|
|
7
|
+
const subset_state_js_1 = require("./subset-state.js");
|
|
8
|
+
function generateRandomCube3State(options = {}) {
|
|
9
|
+
const random = (0, index_js_1.createRandomSource)(options.seed);
|
|
10
|
+
const rejectTrivial = options.rejectTrivial ?? true;
|
|
11
|
+
if (options.subset) {
|
|
12
|
+
return (0, subset_state_js_1.generateSubsetCube3State)(options.subset, random);
|
|
13
|
+
}
|
|
14
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
15
|
+
const state = createLegalRandomState(random);
|
|
16
|
+
if (!rejectTrivial || (0, validation_js_1.isAllowedRandomCube3State)(state)) {
|
|
17
|
+
return state;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
throw new Error("Unable to generate a non-trivial random 3x3 state.");
|
|
21
|
+
}
|
|
22
|
+
function createLegalRandomState(random) {
|
|
23
|
+
const cornerPermutation = shuffledRange(types_js_1.CORNER_COUNT, random);
|
|
24
|
+
const edgePermutation = shuffledRange(types_js_1.EDGE_COUNT, random);
|
|
25
|
+
if ((0, validation_js_1.permutationParity)(cornerPermutation) !== (0, validation_js_1.permutationParity)(edgePermutation)) {
|
|
26
|
+
swap(edgePermutation, 0, 1);
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
corners: {
|
|
30
|
+
permutation: cornerPermutation,
|
|
31
|
+
orientation: randomOrientations(types_js_1.CORNER_COUNT, 3, random)
|
|
32
|
+
},
|
|
33
|
+
edges: {
|
|
34
|
+
permutation: edgePermutation,
|
|
35
|
+
orientation: randomOrientations(types_js_1.EDGE_COUNT, 2, random)
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function shuffledRange(length, random) {
|
|
40
|
+
const values = Array.from({ length }, (_, index) => index);
|
|
41
|
+
for (let index = values.length - 1; index > 0; index -= 1) {
|
|
42
|
+
const swapIndex = random.nextInt(index + 1);
|
|
43
|
+
swap(values, index, swapIndex);
|
|
44
|
+
}
|
|
45
|
+
return values;
|
|
46
|
+
}
|
|
47
|
+
function randomOrientations(length, modulo, random) {
|
|
48
|
+
const orientations = Array(length).fill(0);
|
|
49
|
+
let total = 0;
|
|
50
|
+
for (let index = 0; index < length - 1; index += 1) {
|
|
51
|
+
const orientation = random.nextInt(modulo);
|
|
52
|
+
orientations[index] = orientation;
|
|
53
|
+
total += orientation;
|
|
54
|
+
}
|
|
55
|
+
orientations[length - 1] = (modulo - (total % modulo)) % modulo;
|
|
56
|
+
return orientations;
|
|
57
|
+
}
|
|
58
|
+
function swap(values, left, right) {
|
|
59
|
+
const temporary = values[left];
|
|
60
|
+
values[left] = values[right];
|
|
61
|
+
values[right] = temporary;
|
|
62
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.cube3ScrambleGenerator = void 0;
|
|
4
|
+
exports.generateCube3Scramble = generateCube3Scramble;
|
|
5
|
+
const moves_js_1 = require("./moves.js");
|
|
6
|
+
const random_state_js_1 = require("./random-state.js");
|
|
7
|
+
const state_js_1 = require("./state.js");
|
|
8
|
+
const facelets_js_1 = require("./facelets.js");
|
|
9
|
+
const index_js_1 = require("./solver/index.js");
|
|
10
|
+
exports.cube3ScrambleGenerator = {
|
|
11
|
+
info: {
|
|
12
|
+
eventId: "333",
|
|
13
|
+
name: "3x3x3 Cube",
|
|
14
|
+
puzzle: "cube-3x3",
|
|
15
|
+
quality: "random-state",
|
|
16
|
+
generator: "cube3-two-phase",
|
|
17
|
+
description: "Random-state 3x3 scramble generated by the CubingCenter two-phase solver."
|
|
18
|
+
},
|
|
19
|
+
generate(options = {}) {
|
|
20
|
+
return generateCube3Scramble(options);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
async function generateCube3Scramble(options = {}) {
|
|
24
|
+
const state = (0, random_state_js_1.generateRandomCube3State)(options);
|
|
25
|
+
const solution = await (0, index_js_1.solveCube3State)(state);
|
|
26
|
+
const scrambleMoves = (0, moves_js_1.invertCube3Algorithm)(solution.moves);
|
|
27
|
+
if (!options.skipValidation) {
|
|
28
|
+
const scrambledState = (0, moves_js_1.applyCube3Algorithm)((0, state_js_1.createSolvedCube3State)(), scrambleMoves);
|
|
29
|
+
if (!(0, state_js_1.cube3StatesEqual)(scrambledState, state)) {
|
|
30
|
+
throw new Error("Generated 3x3 scramble does not reproduce the target random state.");
|
|
31
|
+
}
|
|
32
|
+
if (!(0, state_js_1.isSolvedCube3State)(solution.state)) {
|
|
33
|
+
throw new Error("Generated 3x3 solution does not solve the target random state.");
|
|
34
|
+
}
|
|
35
|
+
if (scrambleMoves.length < 2) {
|
|
36
|
+
throw new Error("Generated 3x3 scramble is too short.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const facelets = (0, facelets_js_1.toCube3Facelets)(state);
|
|
40
|
+
const result = {
|
|
41
|
+
eventId: "333",
|
|
42
|
+
scramble: (0, moves_js_1.formatCube3Algorithm)(scrambleMoves),
|
|
43
|
+
moves: scrambleMoves,
|
|
44
|
+
quality: "random-state",
|
|
45
|
+
generator: "cube3-two-phase",
|
|
46
|
+
metadata: {
|
|
47
|
+
generator: "cube3-two-phase",
|
|
48
|
+
generatorVersion: "1.0.0",
|
|
49
|
+
faceletString: (0, facelets_js_1.formatCube3Facelets)(facelets),
|
|
50
|
+
state: JSON.parse(JSON.stringify(state)),
|
|
51
|
+
solutionMoves: solution.moves,
|
|
52
|
+
solutionDepth: solution.depth,
|
|
53
|
+
phase1Depth: solution.phase1.depth,
|
|
54
|
+
phase2Depth: solution.phase2.depth,
|
|
55
|
+
visitedNodes: solution.visitedNodes,
|
|
56
|
+
...options.metadata
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
if (options.seed !== undefined) {
|
|
60
|
+
result.seed = options.seed;
|
|
61
|
+
}
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCachedBrowserTables = getCachedBrowserTables;
|
|
4
|
+
exports.clearCachedBrowserTables = clearCachedBrowserTables;
|
|
5
|
+
exports.loadBrowserTables = loadBrowserTables;
|
|
6
|
+
let browserTables;
|
|
7
|
+
function resolveBaseUrl(provided) {
|
|
8
|
+
if (provided) {
|
|
9
|
+
return provided.replace(/\/$/, "");
|
|
10
|
+
}
|
|
11
|
+
if (typeof document !== "undefined") {
|
|
12
|
+
const script = document.currentScript;
|
|
13
|
+
if (script?.src) {
|
|
14
|
+
const base = new URL(".", script.src).href;
|
|
15
|
+
return base.replace(/\/$/, "");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return ".";
|
|
19
|
+
}
|
|
20
|
+
function getCachedBrowserTables() {
|
|
21
|
+
return browserTables;
|
|
22
|
+
}
|
|
23
|
+
function clearCachedBrowserTables() {
|
|
24
|
+
browserTables = undefined;
|
|
25
|
+
}
|
|
26
|
+
async function loadBrowserTables(baseUrl) {
|
|
27
|
+
if (browserTables) {
|
|
28
|
+
return browserTables;
|
|
29
|
+
}
|
|
30
|
+
const resolvedBase = resolveBaseUrl(baseUrl);
|
|
31
|
+
const manifest = await fetchManifest(resolvedBase);
|
|
32
|
+
browserTables = {
|
|
33
|
+
phase1Moves: manifest.phase1Moves,
|
|
34
|
+
phase2Moves: manifest.phase2Moves,
|
|
35
|
+
moveTables: {
|
|
36
|
+
cornerOrientation: await fetchMoveTable(resolvedBase, manifest.moveTables.cornerOrientation),
|
|
37
|
+
edgeOrientation: await fetchMoveTable(resolvedBase, manifest.moveTables.edgeOrientation),
|
|
38
|
+
udSlice: await fetchMoveTable(resolvedBase, manifest.moveTables.udSlice),
|
|
39
|
+
cornerPermutation: await fetchMoveTable(resolvedBase, manifest.moveTables.cornerPermutation),
|
|
40
|
+
udEdgePermutation: await fetchMoveTable(resolvedBase, manifest.moveTables.udEdgePermutation),
|
|
41
|
+
slicePermutation: await fetchMoveTable(resolvedBase, manifest.moveTables.slicePermutation)
|
|
42
|
+
},
|
|
43
|
+
pruningTables: {
|
|
44
|
+
cornerOrientation: await fetchPruningTable(resolvedBase, manifest.pruningTables.cornerOrientation),
|
|
45
|
+
edgeOrientation: await fetchPruningTable(resolvedBase, manifest.pruningTables.edgeOrientation),
|
|
46
|
+
udSlice: await fetchPruningTable(resolvedBase, manifest.pruningTables.udSlice),
|
|
47
|
+
cornerOrientationEdgeOrientation: await fetchPruningTable(resolvedBase, manifest.pruningTables.cornerOrientationEdgeOrientation),
|
|
48
|
+
cornerPermutation: await fetchPruningTable(resolvedBase, manifest.pruningTables.cornerPermutation),
|
|
49
|
+
udEdgePermutation: await fetchPruningTable(resolvedBase, manifest.pruningTables.udEdgePermutation),
|
|
50
|
+
slicePermutation: await fetchPruningTable(resolvedBase, manifest.pruningTables.slicePermutation),
|
|
51
|
+
cornerPermutationSlicePermutation: await fetchPruningTable(resolvedBase, manifest.pruningTables.cornerPermutationSlicePermutation),
|
|
52
|
+
udEdgePermutationSlicePermutation: await fetchPruningTable(resolvedBase, manifest.pruningTables.udEdgePermutationSlicePermutation)
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return browserTables;
|
|
56
|
+
}
|
|
57
|
+
const CACHE_NAME = "cubingcenter-scrambler-tables-v1";
|
|
58
|
+
async function cachedFetch(url) {
|
|
59
|
+
// Try Cache API first
|
|
60
|
+
if (typeof caches !== "undefined") {
|
|
61
|
+
try {
|
|
62
|
+
const cache = await caches.open(CACHE_NAME);
|
|
63
|
+
const cached = await cache.match(url);
|
|
64
|
+
if (cached) {
|
|
65
|
+
return cached.arrayBuffer();
|
|
66
|
+
}
|
|
67
|
+
const response = await fetch(url);
|
|
68
|
+
if (response.ok) {
|
|
69
|
+
// Clone before reading so we can store the clone
|
|
70
|
+
await cache.put(url, response.clone());
|
|
71
|
+
}
|
|
72
|
+
return response.arrayBuffer();
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// Cache API failed (e.g. quota exceeded, private mode) — fall through
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Fallback: plain fetch
|
|
79
|
+
const response = await fetch(url);
|
|
80
|
+
return response.arrayBuffer();
|
|
81
|
+
}
|
|
82
|
+
async function fetchManifest(baseUrl) {
|
|
83
|
+
const url = `${baseUrl}/puzzles/cube3/solver/generated/manifest.json`;
|
|
84
|
+
const response = await fetch(url);
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
throw new Error(`Failed to load solver table manifest from ${url}: ${response.status} ${response.statusText}`);
|
|
87
|
+
}
|
|
88
|
+
const manifest = await response.json();
|
|
89
|
+
if (manifest.version !== 1) {
|
|
90
|
+
throw new Error(`Unsupported 3x3 solver table manifest version: ${manifest.version}`);
|
|
91
|
+
}
|
|
92
|
+
return manifest;
|
|
93
|
+
}
|
|
94
|
+
async function fetchMoveTable(baseUrl, entry) {
|
|
95
|
+
const url = `${baseUrl}/puzzles/cube3/solver/generated/${entry.file}`;
|
|
96
|
+
const buffer = await cachedFetch(url);
|
|
97
|
+
const expectedBytes = entry.range * entry.moves.length * 4;
|
|
98
|
+
if (buffer.byteLength !== expectedBytes) {
|
|
99
|
+
throw new Error(`Invalid byte size for ${entry.coordinate} move table.`);
|
|
100
|
+
}
|
|
101
|
+
const values = new Int32Array(entry.range * entry.moves.length);
|
|
102
|
+
const view = new DataView(buffer);
|
|
103
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
104
|
+
values[index] = view.getInt32(index * 4, true);
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
coordinate: entry.coordinate,
|
|
108
|
+
moves: entry.moves,
|
|
109
|
+
range: entry.range,
|
|
110
|
+
solvedCoordinate: entry.solvedCoordinate,
|
|
111
|
+
values,
|
|
112
|
+
checksum: checksum(values)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function fetchPruningTable(baseUrl, entry) {
|
|
116
|
+
const url = `${baseUrl}/puzzles/cube3/solver/generated/${entry.file}`;
|
|
117
|
+
const buffer = await cachedFetch(url);
|
|
118
|
+
const expectedBytes = Math.ceil(entry.range / 2);
|
|
119
|
+
if (buffer.byteLength !== expectedBytes) {
|
|
120
|
+
throw new Error(`Invalid byte size for ${entry.coordinate} pruning table.`);
|
|
121
|
+
}
|
|
122
|
+
const values = new Uint8Array(buffer);
|
|
123
|
+
return {
|
|
124
|
+
coordinate: entry.coordinate,
|
|
125
|
+
moves: entry.moves,
|
|
126
|
+
range: entry.range,
|
|
127
|
+
values,
|
|
128
|
+
checksum: checksum(values),
|
|
129
|
+
maxDepth: entry.maxDepth ?? 0
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function checksum(values) {
|
|
133
|
+
let hash = 0x811c9dc5;
|
|
134
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
135
|
+
hash ^= values[index];
|
|
136
|
+
hash = Math.imul(hash, 0x01000193);
|
|
137
|
+
}
|
|
138
|
+
return hash >>> 0;
|
|
139
|
+
}
|