-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathanalysis.ts
More file actions
151 lines (135 loc) · 2.9 KB
/
analysis.ts
File metadata and controls
151 lines (135 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { Player } from './player'
import { BaseGame } from './common'
import { AvailableMoves } from './puzzle'
export interface MoveValueMapping {
[move: string]: number
}
export interface AnalyzedGame extends BaseGame {
availableMoves: AvailableMoves[]
type: EvaluationType
gameType: string
blackPlayer: Player
whitePlayer: Player
termination?: Termination
}
export interface MaiaEvaluation {
value: number
policy: { [key: string]: number }
}
export interface StockfishEvaluation {
sent: boolean
depth: number
model_move: string
model_optimal_cp: number
cp_vec: { [key: string]: number }
cp_relative_vec: { [key: string]: number }
winrate_vec?: { [key: string]: number }
winrate_loss_vec?: { [key: string]: number }
mate_in?: number
is_checkmate?: boolean
}
export interface CachedEngineAnalysisEntry {
ply: number
fen: string
maia?: { [rating: string]: MaiaEvaluation }
stockfish?: {
depth: number
cp_vec: MoveValueMapping
}
}
type EvaluationType =
| 'tournament'
| 'lichess'
| 'play'
| 'hand'
| 'brain'
| 'custom'
| 'stream'
export interface WorldChampionshipGameListEntry {
game_index: number
event: string
site: string
date: string
round: number
white: string
black: string
result?: string
}
export interface MaiaGameListEntry {
id: string
type:
| 'tournament'
| 'lichess'
| 'play'
| 'hand'
| 'brain'
| 'custom'
| 'stream'
label: string
result: string
pgn?: string
}
export interface Termination {
result: string
winner: 'white' | 'black' | 'none' | undefined
type?: 'rules' | 'resign' | 'time' | undefined
condition?: string
}
export interface ColorSanMapping {
[move: string]: {
san: string
color: string
}
}
export interface DeepAnalysisConfig {
targetDepth: number
}
export interface DeepAnalysisProgress {
currentMoveIndex: number
totalMoves: number
currentMove: string
isAnalyzing: boolean
isComplete: boolean
isCancelled: boolean
}
export interface BlunderInfo {
move: string
probability: number
}
export interface BlunderMeterResult {
blunderMoves: {
probability: number
moves: BlunderInfo[]
}
okMoves: {
probability: number
moves: BlunderInfo[]
}
goodMoves: {
probability: number
moves: BlunderInfo[]
}
}
export interface MistakePosition {
nodeId: string
moveIndex: number
fen: string
playedMove: string
san: string
type: 'blunder' | 'inaccuracy'
bestMove: string
bestMoveSan: string
playerColor: 'white' | 'black'
}
export interface LearnFromMistakesConfiguration {
isActive: boolean
showPlayerSelection: boolean
selectedPlayerColor: 'white' | 'black' | null
currentMistakeIndex: number
mistakes: MistakePosition[]
hasCompletedAnalysis: boolean
showSolution: boolean
currentAttempt: number
maxAttempts: number
originalPosition: string | null // FEN of the position where the player should make a move
}