diff --git a/src/cubing/search/inside/api.ts b/src/cubing/search/inside/api.ts index a563461d6..6092007d1 100644 --- a/src/cubing/search/inside/api.ts +++ b/src/cubing/search/inside/api.ts @@ -1,13 +1,13 @@ import type { Alg } from "../../alg"; import { - type KPuzzleDefinition, KPattern, - type KPatternData, KPuzzle, + type KPatternData, + type KPuzzleDefinition, } from "../../kpuzzle"; import { puzzles } from "../../puzzles"; import { setIsInsideWorker } from "./inside-worker"; -import { preInitialize222, solve222HTMSubOptimal } from "./solve/puzzles/2x2x2"; +import { preInitialize222, solve222 } from "./solve/puzzles/2x2x2"; import { initialize333, random333OrientedScramble, @@ -32,8 +32,8 @@ import { import { getRandomSquare1Scramble } from "./solve/puzzles/sq1"; import { wasmRandomScrambleForEvent, - type TwsearchOptions, wasmTwsearch, + type TwsearchOptions, } from "./solve/twsearch"; const IDLE_PREFETCH_TIMEOUT_MS = 1000; @@ -81,9 +81,24 @@ async function randomScrambleForEvent( eventID: string, options?: { isPrefetch?: boolean }, ): Promise { + function wasm(): Promise { + return measurePerf( + `wasmRandomScrambleForEvent(${JSON.stringify(eventID)})`, + () => wasmRandomScrambleForEvent(eventID), + { + isPrefetch: options?.isPrefetch, + }, + ); + } + switch (eventID) { // case "333": case "222": + return (await wasm()).experimentalSimplify({ + puzzleSpecificSimplifyOptions: { + quantumMoveOrder: () => 4, + }, + }); // case "444": case "555": case "666": @@ -103,13 +118,7 @@ async function randomScrambleForEvent( // case "master_tetraminx": // case "kilominx": // case "redi_cube":m - return measurePerf( - `wasmRandomScrambleForEvent(${JSON.stringify(eventID)})`, - () => wasmRandomScrambleForEvent(eventID), - { - isPrefetch: options?.isPrefetch, - }, - ); + return wasm(); case "333": case "333oh": case "333ft": @@ -234,7 +243,7 @@ export const insideAPI = { solve222ToString: async (patternData: KPatternData): Promise => { const pattern = new KPattern(await puzzles["2x2x2"].kpuzzle(), patternData); - return (await solve222HTMSubOptimal(pattern)).toString(); + return (await solve222(pattern)).toString(); }, solveSkewbToString: async (patternData: KPatternData): Promise => { diff --git a/src/cubing/search/inside/solve/puzzles/2x2x2.ts b/src/cubing/search/inside/solve/puzzles/2x2x2.ts index 1ee0e6917..4bc077510 100644 --- a/src/cubing/search/inside/solve/puzzles/2x2x2.ts +++ b/src/cubing/search/inside/solve/puzzles/2x2x2.ts @@ -3,7 +3,6 @@ import type { Alg } from "../../../../alg"; import type { KPuzzle } from "../../../../kpuzzle"; import { KPattern } from "../../../../kpuzzle"; import { cube2x2x2, puzzles } from "../../../../puzzles"; -import { experimentalNormalize2x2x2Orientation } from "../../../../puzzles/cubing-private"; import { mustBeInsideWorker } from "../../inside-worker"; import type { SGSCachedData } from "../parseSGS"; import { TrembleSolver } from "../tremble"; @@ -31,43 +30,11 @@ export async function preInitialize222(): Promise { await getCachedTrembleSolver(); } -export async function solve222HTMSubOptimal( - pattern: KPattern, - maxDepth: number = 11, -): Promise { - mustBeInsideWorker(); - return await wasmTwsearch((await cube2x2x2.kpuzzle()).definition, pattern, { - generatorMoves: "UFLR".split(""), // TODO: - maxDepth, - }); -} - -// TODO: fix def consistency. -// TODO: why is this ending up with the wrong rotation sometimes? -export async function solve222HTMOptimal( - pattern: KPattern, - maxDepth: number = 11, -): Promise { - mustBeInsideWorker(); - const { normalizedPattern, normalizationAlg } = - experimentalNormalize2x2x2Orientation(pattern); - const orientedResult = await wasmTwsearch( - (await cube2x2x2.kpuzzle()).definition, - normalizedPattern, - { - generatorMoves: "UFLR".split(""), // TODO: - maxDepth, - }, - ); - return normalizationAlg.concat(orientedResult); -} - // TODO: fix def consistency. -export async function solve222ForScramble(pattern: KPattern): Promise { +export async function solve222(pattern: KPattern): Promise { mustBeInsideWorker(); return wasmTwsearch((await cube2x2x2.kpuzzle()).definition, pattern, { generatorMoves: "UFLR".split(""), - minDepth: 11, }); }