fix : engine parallel workers
This commit is contained in:
@@ -17,7 +17,7 @@ import { getMovesClassification } from "@/lib/engine/helpers/moveClassification"
|
||||
|
||||
export const useCurrentPosition = (engineName?: EngineName) => {
|
||||
const [currentPosition, setCurrentPosition] = useAtom(currentPositionAtom);
|
||||
const engine = useEngine(engineName);
|
||||
const engine = useEngine(engineName, 1);
|
||||
const gameEval = useAtomValue(gameEvalAtom);
|
||||
const game = useAtomValue(gameAtom);
|
||||
const board = useAtomValue(boardAtom);
|
||||
@@ -52,7 +52,7 @@ export const useCurrentPosition = (engineName?: EngineName) => {
|
||||
|
||||
if (
|
||||
!position.eval &&
|
||||
engine?.isReady() &&
|
||||
engine?.getIsReady() &&
|
||||
engineName &&
|
||||
!board.isCheckmate() &&
|
||||
!board.isStalemate()
|
||||
@@ -61,7 +61,7 @@ export const useCurrentPosition = (engineName?: EngineName) => {
|
||||
fen: string,
|
||||
setPartialEval?: (positionEval: PositionEval) => void
|
||||
) => {
|
||||
if (!engine?.isReady() || !engineName)
|
||||
if (!engine?.getIsReady() || !engineName)
|
||||
throw new Error("Engine not ready");
|
||||
const savedEval = savedEvals[fen];
|
||||
if (
|
||||
|
||||
@@ -30,11 +30,15 @@ export default function AnalyzeButton() {
|
||||
const setSavedEvals = useSetAtom(savedEvalsAtom);
|
||||
|
||||
const readyToAnalyse =
|
||||
engine?.isReady() && game.history().length > 0 && !evaluationProgress;
|
||||
engine?.getIsReady() && game.history().length > 0 && !evaluationProgress;
|
||||
|
||||
const handleAnalyze = async () => {
|
||||
const params = getEvaluateGameParams(game);
|
||||
if (!engine?.isReady() || params.fens.length === 0 || evaluationProgress) {
|
||||
if (
|
||||
!engine?.getIsReady() ||
|
||||
params.fens.length === 0 ||
|
||||
evaluationProgress
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ export const showBestMoveArrowAtom = atom(true);
|
||||
export const showPlayerMoveIconAtom = atom(true);
|
||||
|
||||
export const engineNameAtom = atom<EngineName>(EngineName.Stockfish17Lite);
|
||||
export const engineDepthAtom = atom(16);
|
||||
export const engineDepthAtom = atom(14);
|
||||
export const engineMultiPvAtom = atom(3);
|
||||
export const evaluationProgressAtom = atom(0);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useGameData } from "@/hooks/useGameData";
|
||||
export default function BoardContainer() {
|
||||
const screenSize = useScreenSize();
|
||||
const engineName = useAtomValue(enginePlayNameAtom);
|
||||
const engine = useEngine(engineName);
|
||||
const engine = useEngine(engineName, 1);
|
||||
const game = useAtomValue(gameAtom);
|
||||
const playerColor = useAtomValue(playerColorAtom);
|
||||
const { makeMove: makeGameMove } = useChessActions(gameAtom);
|
||||
@@ -32,7 +32,7 @@ export default function BoardContainer() {
|
||||
useEffect(() => {
|
||||
const playEngineMove = async () => {
|
||||
if (
|
||||
!engine?.isReady() ||
|
||||
!engine?.getIsReady() ||
|
||||
game.turn() === playerColor ||
|
||||
isGameFinished ||
|
||||
!isGameInProgress
|
||||
|
||||
Reference in New Issue
Block a user