Skip to content

Commit 545ed7e

Browse files
fix: moves by rating for tournament games
1 parent 774b6fa commit 545ed7e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/hooks/useAnalysisController/useAnalysisController.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const useAnalysisController = (
8686
maia_kdd_1900: result[8],
8787
}
8888

89+
console.log(output)
8990
setMaiaEvaluations((prev) => {
9091
const newEvaluations = [...prev]
9192
newEvaluations[controller.currentIndex] = output
@@ -279,14 +280,10 @@ export const useAnalysisController = (
279280
}, [moveEvaluation])
280281

281282
const movesByRating = useMemo(() => {
282-
if (
283-
!maiaEvaluations[controller.currentIndex] ||
284-
!stockfishEvaluations[controller.currentIndex]
285-
)
286-
return
283+
if (!maiaEvaluations[controller.currentIndex]) return
287284

288285
const maia = maiaEvaluations[controller.currentIndex]
289-
const stockfish = stockfishEvaluations[controller.currentIndex]
286+
const stockfish = moveEvaluation?.stockfish
290287

291288
const candidates: string[][] = []
292289

@@ -297,9 +294,11 @@ export const useAnalysisController = (
297294
}
298295

299296
// Get top 3 Stockfish moves
300-
for (const move of Object.keys(stockfish.cp_vec).slice(0, 3)) {
301-
if (candidates.find((c) => c[0] === move)) continue
302-
candidates.push([move, move])
297+
if (stockfish) {
298+
for (const move of Object.keys(stockfish.cp_vec).slice(0, 3)) {
299+
if (candidates.find((c) => c[0] === move)) continue
300+
candidates.push([move, move])
301+
}
303302
}
304303

305304
// Get top Maia move from each rating level
@@ -328,6 +327,7 @@ export const useAnalysisController = (
328327
controller.currentIndex,
329328
maiaEvaluations,
330329
stockfishEvaluations,
330+
moveEvaluation,
331331
currentMaiaModel,
332332
])
333333

0 commit comments

Comments
 (0)