-
Notifications
You must be signed in to change notification settings - Fork 14
/
evaluate_endgame_test.go
231 lines (185 loc) · 5.65 KB
/
evaluate_endgame_test.go
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
// Copyright (c) 2014-2015 by Michael Dvorkin. All Rights Reserved.
// Use of this source code is governed by a MIT-style license that can
// be found in the LICENSE file.
package donna
import(`github.com/michaeldv/donna/expect`; `testing`)
// King with 2+ pawns vs. king.
func TestEndgame000(t *testing.T) {
score := NewGame(`Ke1,a4,a5`, `M,Ka8`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame010(t *testing.T) {
score := NewGame(`Ke1,h4,h6`, `M,Kg8`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame020(t *testing.T) {
score := NewGame(`Kh4`, `Kg8,h6,h2`).start().Evaluate()
expect.True(t, score != 0)
}
func TestEndgame030(t *testing.T) {
score := NewGame(`Kc4`, `Ka5,a3,a4`).start().Evaluate()
expect.True(t, score != 0)
}
// No pawns left.
func TestEndgame100(t *testing.T) {
score := NewGame(`Ke1,Bc1,a2,b2`, `Kd8,Bc8,Nb8`).start().Evaluate()
expect.True(t, score != 0)
}
func TestEndgame110(t *testing.T) {
score := NewGame(`Ke1,Bc1`, `Kd8,d5`).start().Evaluate()
expect.True(t, score == 0)
}
func TestEndgame120(t *testing.T) {
score := NewGame(`Ke1,Nb1`, `Kd8,a5`).start().Evaluate()
expect.True(t, score != 0)
}
// KPK bitbase.
func TestEndgame200(t *testing.T) {
score := NewGame(`Kf1`, `Kh1,h2`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame201(t *testing.T) {
score := NewGame(`Kf1`, `M,Kh1,h2`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame202(t *testing.T) {
score := NewGame(`Ka8,a7`, `Kc7`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame203(t *testing.T) {
score := NewGame(`Ka8,a7`, `M,Kc7`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame210(t *testing.T) {
score := NewGame(`Kf4`, `Kh5,h7`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame211(t *testing.T) {
score := NewGame(`Kf4`, `M,Kh5,h7`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame212(t *testing.T) {
score := NewGame(`Ka5,a2`, `Kc6`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame213(t *testing.T) {
score := NewGame(`Ka5,a2`, `M,Kc6`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame220(t *testing.T) {
score := NewGame(`Kf6,e6`, `Kf8`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame221(t *testing.T) {
score := NewGame(`Kf6,e6`, `M,Kf8`).start().Evaluate()
expect.Eq(t, score, -WhiteWinning)
}
func TestEndgame222(t *testing.T) {
score := NewGame(`Kd1`, `Kd3,e3`).start().Evaluate()
expect.Eq(t, score, BlackWinning)
}
func TestEndgame223(t *testing.T) {
score := NewGame(`Kd1`, `M,Kd3,e3`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame230(t *testing.T) {
score := NewGame(`Kf6,e6`, `Ke8`).start().Evaluate()
expect.Eq(t, score, WhiteWinning)
}
func TestEndgame231(t *testing.T) {
score := NewGame(`Kf6,e6`, `M,Ke8`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame232(t *testing.T) {
score := NewGame(`Ke1`, `Kd3,e3`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame233(t *testing.T) {
score := NewGame(`Ke1`, `M,Kd3,e3`).start().Evaluate()
expect.Eq(t, score, -BlackWinning)
}
func TestEndgame240(t *testing.T) {
score := NewGame(`Ke6,e4`, `Ke8`).start().Evaluate()
expect.Eq(t, score, WhiteWinning)
}
func TestEndgame241(t *testing.T) {
score := NewGame(`Ke6,e4`, `M,Ke8`).start().Evaluate()
expect.Eq(t, score, -WhiteWinning)
}
func TestEndgame242(t *testing.T) {
score := NewGame(`Kd1`, `Kd3,d5`).start().Evaluate()
expect.Eq(t, score, BlackWinning)
}
func TestEndgame243(t *testing.T) {
score := NewGame(`Kd1`, `M,Kd3,d5`).start().Evaluate()
expect.Eq(t, score, -BlackWinning)
}
func TestEndgame250(t *testing.T) {
score := NewGame(`Ka1,e4`, `Ka4`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame251(t *testing.T) {
score := NewGame(`Ka1,e4`, `M,Ka4`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame252(t *testing.T) {
score := NewGame(`Kh5`, `Kh8,d5`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame253(t *testing.T) {
score := NewGame(`Kh5`, `M,Kh8,d5`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame260(t *testing.T) {
score := NewGame(`Ka1,g4`, `Ka4`).start().Evaluate()
expect.Eq(t, score, WhiteWinning)
}
func TestEndgame261(t *testing.T) {
score := NewGame(`Ka1,g4`, `M,Ka4`).start().Evaluate()
expect.Eq(t, score, -WhiteWinning)
}
func TestEndgame262(t *testing.T) {
score := NewGame(`Kh5`, `Kh8,b5`).start().Evaluate()
expect.Eq(t, score, BlackWinning)
}
func TestEndgame263(t *testing.T) {
score := NewGame(`Kh5`, `M,Kh8,b5`).start().Evaluate()
expect.Eq(t, score, -BlackWinning)
}
// kingAndPawnVsKingAndPawn
func TestEndgame300(t *testing.T) {
score := NewGame(`Ke1,e4`, `M,Ke8,e5`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame310(t *testing.T) {
score := NewGame(`Ke1,a4`, `Kf8,h7`).start().Evaluate()
expect.Eq(t, score, WhiteWinning)
}
func TestEndgame320(t *testing.T) {
score := NewGame(`Kc1,a2`, `M,Ke6,h5`).start().Evaluate()
expect.Eq(t, score, BlackWinning)
}
func TestEndgame330(t *testing.T) {
score := NewGame(`Kd1,h2`, `Ka8,a4`).start().Evaluate()
expect.Eq(t, score, WhiteWinning)
}
func TestEndgame340(t *testing.T) {
score := NewGame(`Kd1,h3`, `M,Kb8,a4`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame350(t *testing.T) {
score := NewGame(`Kf5,h3`, `Kd5,h4`).start().Evaluate()
expect.Eq(t, score, 17)
}
func TestEndgame360(t *testing.T) {
score := NewGame(`Kf5,h3`, `M,Kd5,h4`).start().Evaluate()
expect.Eq(t, score, -7)
}
func TestEndgame370(t *testing.T) {
score := NewGame(`Kh6,h3`, `Kf6,h4`).start().Evaluate()
expect.Eq(t, score, 0)
}
func TestEndgame380(t *testing.T) {
score := NewGame(`Kf1,h3`, `M,Kh1,h4`).start().Evaluate()
expect.Eq(t, score, 0)
}