diff --git a/bun.lockb b/bun.lockb index 30ce2ad..f1b2550 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 9c878c7..954767e 100644 --- a/package.json +++ b/package.json @@ -6,11 +6,11 @@ "devDependencies": { "@biomejs/biome": "^1.9.4", "@types/bun": "^1.1.12", - "barely-a-dev-server": "^0.6.1", + "barely-a-dev-server": "^0.6.2", "csv-parse": "^5.5.6", - "cubing": "^0.31.6", - "esbuild": "0.23.0", + "cubing": "^0.52.3", + "esbuild": "0.24.0", "serve": "^14.2.4", - "typescript": "^4.8.4" + "typescript": "^5.6.3" } } diff --git a/script/generate-scrambles.ts b/script/generate-scrambles.ts new file mode 100644 index 0000000..0fc8d8f --- /dev/null +++ b/script/generate-scrambles.ts @@ -0,0 +1,37 @@ +import { rm } from "node:fs/promises"; +import { join } from "node:path"; +import { file, write } from "bun"; +import { twizzleEvents } from "cubing/puzzles"; +import { randomScrambleForEvent } from "cubing/scramble"; + +const allScrambles: Record = {}; + +const outputDir = "./dist/scrambles"; + +rm(outputDir, { recursive: true, force: true }); + +for (const [event, info] of Object.entries(twizzleEvents)) { + try { + console.log(`[${info.eventName}] Generating…`); + const numScrambles = event === "333mbf" ? 100 : 1; + const eventScrambles: string[] = []; + for (let i = 0; i < numScrambles; i++) { + eventScrambles.push((await randomScrambleForEvent(event)).toString()); + } + write( + file(join(outputDir, `${info.eventName}.txt`)), + eventScrambles.join("\n////////\n"), + ); + allScrambles[event] = eventScrambles; + } catch (e) { + if (e.toString().includes("unsupported event")) { + continue; + } + throw e; + } +} + +write( + file(join(outputDir, "scrambles.json")), + JSON.stringify(allScrambles, null, " "), +);