From 4c08e738c601afbf935ca331fe76455a0c8b9a13 Mon Sep 17 00:00:00 2001 From: Tyson Decker Date: Wed, 9 Mar 2022 09:57:10 -0700 Subject: [PATCH] remove extra typings. --- README.md | 2 +- dist/enums.d.ts | 19 ------------------ dist/enums.d.ts.map | 1 - dist/index.js | 2 +- dist/index.js.map | 2 +- dist/scrambler/scrambler.d.ts | 33 ------------------------------- dist/scrambler/scrambler.d.ts.map | 1 - dist/util.d.ts | 3 --- dist/util.d.ts.map | 1 - package.json | 2 +- src/scrambler/scrambler.ts | 6 ------ 11 files changed, 4 insertions(+), 68 deletions(-) delete mode 100644 dist/enums.d.ts delete mode 100644 dist/enums.d.ts.map delete mode 100644 dist/scrambler/scrambler.d.ts delete mode 100644 dist/scrambler/scrambler.d.ts.map delete mode 100644 dist/util.d.ts delete mode 100644 dist/util.d.ts.map diff --git a/README.md b/README.md index 3ec5bfd..9acaf8b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # srScrambler -Tool to generate scrambles for various twisty puzzles. This is not an official WCA scrambler. But this is very simple and should be good enough for casual scrambles. +Tool to generate scrambles for various twisty puzzles. ***This is not an official WCA scrambler.*** srScrambler won't generate scrambles with canceling moves, but it is still a naive scramble implemenation. But good enough for casual use. - Rubiks Cube (NxN) - Skewb diff --git a/dist/enums.d.ts b/dist/enums.d.ts deleted file mode 100644 index 161ea5d..0000000 --- a/dist/enums.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -export declare enum CubePlane { - X = "x", - Y = "y", - Z = "z" -} -export declare enum Side { - L = "L", - R = "R", - U = "U", - D = "D", - F = "F", - B = "B" -} -export declare enum Modifier { - Double = "2", - CounterClockwise = "'", - Clockwise = "" -} -//# sourceMappingURL=enums.d.ts.map \ No newline at end of file diff --git a/dist/enums.d.ts.map b/dist/enums.d.ts.map deleted file mode 100644 index f96a10b..0000000 --- a/dist/enums.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACnB,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;CACR;AAED,oBAAY,IAAI;IACd,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;IACP,CAAC,MAAM;CACR;AAED,oBAAY,QAAQ;IAClB,MAAM,MAAM;IACZ,gBAAgB,MAAO;IACvB,SAAS,KAAK;CACf"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 2644c16..dbacc63 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,2 +1,2 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["sr-scrambler"]=t():e["sr-scrambler"]=t()}(self,(function(){return(()=>{"use strict";var e,t,o,r={d:(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},l={};function n(e){return!Array.isArray(e)||e.length<1?null:e[Math.floor(Math.random()*e.length)]}r.r(l),r.d(l,{cube:()=>p,megaminx:()=>a,pyraminx:()=>c,skewb:()=>h,square1:()=>d}),function(e){e.X="x",e.Y="y",e.Z="z"}(e||(e={})),function(e){e.L="L",e.R="R",e.U="U",e.D="D",e.F="F",e.B="B"}(t||(t={})),function(e){e.Double="2",e.CounterClockwise="'",e.Clockwise=""}(o||(o={}));const i=(e,t,o,r,l)=>{let i,f,s=[];for(var u=0;ue.map((e=>Array.isArray(e)?u(e)+"\n":(e=>{const t=e.depth>2?`${e.depth}`:"",o=e.depth>1?"w":"";return`${t}${e.face}${o}${e.modifier}`})(e))).join(" "),p=(r=3,l=21)=>u(((r=3,l=21)=>i([t.L,t.R,t.U,t.D,t.F,t.B],{[t.L]:e.X,[t.R]:e.X,[t.U]:e.Y,[t.D]:e.Y,[t.F]:e.Z,[t.B]:e.Z},[o.Double,o.CounterClockwise,o.Clockwise],Math.floor(r/2),l))(r,l)),a=()=>u(((e=10,t=6)=>{let o=[];for(let r=0;ru(((e=10)=>{let r=i([t.L,t.R,t.U,t.B],{[t.L]:"L",[t.R]:"R",[t.U]:"U",[t.B]:"B"},[o.CounterClockwise,o.Clockwise],1,e);var l;return(l=["l","r","u","b"],l.map((e=>({value:e,sort:Math.random()}))).sort(((e,t)=>e.sort-t.sort)).map((({value:e})=>e))).forEach((e=>{let t=n([o.Clockwise,o.CounterClockwise,null]);null!=t&&r.push({face:e,modifier:t,depth:1})})),r})(e)),h=e=>u(((e=9)=>i([t.L,t.R,t.U,t.B],{[t.L]:"L",[t.R]:"R",[t.U]:"U",[t.B]:"B"},[o.CounterClockwise,o.Clockwise],1,e))(e)),d=e=>((e=12)=>{let t=[2,1,2,1,2,1,2,1],o=[1,2,1,2,1,2,1,2];const r=e=>{for(;0!=e;)if(e<0){let o=t.shift();e+=o,t.push(o)}else if(e>0){let o=t.pop();e-=o,t.unshift(o)}},l=e=>{for(;0!=e;)if(e<0){let t=o.shift();if(t>-e)throw Error("breaking");e+=t,o.push(t)}else if(e>0){let t=o.pop();if(t>e)throw Error("breaking2");e-=t,o.unshift(t)}},i=()=>{let e=0,r=0,l=0;for(let o=t.length;o>0&&l<6;o--)l+=t[o-1],e++;l=0;for(let e=0;e{let t=0;for(let o=0;o6)return!1;return!0},s=(e,t)=>{if(t<0){for(;t<0;){let o=e.shift();if(o>Math.abs(t))return!1;t+=o,e.push(o)}return f(e)}if(t>0){for(;t>0;){let o=e.pop();if(t{let e=[],r=[];for(let l=-6;l<=6;l++)s([...t],l)&&e.push(l),s([...o],l)&&r.push(l);return{possibleTop:e,possibleBottom:r}};let p=[];for(let t=0;t` (${e.top}, ${e.bottom}) /`)).join("");return l})()})); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["sr-scrambler"]=t():e["sr-scrambler"]=t()}(self,(function(){return(()=>{"use strict";var e,t,o,r={d:(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},l={};function n(e){return!Array.isArray(e)||e.length<1?null:e[Math.floor(Math.random()*e.length)]}r.r(l),r.d(l,{cube:()=>p,megaminx:()=>a,pyraminx:()=>c,skewb:()=>h,square1:()=>d}),function(e){e.X="x",e.Y="y",e.Z="z"}(e||(e={})),function(e){e.L="L",e.R="R",e.U="U",e.D="D",e.F="F",e.B="B"}(t||(t={})),function(e){e.Double="2",e.CounterClockwise="'",e.Clockwise=""}(o||(o={}));const i=(e,t,o,r,l)=>{let i,s,f=[];for(var u=0;ue.map((e=>Array.isArray(e)?u(e)+"\n":(e=>{const t=e.depth>2?`${e.depth}`:"",o=e.depth>1?"w":"";return`${t}${e.face}${o}${e.modifier}`})(e))).join(" "),p=(r=3,l=21)=>u(((r=3,l=21)=>i([t.L,t.R,t.U,t.D,t.F,t.B],{[t.L]:e.X,[t.R]:e.X,[t.U]:e.Y,[t.D]:e.Y,[t.F]:e.Z,[t.B]:e.Z},[o.Double,o.CounterClockwise,o.Clockwise],Math.floor(r/2),l))(r,l)),a=()=>u(((e=10,t=6)=>{let o=[];for(let r=0;ru(((e=10)=>{let r=i([t.L,t.R,t.U,t.B],{[t.L]:"L",[t.R]:"R",[t.U]:"U",[t.B]:"B"},[o.CounterClockwise,o.Clockwise],1,e);var l;return(l=["l","r","u","b"],l.map((e=>({value:e,sort:Math.random()}))).sort(((e,t)=>e.sort-t.sort)).map((({value:e})=>e))).forEach((e=>{let t=n([o.Clockwise,o.CounterClockwise,null]);null!=t&&r.push({face:e,modifier:t,depth:1})})),r})(e)),h=e=>u(((e=9)=>i([t.L,t.R,t.U,t.B],{[t.L]:"L",[t.R]:"R",[t.U]:"U",[t.B]:"B"},[o.CounterClockwise,o.Clockwise],1,e))(e)),d=e=>((e=12)=>{let t=[2,1,2,1,2,1,2,1],o=[1,2,1,2,1,2,1,2];const r=e=>{for(;0!=e;)if(e<0){let o=t.shift();e+=o,t.push(o)}else if(e>0){let o=t.pop();e-=o,t.unshift(o)}},l=e=>{for(;0!=e;)if(e<0){let t=o.shift();e+=t,o.push(t)}else if(e>0){let t=o.pop();e-=t,o.unshift(t)}},i=()=>{let e=0,r=0,l=0;for(let o=t.length;o>0&&l<6;o--)l+=t[o-1],e++;l=0;for(let e=0;e{let t=0;for(let o=0;o6)return!1;return!0},f=(e,t)=>{if(t<0){for(;t<0;){let o=e.shift();if(o>Math.abs(t))return!1;t+=o,e.push(o)}return s(e)}if(t>0){for(;t>0;){let o=e.pop();if(t{let e=[],r=[];for(let l=-6;l<=6;l++)f([...t],l)&&e.push(l),f([...o],l)&&r.push(l);return{possibleTop:e,possibleBottom:r}};let p=[];for(let t=0;t` (${e.top}, ${e.bottom}) /`)).join("");return l})()})); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/index.js.map b/dist/index.js.map index cec3757..a87675b 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,gBAAkBD,IAE1BD,EAAK,gBAAkBC,IARzB,CASGK,MAAM,WACT,M,mBCTA,ICDWC,EAMAC,EASAC,EDdPC,EAAsB,CEA1BA,EAAwB,CAACR,EAASS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3B,GAAIA,EAAQ,EAAG,CAEX,KAAOA,EAAQ,GAAG,CACd,IAAIgD,EAAQc,EAAMb,QAClB,GAAID,EAAQ3D,KAAK2E,IAAIhE,GACjB,OAAO,EAEXA,GAASgD,EACTc,EAAM5D,KAAK8C,GAEf,OAAOa,EAAeC,GAErB,GAAI9D,EAAQ,EAAG,CAEhB,KAAOA,EAAQ,GAAG,CACd,IAAIgD,EAAQc,EAAMZ,MAClB,GAAIlD,EAAQgD,EACR,OAAO,EAEXhD,GAASgD,EACTc,EAAMX,QAAQH,GAElB,OAAOa,EAAeC,GAItB,OAAO,GAGTG,EAAgB,KAClB,IAAIC,EAAc,GACdC,EAAiB,GACrB,IAAK,IAAIlE,GAAK,EAAGA,GAAK,EAAGA,IACjB8D,EAAe,IAAIlB,GAAO5C,IAC1BiE,EAAYhE,KAAKD,GAEjB8D,EAAe,IAAIjB,GAAS7C,IAC5BkE,EAAejE,KAAKD,GAG5B,MAAO,CACHiE,YAAAA,EACAC,eAAAA,IAGR,IAAInE,EAAQ,GACZ,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAUI,IAAK,CAC/B,IAAImE,EAAQH,IACRI,EAAU,EACVC,EAAa,EACjB,GACID,EAAUrF,EAAcoF,EAAMF,aAC9BI,EAAatF,EAAcoF,EAAMD,sBAChB,IAAZE,GAAgC,IAAfC,GAC1BtE,EAAME,KAAK,CACPqE,IAAKF,EACLvB,OAAQwB,IAEZvB,EAAQsB,GACRjB,EAAWkB,GACXhB,IAEJ,OAAOtD,GC5LAwE,CAAwB3E,GAC1BY,KAAKC,GAAS,KAAKA,EAAK6D,QAAQ7D,EAAKoC,cACrChC,KAAK,I","sources":["webpack://sr-scrambler/webpack/universalModuleDefinition","webpack://sr-scrambler/webpack/bootstrap","webpack://sr-scrambler/./src/enums.ts","webpack://sr-scrambler/webpack/runtime/define property getters","webpack://sr-scrambler/webpack/runtime/hasOwnProperty shorthand","webpack://sr-scrambler/webpack/runtime/make namespace object","webpack://sr-scrambler/./src/util.ts","webpack://sr-scrambler/./src/scrambler/scrambler.ts","webpack://sr-scrambler/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sr-scrambler\"] = factory();\n\telse\n\t\troot[\"sr-scrambler\"] = factory();\n})(self, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","export var CubePlane;\n(function (CubePlane) {\n CubePlane[\"X\"] = \"x\";\n CubePlane[\"Y\"] = \"y\";\n CubePlane[\"Z\"] = \"z\";\n})(CubePlane || (CubePlane = {}));\nexport var Side;\n(function (Side) {\n Side[\"L\"] = \"L\";\n Side[\"R\"] = \"R\";\n Side[\"U\"] = \"U\";\n Side[\"D\"] = \"D\";\n Side[\"F\"] = \"F\";\n Side[\"B\"] = \"B\";\n})(Side || (Side = {}));\nexport var Modifier;\n(function (Modifier) {\n Modifier[\"Double\"] = \"2\";\n Modifier[\"CounterClockwise\"] = \"'\";\n Modifier[\"Clockwise\"] = \"\";\n})(Modifier || (Modifier = {}));\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export function randomElement(array) {\n if (!Array.isArray(array) || array.length < 1) {\n return null;\n }\n return array[Math.floor(Math.random() * array.length)];\n}\nexport function shuffle(array) {\n return array.map(value => ({ value, sort: Math.random() }))\n .sort((a, b) => a.sort - b.sort)\n .map(({ value }) => value);\n}\n","import { CubePlane, Modifier, Side } from \"../enums\";\nimport { randomElement, shuffle } from \"../util\";\nconst generateScramble = (faces, planeMapping, modifiers, maxDepth, numTurns) => {\n let turns = [];\n let previousTurn;\n let newTurn;\n for (var i = 0; i < numTurns; i++) {\n do {\n newTurn = randomElement(faces);\n } while (planeMapping[previousTurn] === planeMapping[newTurn]);\n turns.push({\n face: newTurn,\n depth: Math.floor(Math.random() * maxDepth) + 1,\n modifier: randomElement(modifiers)\n });\n previousTurn = newTurn;\n }\n return turns;\n};\nexport const generateCubeScramble = (size = 3, numTurns = 21) => {\n return generateScramble([Side.L, Side.R, Side.U, Side.D, Side.F, Side.B], {\n [Side.L]: CubePlane.X,\n [Side.R]: CubePlane.X,\n [Side.U]: CubePlane.Y,\n [Side.D]: CubePlane.Y,\n [Side.F]: CubePlane.Z,\n [Side.B]: CubePlane.Z\n }, [\n Modifier.Double,\n Modifier.CounterClockwise,\n Modifier.Clockwise\n ], Math.floor(size / 2), numTurns);\n};\nconst pochmanFaces = ['D', 'R'];\nconst pochmanModifiers = ['++', '--'];\n/**\n * generates a pochman scramble for the megaminx\n */\nexport const generateMegaminxScramble = (sequenceLength = 10, numSequences = 6) => {\n let turns = [];\n for (let i = 0; i < numSequences; i++) {\n turns[i] = [];\n for (let j = 0; j < sequenceLength; j++) {\n turns[i].push({\n face: pochmanFaces[j % pochmanFaces.length],\n modifier: randomElement(pochmanModifiers),\n depth: 1\n });\n }\n turns[i].push({\n face: 'U',\n modifier: randomElement(['', '\\'']),\n depth: 1\n });\n }\n return turns;\n};\nexport const generateSkewbScramble = (numTurns = 9) => {\n return generateScramble([Side.L, Side.R, Side.U, Side.B], {\n [Side.L]: 'L',\n [Side.R]: 'R',\n [Side.U]: 'U',\n [Side.B]: 'B'\n }, [\n Modifier.CounterClockwise,\n Modifier.Clockwise\n ], 1, numTurns);\n};\nexport const generatePyraminxScramble = (numTurns = 10) => {\n let turns = generateScramble([Side.L, Side.R, Side.U, Side.B], {\n [Side.L]: 'L',\n [Side.R]: 'R',\n [Side.U]: 'U',\n [Side.B]: 'B'\n }, [\n Modifier.CounterClockwise,\n Modifier.Clockwise\n ], 1, numTurns);\n shuffle(['l', 'r', 'u', 'b'])\n .forEach(point => {\n let modifier = randomElement([Modifier.Clockwise, Modifier.CounterClockwise, null]);\n if (modifier != null) {\n turns.push({\n face: point,\n modifier: modifier,\n depth: 1\n });\n }\n });\n return turns;\n};\nexport const generateSquare1Scramble = (numTurns = 12) => {\n let tops = [2, 1, 2, 1, 2, 1, 2, 1];\n let bottom = [1, 2, 1, 2, 1, 2, 1, 2];\n const turnTop = (turns) => {\n while (turns != 0) {\n if (turns < 0) {\n let piece = tops.shift();\n turns += piece;\n tops.push(piece);\n }\n else if (turns > 0) {\n let piece = tops.pop();\n turns -= piece;\n tops.unshift(piece);\n }\n }\n };\n const turnBottom = (turns) => {\n while (turns != 0) {\n if (turns < 0) {\n let piece = bottom.shift();\n if (piece > (-turns)) {\n throw Error(\"breaking\");\n }\n turns += piece;\n bottom.push(piece);\n }\n else if (turns > 0) {\n let piece = bottom.pop();\n if (piece > turns) {\n throw Error(\"breaking2\");\n }\n turns -= piece;\n bottom.unshift(piece);\n }\n }\n };\n const slice = () => {\n let topNum = 0;\n let bottomNum = 0;\n let value = 0;\n for (let i = tops.length; i > 0 && value < 6; i--) {\n value += tops[i - 1];\n topNum++;\n }\n value = 0;\n for (let i = 0; i < bottom.length && value < 6; i++) {\n value += bottom[i];\n bottomNum++;\n }\n const topSlice = tops.splice(tops.length - topNum, tops.length);\n const bottomSlice = bottom.splice(0, bottomNum);\n tops = tops.concat(bottomSlice);\n bottom = topSlice.concat(bottom);\n };\n const isLayerAligned = (layer) => {\n let value = 0;\n for (let i = 0; i < layer.length && value < 6; i++) {\n value += layer[i];\n if (value > 6) {\n return false;\n }\n }\n return true;\n };\n const isMovePossible = (layer, turns) => {\n if (turns < 0) {\n // Take off front, put on end\n while (turns < 0) {\n let piece = layer.shift();\n if (piece > Math.abs(turns)) {\n return false;\n }\n turns += piece;\n layer.push(piece);\n }\n return isLayerAligned(layer);\n }\n else if (turns > 0) {\n // Take off end, put on front\n while (turns > 0) {\n let piece = layer.pop();\n if (turns < piece) {\n return false;\n }\n turns -= piece;\n layer.unshift(piece);\n }\n return isLayerAligned(layer);\n }\n else {\n // Turns = 0, should be possible\n return true;\n }\n };\n const possibleMoves = () => {\n let possibleTop = [];\n let possibleBottom = [];\n for (let i = -6; i <= 6; i++) {\n if (isMovePossible([...tops], i)) {\n possibleTop.push(i);\n }\n if (isMovePossible([...bottom], i)) {\n possibleBottom.push(i);\n }\n }\n return {\n possibleTop,\n possibleBottom\n };\n };\n let turns = [];\n for (let i = 0; i < numTurns; i++) {\n let moves = possibleMoves();\n let topMove = 0;\n let bottomMove = 0;\n do {\n topMove = randomElement(moves.possibleTop);\n bottomMove = randomElement(moves.possibleBottom);\n } while (topMove === 0 && bottomMove === 0);\n turns.push({\n top: topMove,\n bottom: bottomMove\n });\n turnTop(topMove);\n turnBottom(bottomMove);\n slice();\n }\n return turns;\n};\n","import { generateSquare1Scramble, generateCubeScramble, generateMegaminxScramble, generatePyraminxScramble, generateSkewbScramble } from \"./scrambler/scrambler\";\nconst turnToString = (turn) => {\n const depthLayer = turn.depth > 2 ? `${turn.depth}` : '';\n const sliceIndicator = turn.depth > 1 ? 'w' : '';\n return `${depthLayer}${turn.face}${sliceIndicator}${turn.modifier}`;\n};\nconst scrambleToString = (turns) => {\n return turns\n .map(turn => {\n if (Array.isArray(turn)) {\n return scrambleToString(turn) + '\\n';\n }\n else {\n return turnToString(turn);\n }\n })\n .join(' ');\n};\nexport const cube = (size = 3, numTurns = 21) => {\n return scrambleToString(generateCubeScramble(size, numTurns));\n};\nexport const megaminx = () => {\n return scrambleToString(generateMegaminxScramble());\n};\nexport const pyraminx = (numTurns) => {\n return scrambleToString(generatePyraminxScramble(numTurns));\n};\nexport const skewb = (numTurns) => {\n return scrambleToString(generateSkewbScramble(numTurns));\n};\nexport const square1 = (numTurns) => {\n return generateSquare1Scramble(numTurns)\n .map((turn) => ` (${turn.top}, ${turn.bottom}) /`)\n .join('');\n};\n"],"names":["root","factory","exports","module","define","amd","self","CubePlane","Side","Modifier","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","randomElement","array","Array","isArray","length","Math","floor","random","generateScramble","faces","planeMapping","modifiers","maxDepth","numTurns","previousTurn","newTurn","turns","i","push","face","depth","modifier","pochmanFaces","pochmanModifiers","scrambleToString","map","turn","depthLayer","sliceIndicator","turnToString","join","cube","size","L","R","U","D","F","B","X","Y","Z","Double","CounterClockwise","Clockwise","generateCubeScramble","megaminx","sequenceLength","numSequences","j","generateMegaminxScramble","pyraminx","sort","a","b","forEach","point","generatePyraminxScramble","skewb","generateSkewbScramble","square1","tops","bottom","turnTop","piece","shift","pop","unshift","turnBottom","Error","slice","topNum","bottomNum","topSlice","splice","bottomSlice","concat","isLayerAligned","layer","isMovePossible","abs","possibleMoves","possibleTop","possibleBottom","moves","topMove","bottomMove","top","generateSquare1Scramble"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAQ,gBAAkBD,IAE1BD,EAAK,gBAAkBC,IARzB,CASGK,MAAM,WACT,M,mBCTA,ICDWC,EAMAC,EASAC,EDdPC,EAAsB,CEA1BA,EAAwB,CAACR,EAASS,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAEX,EAASU,IAC5EE,OAAOC,eAAeb,EAASU,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,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Q,GAAG,CACd,IAAIgD,EAAQa,EAAMX,MAClB,GAAIlD,EAAQgD,EACR,OAAO,EAEXhD,GAASgD,EACTa,EAAMV,QAAQH,GAElB,OAAOY,EAAeC,GAItB,OAAO,GAGTG,EAAgB,KAClB,IAAIC,EAAc,GACdC,EAAiB,GACrB,IAAK,IAAIjE,GAAK,EAAGA,GAAK,EAAGA,IACjB6D,EAAe,IAAIjB,GAAO5C,IAC1BgE,EAAY/D,KAAKD,GAEjB6D,EAAe,IAAIhB,GAAS7C,IAC5BiE,EAAehE,KAAKD,GAG5B,MAAO,CACHgE,YAAAA,EACAC,eAAAA,IAGR,IAAIlE,EAAQ,GACZ,IAAK,IAAIC,EAAI,EAAGA,EAAIJ,EAAUI,IAAK,CAC/B,IAAIkE,EAAQH,IACRI,EAAU,EACVC,EAAa,EACjB,GACID,EAAUpF,EAAcmF,EAAMF,aAC9BI,EAAarF,EAAcmF,EAAMD,sBAChB,IAAZE,GAAgC,IAAfC,GAC1BrE,EAAME,KAAK,CACPoE,IAAKF,EACLtB,OAAQuB,IAEZtB,EAAQqB,GACRhB,EAAWiB,GACXhB,IAEJ,OAAOrD,GCtLAuE,CAAwB1E,GAC1BY,KAAKC,GAAS,KAAKA,EAAK4D,QAAQ5D,EAAKoC,cACrChC,KAAK,I","sources":["webpack://sr-scrambler/webpack/universalModuleDefinition","webpack://sr-scrambler/webpack/bootstrap","webpack://sr-scrambler/./src/enums.ts","webpack://sr-scrambler/webpack/runtime/define property getters","webpack://sr-scrambler/webpack/runtime/hasOwnProperty shorthand","webpack://sr-scrambler/webpack/runtime/make namespace object","webpack://sr-scrambler/./src/util.ts","webpack://sr-scrambler/./src/scrambler/scrambler.ts","webpack://sr-scrambler/./src/index.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"sr-scrambler\"] = factory();\n\telse\n\t\troot[\"sr-scrambler\"] = factory();\n})(self, function() {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","export var CubePlane;\n(function (CubePlane) {\n CubePlane[\"X\"] = \"x\";\n CubePlane[\"Y\"] = \"y\";\n CubePlane[\"Z\"] = \"z\";\n})(CubePlane || (CubePlane = {}));\nexport var Side;\n(function (Side) {\n Side[\"L\"] = \"L\";\n Side[\"R\"] = \"R\";\n Side[\"U\"] = \"U\";\n Side[\"D\"] = \"D\";\n Side[\"F\"] = \"F\";\n Side[\"B\"] = \"B\";\n})(Side || (Side = {}));\nexport var Modifier;\n(function (Modifier) {\n Modifier[\"Double\"] = \"2\";\n Modifier[\"CounterClockwise\"] = \"'\";\n Modifier[\"Clockwise\"] = \"\";\n})(Modifier || (Modifier = {}));\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export function randomElement(array) {\n if (!Array.isArray(array) || array.length < 1) {\n return null;\n }\n return array[Math.floor(Math.random() * array.length)];\n}\nexport function shuffle(array) {\n return array.map(value => ({ value, sort: Math.random() }))\n .sort((a, b) => a.sort - b.sort)\n .map(({ value }) => value);\n}\n","import { CubePlane, Modifier, Side } from \"../enums\";\nimport { randomElement, shuffle } from \"../util\";\nconst generateScramble = (faces, planeMapping, modifiers, maxDepth, numTurns) => {\n let turns = [];\n let previousTurn;\n let newTurn;\n for (var i = 0; i < numTurns; i++) {\n do {\n newTurn = randomElement(faces);\n } while (planeMapping[previousTurn] === planeMapping[newTurn]);\n turns.push({\n face: newTurn,\n depth: Math.floor(Math.random() * maxDepth) + 1,\n modifier: randomElement(modifiers)\n });\n previousTurn = newTurn;\n }\n return turns;\n};\nexport const generateCubeScramble = (size = 3, numTurns = 21) => {\n return generateScramble([Side.L, Side.R, Side.U, Side.D, Side.F, Side.B], {\n [Side.L]: CubePlane.X,\n [Side.R]: CubePlane.X,\n [Side.U]: CubePlane.Y,\n [Side.D]: CubePlane.Y,\n [Side.F]: CubePlane.Z,\n [Side.B]: CubePlane.Z\n }, [\n Modifier.Double,\n Modifier.CounterClockwise,\n Modifier.Clockwise\n ], Math.floor(size / 2), numTurns);\n};\nconst pochmanFaces = ['D', 'R'];\nconst pochmanModifiers = ['++', '--'];\n/**\n * generates a pochman scramble for the megaminx\n */\nexport const generateMegaminxScramble = (sequenceLength = 10, numSequences = 6) => {\n let turns = [];\n for (let i = 0; i < numSequences; i++) {\n turns[i] = [];\n for (let j = 0; j < sequenceLength; j++) {\n turns[i].push({\n face: pochmanFaces[j % pochmanFaces.length],\n modifier: randomElement(pochmanModifiers),\n depth: 1\n });\n }\n turns[i].push({\n face: 'U',\n modifier: randomElement(['', '\\'']),\n depth: 1\n });\n }\n return turns;\n};\nexport const generateSkewbScramble = (numTurns = 9) => {\n return generateScramble([Side.L, Side.R, Side.U, Side.B], {\n [Side.L]: 'L',\n [Side.R]: 'R',\n [Side.U]: 'U',\n [Side.B]: 'B'\n }, [\n Modifier.CounterClockwise,\n Modifier.Clockwise\n ], 1, numTurns);\n};\nexport const generatePyraminxScramble = (numTurns = 10) => {\n let turns = generateScramble([Side.L, Side.R, Side.U, Side.B], {\n [Side.L]: 'L',\n [Side.R]: 'R',\n [Side.U]: 'U',\n [Side.B]: 'B'\n }, [\n Modifier.CounterClockwise,\n Modifier.Clockwise\n ], 1, numTurns);\n shuffle(['l', 'r', 'u', 'b'])\n .forEach(point => {\n let modifier = randomElement([Modifier.Clockwise, Modifier.CounterClockwise, null]);\n if (modifier != null) {\n turns.push({\n face: point,\n modifier: modifier,\n depth: 1\n });\n }\n });\n return turns;\n};\nexport const generateSquare1Scramble = (numTurns = 12) => {\n let tops = [2, 1, 2, 1, 2, 1, 2, 1];\n let bottom = [1, 2, 1, 2, 1, 2, 1, 2];\n const turnTop = (turns) => {\n while (turns != 0) {\n if (turns < 0) {\n let piece = tops.shift();\n turns += piece;\n tops.push(piece);\n }\n else if (turns > 0) {\n let piece = tops.pop();\n turns -= piece;\n tops.unshift(piece);\n }\n }\n };\n const turnBottom = (turns) => {\n while (turns != 0) {\n if (turns < 0) {\n let piece = bottom.shift();\n turns += piece;\n bottom.push(piece);\n }\n else if (turns > 0) {\n let piece = bottom.pop();\n turns -= piece;\n bottom.unshift(piece);\n }\n }\n };\n const slice = () => {\n let topNum = 0;\n let bottomNum = 0;\n let value = 0;\n for (let i = tops.length; i > 0 && value < 6; i--) {\n value += tops[i - 1];\n topNum++;\n }\n value = 0;\n for (let i = 0; i < bottom.length && value < 6; i++) {\n value += bottom[i];\n bottomNum++;\n }\n const topSlice = tops.splice(tops.length - topNum, tops.length);\n const bottomSlice = bottom.splice(0, bottomNum);\n tops = tops.concat(bottomSlice);\n bottom = topSlice.concat(bottom);\n };\n const isLayerAligned = (layer) => {\n let value = 0;\n for (let i = 0; i < layer.length && value < 6; i++) {\n value += layer[i];\n if (value > 6) {\n return false;\n }\n }\n return true;\n };\n const isMovePossible = (layer, turns) => {\n if (turns < 0) {\n // Take off front, put on end\n while (turns < 0) {\n let piece = layer.shift();\n if (piece > Math.abs(turns)) {\n return false;\n }\n turns += piece;\n layer.push(piece);\n }\n return isLayerAligned(layer);\n }\n else if (turns > 0) {\n // Take off end, put on front\n while (turns > 0) {\n let piece = layer.pop();\n if (turns < piece) {\n return false;\n }\n turns -= piece;\n layer.unshift(piece);\n }\n return isLayerAligned(layer);\n }\n else {\n // Turns = 0, should be possible\n return true;\n }\n };\n const possibleMoves = () => {\n let possibleTop = [];\n let possibleBottom = [];\n for (let i = -6; i <= 6; i++) {\n if (isMovePossible([...tops], i)) {\n possibleTop.push(i);\n }\n if (isMovePossible([...bottom], i)) {\n possibleBottom.push(i);\n }\n }\n return {\n possibleTop,\n possibleBottom\n };\n };\n let turns = [];\n for (let i = 0; i < numTurns; i++) {\n let moves = possibleMoves();\n let topMove = 0;\n let bottomMove = 0;\n do {\n topMove = randomElement(moves.possibleTop);\n bottomMove = randomElement(moves.possibleBottom);\n } while (topMove === 0 && bottomMove === 0);\n turns.push({\n top: topMove,\n bottom: bottomMove\n });\n turnTop(topMove);\n turnBottom(bottomMove);\n slice();\n }\n return turns;\n};\n","import { generateSquare1Scramble, generateCubeScramble, generateMegaminxScramble, generatePyraminxScramble, generateSkewbScramble } from \"./scrambler/scrambler\";\nconst turnToString = (turn) => {\n const depthLayer = turn.depth > 2 ? `${turn.depth}` : '';\n const sliceIndicator = turn.depth > 1 ? 'w' : '';\n return `${depthLayer}${turn.face}${sliceIndicator}${turn.modifier}`;\n};\nconst scrambleToString = (turns) => {\n return turns\n .map(turn => {\n if (Array.isArray(turn)) {\n return scrambleToString(turn) + '\\n';\n }\n else {\n return turnToString(turn);\n }\n })\n .join(' ');\n};\nexport const cube = (size = 3, numTurns = 21) => {\n return scrambleToString(generateCubeScramble(size, numTurns));\n};\nexport const megaminx = () => {\n return scrambleToString(generateMegaminxScramble());\n};\nexport const pyraminx = (numTurns) => {\n return scrambleToString(generatePyraminxScramble(numTurns));\n};\nexport const skewb = (numTurns) => {\n return scrambleToString(generateSkewbScramble(numTurns));\n};\nexport const square1 = (numTurns) => {\n return generateSquare1Scramble(numTurns)\n .map((turn) => ` (${turn.top}, ${turn.bottom}) /`)\n .join('');\n};\n"],"names":["root","factory","exports","module","define","amd","self","CubePlane","Side","Modifier","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","randomElement","array","Array","isArray","length","Math","floor","random","generateScramble","faces","planeMapping","modifiers","maxDepth","numTurns","previousTurn","newTurn","turns","i","push","face","depth","modifier","pochmanFaces","pochmanModifiers","scrambleToString","map","turn","depthLayer","sliceIndicator","turnToString","join","cube","size","L","R","U","D","F","B","X","Y","Z","Double","CounterClockwise","Clockwise","generateCubeScramble","megaminx","sequenceLength","numSequences","j","generateMegaminxScramble","pyraminx","sort","a","b","forEach","point","generatePyraminxScramble","skewb","generateSkewbScramble","square1","tops","bottom","turnTop","piece","shift","pop","unshift","turnBottom","slice","topNum","bottomNum","topSlice","splice","bottomSlice","concat","isLayerAligned","layer","isMovePossible","abs","possibleMoves","possibleTop","possibleBottom","moves","topMove","bottomMove","top","generateSquare1Scramble"],"sourceRoot":""} \ No newline at end of file diff --git a/dist/scrambler/scrambler.d.ts b/dist/scrambler/scrambler.d.ts deleted file mode 100644 index 13afd42..0000000 --- a/dist/scrambler/scrambler.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * planes of rotation - * for examples a cube rototes on x,y,z axis - * we don't want to generate two turns in a - * row on the same axis - */ -export declare type RotationPlane = string; -/** - * possible faces to rotate on the puzzle - * (ex, 3x3 has UFLRB) - */ -export declare type Face = string; -/** - * clockwise, counterclockwise... - */ -export declare type Modifer = string; -export declare type PlaneMapping = { - [face: string]: RotationPlane; -}; -export declare type Turn = { - face: Face; - depth: number; - modifier: Modifer; -}; -export declare const generateCubeScramble: (size?: number, numTurns?: number) => Turn[]; -/** - * generates a pochman scramble for the megaminx - */ -export declare const generateMegaminxScramble: (sequenceLength?: number, numSequences?: number) => Turn[][]; -export declare const generateSkewbScramble: (numTurns?: number) => Turn[]; -export declare const generatePyraminxScramble: (numTurns?: number) => Turn[]; -export declare const generateSquare1Scramble: (numTurns?: number) => any; -//# sourceMappingURL=scrambler.d.ts.map \ No newline at end of file diff --git a/dist/scrambler/scrambler.d.ts.map b/dist/scrambler/scrambler.d.ts.map deleted file mode 100644 index b7faf4d..0000000 --- a/dist/scrambler/scrambler.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"scrambler.d.ts","sourceRoot":"","sources":["../../src/scrambler/scrambler.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,oBAAY,aAAa,GAAG,MAAM,CAAC;AAEnC;;;GAGG;AACH,oBAAY,IAAI,GAAG,MAAM,CAAC;AAE1B;;GAEG;AACH,oBAAY,OAAO,GAAG,MAAM,CAAC;AAE7B,oBAAY,YAAY,GAAG;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAE7D,oBAAY,IAAI,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAA;AA6BD,eAAO,MAAM,oBAAoB,UAAU,MAAM,aAAgB,MAAM,WAiBtE,CAAA;AAKD;;GAEG;AACH,eAAO,MAAM,wBAAwB,oBAAoB,MAAM,iBAAqB,MAAM,KAAO,IAAI,EAAE,EAoBtG,CAAA;AAED,eAAO,MAAM,qBAAqB,cAAc,MAAM,WAcrD,CAAA;AAED,eAAO,MAAM,wBAAwB,cAAc,MAAM,WA6BxD,CAAA;AAED,eAAO,MAAM,uBAAuB,cAAc,MAAM,QAsJvD,CAAA"} \ No newline at end of file diff --git a/dist/util.d.ts b/dist/util.d.ts deleted file mode 100644 index 309869a..0000000 --- a/dist/util.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare function randomElement(array: T[]): T; -export declare function shuffle(array: T[]): T[]; -//# sourceMappingURL=util.d.ts.map \ No newline at end of file diff --git a/dist/util.d.ts.map b/dist/util.d.ts.map deleted file mode 100644 index 6c5df3b..0000000 --- a/dist/util.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,CAK9C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAI1C"} \ No newline at end of file diff --git a/package.json b/package.json index fde0ece..4629000 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sr-scrambler", - "version": "2.0.1", + "version": "2.0.2", "description": "utilitiy to generate scrambles for twisty puzzles (rubiks cube, megaminx, pyraminx, skewb, square1)", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/scrambler/scrambler.ts b/src/scrambler/scrambler.ts index 453a56b..41969a0 100644 --- a/src/scrambler/scrambler.ts +++ b/src/scrambler/scrambler.ts @@ -171,16 +171,10 @@ export const generateSquare1Scramble = (numTurns: number = 12) => { while (turns != 0) { if (turns < 0) { let piece = bottom.shift(); - if (piece > (-turns)) { - throw Error("breaking") - } turns += piece; bottom.push(piece); } else if (turns > 0) { let piece = bottom.pop(); - if (piece > turns) { - throw Error("breaking2") - } turns -= piece; bottom.unshift(piece); }