Files
chesskit/src/lib/engine/stockfish16_1.ts
2024-12-28 21:46:55 +01:00

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);
}
}