27 lines
866 B
TypeScript
27 lines
866 B
TypeScript
import { EngineName } from "@/types/enums";
|
|
import { UciEngine } from "./uciEngine";
|
|
import { isMultiThreadSupported, isWasmSupported } from "./shared";
|
|
import { getEngineWorker } from "./worker";
|
|
|
|
export class Stockfish16_1 {
|
|
public static async create(lite?: boolean): Promise<UciEngine> {
|
|
if (!isWasmSupported()) {
|
|
throw new Error("Stockfish 16.1 is not supported");
|
|
}
|
|
|
|
const multiThreadIsSupported = isMultiThreadSupported();
|
|
if (!multiThreadIsSupported) console.log("Single thread mode");
|
|
|
|
const enginePath = `engines/stockfish-16.1/stockfish-16.1${
|
|
lite ? "-lite" : ""
|
|
}${multiThreadIsSupported ? "" : "-single"}.js`;
|
|
const engineName = lite
|
|
? EngineName.Stockfish16_1Lite
|
|
: EngineName.Stockfish16_1;
|
|
|
|
const worker = getEngineWorker(enginePath);
|
|
|
|
return UciEngine.create(engineName, worker);
|
|
}
|
|
}
|