@@ -20,6 +20,7 @@ import {
2020 engineNameAtom ,
2121 engineDepthAtom ,
2222 engineMultiPvAtom ,
23+ engineWorkersNbAtom ,
2324} from "../analysis/states" ;
2425import ArrowOptions from "./arrowOptions" ;
2526import { useAtomLocalStorage } from "@/hooks/useAtomLocalStorage" ;
@@ -35,6 +36,7 @@ import {
3536 PIECE_SETS ,
3637 STRONGEST_ENGINE ,
3738} from "@/constants" ;
39+ import { getRecommendedWorkersNb } from "@/lib/engine/worker" ;
3840
3941interface Props {
4042 open : boolean ;
@@ -56,6 +58,7 @@ export default function EngineSettingsDialog({ open, onClose }: Props) {
5658 ) ;
5759 const [ boardHue , setBoardHue ] = useAtom ( boardHueAtom ) ;
5860 const [ pieceSet , setPieceSet ] = useAtom ( pieceSetAtom ) ;
61+ const [ engineWorkersNb , setEngineWorkersNb ] = useAtom ( engineWorkersNbAtom ) ;
5962
6063 const theme = useTheme ( ) ;
6164 const isDarkMode = theme . palette . mode === "dark" ;
@@ -72,12 +75,15 @@ export default function EngineSettingsDialog({ open, onClose }: Props) {
7275
7376 return (
7477 < Dialog open = { open } onClose = { onClose } maxWidth = "md" fullWidth >
75- < DialogTitle variant = "h5" > Settings</ DialogTitle >
78+ < DialogTitle variant = "h5" sx = { { paddingBottom : 1 } } >
79+ Settings
80+ </ DialogTitle >
7681 < DialogContent sx = { { paddingBottom : 0 } } >
7782 < Grid
7883 container
7984 justifyContent = "center"
8085 alignItems = "center"
86+ paddingTop = { 1 }
8187 spacing = { 3 }
8288 size = { 12 }
8389 >
@@ -86,12 +92,14 @@ export default function EngineSettingsDialog({ open, onClose }: Props) {
8692 justifyContent = "center"
8793 size = { { xs : 12 , sm : 7 , md : 8 } }
8894 >
89- < Typography >
95+ < Typography variant = "body2" >
9096 { ENGINE_LABELS [ DEFAULT_ENGINE ] . small } is the default engine if
9197 your device support its requirements. It offers the best balance
9298 between speed and strength.{ " " }
9399 { ENGINE_LABELS [ STRONGEST_ENGINE ] . small } is the strongest engine
94- available, note that it requires a one time download of 75MB.
100+ available, note that it requires a one time download of{ " " }
101+ { ENGINE_LABELS [ STRONGEST_ENGINE ] . sizeMb } MB and is much more
102+ compute intensive.
95103 </ Typography >
96104 </ Grid >
97105
@@ -162,6 +170,7 @@ export default function EngineSettingsDialog({ open, onClose }: Props) {
162170 < Grid
163171 container
164172 justifyContent = "center"
173+ alignItems = "center"
165174 size = { { xs : 12 , sm : 4 , md : 3 } }
166175 >
167176 < FormControl variant = "outlined" >
@@ -194,6 +203,26 @@ export default function EngineSettingsDialog({ open, onClose }: Props) {
194203 </ Select >
195204 </ FormControl >
196205 </ Grid >
206+
207+ < Grid container justifyContent = "center" size = { { xs : 12 , sm : 7 } } >
208+ < Slider
209+ label = "Number of threads"
210+ value = { engineWorkersNb }
211+ setValue = { setEngineWorkersNb }
212+ min = { 1 }
213+ max = { 10 }
214+ marksFilter = { 1 }
215+ />
216+ </ Grid >
217+
218+ < Grid container justifyContent = "center" size = { { xs : 12 , sm : 5 } } >
219+ < Typography variant = "body2" >
220+ More threads means quicker analysis but only if your device can
221+ handle them, otherwise it may have the opposite effect. The
222+ estimated best value for your device is{ " " }
223+ { getRecommendedWorkersNb ( ) } .
224+ </ Typography >
225+ </ Grid >
197226 </ Grid >
198227 </ DialogContent >
199228 < DialogActions sx = { { m : 1 } } >
0 commit comments