Skip to content

Commit efcca23

Browse files
fix: build & lint errors
1 parent e5aad4d commit efcca23

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

src/components/Home/Sections/AdditionalFeaturesSection.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,14 @@ const FeatureCard = ({
5555
variants,
5656
}: {
5757
feature: Feature
58-
variants: any
58+
variants: {
59+
hidden?: { y?: number; opacity?: number }
60+
visible?: {
61+
y?: number
62+
opacity?: number
63+
transition?: { duration: number }
64+
}
65+
}
5966
}) => {
6067
const { icon, title, description, action, iconBgColor, iconTextColor } =
6168
feature

src/hooks/useAnalysisController/useEngineAnalysis.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
11
import { Chess } from 'chess.ts'
22
import { useEffect, useState } from 'react'
33
import { getBookMoves } from 'src/api'
4-
import { GameNode, MaiaEvaluation } from 'src/types'
4+
import { GameNode, MaiaEvaluation, StockfishEvaluation } from 'src/types'
55
import { MAIA_MODELS } from './constants'
66

7+
type BatchEvaluateResult = {
8+
result: MaiaEvaluation[]
9+
time: number
10+
}
11+
712
type EngineHooks = {
813
maia: {
914
batchEvaluate: (
1015
fens: string[],
1116
ratingLevels: number[],
1217
thresholds: number[],
13-
) => Promise<any>
18+
) => Promise<BatchEvaluateResult>
1419
}
1520
streamEvaluations: (
1621
fen: string,
1722
moveCount: number,
18-
) => AsyncIterable<any> | null
23+
) => AsyncIterable<StockfishEvaluation> | null
1924
stopEvaluation: () => void
2025
}
2126

src/hooks/useStockfishEngine/engine.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ class Engine {
171171
this.store[depth].winrate_loss_vec = {}
172172
}
173173

174-
if (this.store[depth].winrate_vec) {
175-
this.store[depth].winrate_vec[move] = winrate
174+
const winrateVec = this.store[depth].winrate_vec
175+
if (winrateVec) {
176+
winrateVec[move] = winrate
176177
}
177178
} else {
178179
const winrate = cpToWinrate(cp * (isBlackTurn ? -1 : 1), false)
@@ -192,33 +193,34 @@ class Engine {
192193
if (!this.store[depth].sent && multipv === this.legalMoveCount) {
193194
let bestWinrate = -Infinity
194195

195-
if (this.store[depth].winrate_vec) {
196-
for (const m in this.store[depth].winrate_vec) {
197-
const wr = this.store[depth].winrate_vec[m]
196+
const winrateVec = this.store[depth].winrate_vec
197+
if (winrateVec) {
198+
for (const m in winrateVec) {
199+
const wr = winrateVec[m]
198200
if (wr > bestWinrate) {
199201
bestWinrate = wr
200202
}
201203
}
202-
}
203204

204-
if (this.store[depth].winrate_vec && this.store[depth].winrate_loss_vec) {
205-
for (const m in this.store[depth].winrate_vec) {
206-
this.store[depth].winrate_loss_vec[m] =
207-
this.store[depth].winrate_vec[m] - bestWinrate
205+
const winrateLossVec = this.store[depth].winrate_loss_vec
206+
if (winrateLossVec) {
207+
for (const m in winrateVec) {
208+
winrateLossVec[m] = winrateVec[m] - bestWinrate
209+
}
208210
}
209211
}
210212

211213
if (this.store[depth].winrate_vec) {
212214
this.store[depth].winrate_vec = Object.fromEntries(
213-
Object.entries(this.store[depth].winrate_vec).sort(
215+
Object.entries(this.store[depth].winrate_vec || {}).sort(
214216
([, a], [, b]) => b - a,
215217
),
216218
)
217219
}
218220

219221
if (this.store[depth].winrate_loss_vec) {
220222
this.store[depth].winrate_loss_vec = Object.fromEntries(
221-
Object.entries(this.store[depth].winrate_loss_vec).sort(
223+
Object.entries(this.store[depth].winrate_loss_vec || {}).sort(
222224
([, a], [, b]) => b - a,
223225
),
224226
)

0 commit comments

Comments
 (0)