Skip to content

Commit

Permalink
[search] Update minx scrambling implementation to use twsearch.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Oct 25, 2023
1 parent d2a179f commit 0fe77c2
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 53 deletions.
23 changes: 14 additions & 9 deletions src/cubing/search/inside/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import {
} from "../../kpuzzle";
import { puzzles } from "../../puzzles";
import { setIsInsideWorker } from "./inside-worker";
import {
preInitialize222,
random222Scramble,
solve222HTMSubOptimal,
} from "./solve/puzzles/2x2x2";
import { preInitialize222, solve222HTMSubOptimal } from "./solve/puzzles/2x2x2";
import {
initialize333,
random333FewestMovesScramble,
Expand Down Expand Up @@ -39,7 +35,11 @@ import {
solveSkewb,
} from "./solve/puzzles/skewb";
import { getRandomSquare1Scramble } from "./solve/puzzles/sq1";
import { solveTwsearch, type TwsearchOptions } from "./solve/twsearch";
import {
solveTwsearch,
wasmRandomScrambleForEvent,
type TwsearchOptions,
} from "./solve/twsearch";

const IDLE_PREFETCH_TIMEOUT_MS = 1000;

Expand Down Expand Up @@ -88,9 +88,14 @@ async function randomScrambleForEvent(
): Promise<Alg> {
switch (eventID) {
case "222":
return measurePerf("random222Scramble", random222Scramble, {
isPrefetch: options?.isPrefetch,
});
case "minx":
return measurePerf(
`wasmRandomScrambleForEvent(${JSON.stringify(eventID)})`,
() => wasmRandomScrambleForEvent(eventID),
{
isPrefetch: options?.isPrefetch,
},
);
case "333":
case "333oh":
case "333ft":
Expand Down
6 changes: 1 addition & 5 deletions src/cubing/search/inside/solve/puzzles/2x2x2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { mustBeInsideWorker } from "../../inside-worker";
import type { SGSCachedData } from "../parseSGS";
import { TrembleSolver } from "../tremble";
import { searchDynamicSideEvents } from "./dynamic/sgs-side-events";
import { solveTwsearch, wasmRandomScrambleForEvent } from "../twsearch";
import { solveTwsearch } from "../twsearch";
import { experimentalNormalize2x2x2Orientation } from "../../../../puzzles/cubing-private";

let cachedTrembleSolver: Promise<TrembleSolver> | null = null;
Expand Down Expand Up @@ -125,7 +125,3 @@ export async function random222Pattern(): Promise<KPattern> {
});
return patternCopy;
}

export async function random222Scramble(): Promise<Alg> {
return wasmRandomScrambleForEvent("222");
}
28 changes: 0 additions & 28 deletions src/cubing/search/inside/solve/puzzles/wca-minx.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/cubing/search/outside.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { KPuzzle } from "../kpuzzle";
import type { KPattern } from "../kpuzzle/KPattern";
import type { PrefetchLevel } from "./inside/api";
import { randomClockScrambleString } from "./inside/solve/puzzles/clock"; // TODO: don't reach into `inside` code.
import { randomMegaminxScrambleString } from "./inside/solve/puzzles/wca-minx"; // TODO: don't reach into `inside` code.
import type { TwsearchOptions } from "./inside/solve/twsearch";
import {
type InsideOutsideAPI,
Expand Down Expand Up @@ -40,8 +39,6 @@ export function _preInitializationHintForEvent(
): void {
switch (eventID) {
case "clock":
case "minx":
return;
case "333oh":
_preInitializationHintForEvent("333");
return;
Expand All @@ -55,8 +52,6 @@ export async function randomScrambleForEvent(eventID: string): Promise<Alg> {
switch (eventID) {
case "clock":
return Alg.fromString(await randomClockScrambleString());
case "minx":
return Alg.fromString(await randomMegaminxScrambleString());
}
const prom = _randomScrambleStringForEvent(eventID);
const wat = await prom;
Expand All @@ -80,8 +75,6 @@ export async function randomScrambleStringForEvent(
switch (eventID) {
case "clock":
return randomClockScrambleString();
case "minx":
return randomMegaminxScrambleString();
}
return await _randomScrambleStringForEvent(eventID);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cubing/vendor/mpl/twsearch/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ var twsearch_wasm_default = __wbg_init;
var cachedInitWrapper;
async function initWrapper() {
await (cachedInitWrapper ??= (async () => {
const wasmUint8Array = (await import("./twsearch_wasm_bg-3NXOW4HT.js")).default;
const wasmUint8Array = (await import("./twsearch_wasm_bg-Q5ED7P6P.js")).default;
await twsearch_wasm_default(wasmUint8Array.buffer);
})());
}
Expand Down
3 changes: 0 additions & 3 deletions src/cubing/vendor/mpl/twsearch/twsearch_wasm_bg-3NXOW4HT.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/cubing/vendor/mpl/twsearch/twsearch_wasm_bg-Q5ED7P6P.js
Git LFS file not shown

0 comments on commit 0fe77c2

Please sign in to comment.