import Slider from "@/components/slider"; import { EngineName } from "@/types/enums"; import { MenuItem, Select, Button, Dialog, DialogTitle, DialogContent, FormControl, InputLabel, OutlinedInput, DialogActions, Typography, Grid2 as Grid, Box, useTheme, } from "@mui/material"; import { engineNameAtom, engineDepthAtom, engineMultiPvAtom, engineWorkersNbAtom, } from "../analysis/states"; import ArrowOptions from "./arrowOptions"; import { useAtomLocalStorage } from "@/hooks/useAtomLocalStorage"; import { useEffect } from "react"; import { isEngineSupported } from "@/lib/engine/shared"; import { Stockfish16_1 } from "@/lib/engine/stockfish16_1"; import { useAtom } from "jotai"; import { boardHueAtom, pieceSetAtom } from "@/components/board/states"; import Image from "next/image"; import { DEFAULT_ENGINE, ENGINE_LABELS, PIECE_SETS, STRONGEST_ENGINE, } from "@/constants"; import { getRecommendedWorkersNb } from "@/lib/engine/worker"; interface Props { open: boolean; onClose: () => void; } export default function EngineSettingsDialog({ open, onClose }: Props) { const [depth, setDepth] = useAtomLocalStorage( "engine-depth", engineDepthAtom ); const [multiPv, setMultiPv] = useAtomLocalStorage( "engine-multi-pv", engineMultiPvAtom ); const [engineName, setEngineName] = useAtomLocalStorage( "engine-name", engineNameAtom ); const [boardHue, setBoardHue] = useAtom(boardHueAtom); const [pieceSet, setPieceSet] = useAtom(pieceSetAtom); const [engineWorkersNb, setEngineWorkersNb] = useAtom(engineWorkersNbAtom); const theme = useTheme(); const isDarkMode = theme.palette.mode === "dark"; useEffect(() => { if (!isEngineSupported(engineName)) { if (Stockfish16_1.isSupported()) { setEngineName(EngineName.Stockfish16_1Lite); } else { setEngineName(EngineName.Stockfish11); } } }, [setEngineName, engineName]); return ( Settings {ENGINE_LABELS[DEFAULT_ENGINE].small} is the default engine if your device support its requirements. It offers the best balance between speed and strength.{" "} {ENGINE_LABELS[STRONGEST_ENGINE].small} is the strongest engine available, note that it requires a one time download of{" "} {ENGINE_LABELS[STRONGEST_ENGINE].sizeMb}MB and is much more compute intensive. Engine Piece set More threads means faster analysis, but only if your device can handle them, otherwise it may have the opposite effect. The estimated optimal value for your device is{" "} {getRecommendedWorkersNb()}.
Due to privacy restrictions in some browsers, this estimated value might be underestimated. Don't hesitate to try different values to find the best one for your device. } />
); }