diff --git a/src/hooks/useAnalysisController/useDeepAnalysis.ts b/src/hooks/useAnalysisController/useDeepAnalysis.ts index 84703a8f..eca4a904 100644 --- a/src/hooks/useAnalysisController/useDeepAnalysis.ts +++ b/src/hooks/useAnalysisController/useDeepAnalysis.ts @@ -110,6 +110,7 @@ export const useDeepAnalysis = ({ analysisRetries < maxAnalysisRetries && !deepAnalysisStatus.current.cancelled && (!node.analysis.stockfish || + !node.analysis.stockfish.done || (node.analysis.stockfish.depth < targetDepth && node.analysis.stockfish.model_optimal_cp !== 10000 && node.analysis.stockfish.model_optimal_cp !== -10000)) diff --git a/src/hooks/useAnalysisController/useEngineAnalysis.ts b/src/hooks/useAnalysisController/useEngineAnalysis.ts index 2bb68714..59d23ac4 100644 --- a/src/hooks/useAnalysisController/useEngineAnalysis.ts +++ b/src/hooks/useAnalysisController/useEngineAnalysis.ts @@ -208,6 +208,10 @@ export const useEngineAnalysis = ( return } + if (currentNode.analysis.stockfish) { + currentNode.analysis.stockfish.done = false + } + const chess = new Chess(currentNode.fen) const legalMoves = new Set( chess @@ -267,6 +271,10 @@ export const useEngineAnalysis = ( } } } + + if (currentNode.analysis.stockfish) { + currentNode.analysis.stockfish.done = true + } } // Delay Stockfish analysis to prevent rapid fire when moving quickly diff --git a/src/lib/engine/stockfish.ts b/src/lib/engine/stockfish.ts index fdbeb869..bdf21a5f 100644 --- a/src/lib/engine/stockfish.ts +++ b/src/lib/engine/stockfish.ts @@ -628,7 +628,6 @@ class Engine { } } finally { if (this.stockfish) { - this.stockfish.listen = originalListen this.stockfish.uci('setoption name MultiPV value 100') } } diff --git a/src/types/analysis.ts b/src/types/analysis.ts index a14fc940..20941023 100644 --- a/src/types/analysis.ts +++ b/src/types/analysis.ts @@ -58,6 +58,7 @@ export interface StockfishEvaluation { winrate_loss_vec?: { [key: string]: number } mate_vec?: { [key: string]: number } is_checkmate?: boolean + done?: boolean } export interface CachedEngineAnalysisEntry {