feat : add user input engineWorkersNb
This commit is contained in:
@@ -3,6 +3,7 @@ import {
|
||||
engineDepthAtom,
|
||||
engineMultiPvAtom,
|
||||
engineNameAtom,
|
||||
engineWorkersNbAtom,
|
||||
evaluationProgressAtom,
|
||||
gameAtom,
|
||||
gameEvalAtom,
|
||||
@@ -19,12 +20,12 @@ import { useEffect, useCallback } from "react";
|
||||
import { usePlayersData } from "@/hooks/usePlayersData";
|
||||
import { Typography } from "@mui/material";
|
||||
import { useCurrentPosition } from "../hooks/useCurrentPosition";
|
||||
import { getRecommendedWorkersNb } from "@/lib/engine/worker";
|
||||
|
||||
export default function AnalyzeButton() {
|
||||
const engineName = useAtomValue(engineNameAtom);
|
||||
const engine = useEngine(engineName);
|
||||
useCurrentPosition(engine);
|
||||
const engineWorkersNb = useAtomValue(engineWorkersNbAtom);
|
||||
const [evaluationProgress, setEvaluationProgress] = useAtom(
|
||||
evaluationProgressAtom
|
||||
);
|
||||
@@ -58,7 +59,7 @@ export default function AnalyzeButton() {
|
||||
white: white?.rating,
|
||||
black: black?.rating,
|
||||
},
|
||||
workersNb: getRecommendedWorkersNb(),
|
||||
workersNb: engineWorkersNb,
|
||||
});
|
||||
|
||||
setEval(newGameEval);
|
||||
@@ -86,6 +87,7 @@ export default function AnalyzeButton() {
|
||||
}, [
|
||||
engine,
|
||||
engineName,
|
||||
engineWorkersNb,
|
||||
game,
|
||||
engineDepth,
|
||||
engineMultiPv,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { DEFAULT_ENGINE } from "@/constants";
|
||||
import { getRecommendedWorkersNb } from "@/lib/engine/worker";
|
||||
import { EngineName } from "@/types/enums";
|
||||
import { CurrentPosition, GameEval, SavedEvals } from "@/types/eval";
|
||||
import { Chess } from "chess.js";
|
||||
import { atom } from "jotai";
|
||||
import { atomWithStorage } from "jotai/utils";
|
||||
|
||||
export const gameEvalAtom = atom<GameEval | undefined>(undefined);
|
||||
export const gameAtom = atom(new Chess());
|
||||
@@ -16,6 +18,10 @@ export const showPlayerMoveIconAtom = atom(true);
|
||||
export const engineNameAtom = atom<EngineName>(DEFAULT_ENGINE);
|
||||
export const engineDepthAtom = atom(14);
|
||||
export const engineMultiPvAtom = atom(3);
|
||||
export const engineWorkersNbAtom = atomWithStorage(
|
||||
"engineWorkersNb",
|
||||
getRecommendedWorkersNb()
|
||||
);
|
||||
export const evaluationProgressAtom = atom(0);
|
||||
|
||||
export const savedEvalsAtom = atom<SavedEvals>({});
|
||||
|
||||
Reference in New Issue
Block a user