-
Notifications
You must be signed in to change notification settings - Fork 12
/
pgn_SUITE.erl
432 lines (394 loc) · 16.2 KB
/
pgn_SUITE.erl
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
%% Copyright (c) 2019-2022, Sergei Semichev <chessvegas@chessvegas.com>. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
-module(pgn_SUITE).
-include_lib("common_test/include/ct.hrl").
-include("binbo_test_lib.hrl").
-export([all/0]).
-export([groups/0]).
-export([init_per_suite/1, end_per_suite/1]).
-export([init_per_testcase/2, end_per_testcase/2]).
-export([
load_pgn_nightmare/1,
load_pgn_empty/1,
load_pgn_not_binary/1,
load_pgn_no_moves/1,
load_pgn_no_result/1,
load_pgn_from_file/1,
load_pgn_with_queen_castling/1
]).
%% all/0
all() -> [{group, pgn_loading}].
%% groups/0
groups() ->
[{pgn_loading, [parallel], [
load_pgn_nightmare,
load_pgn_empty,
load_pgn_not_binary,
load_pgn_no_moves,
load_pgn_no_result,
load_pgn_from_file,
load_pgn_with_queen_castling
]}].
%% init_per_suite/1
init_per_suite(Config) ->
ok = binbo_test_lib:all_group_testcases_exported(?MODULE),
{ok, _} = binbo:start(),
Config.
%% end_per_suite/1
end_per_suite(_Config) ->
ok.
%% init_per_testcase/2
init_per_testcase(_TestCase, Config) ->
{ok, Pid} = binbo:new_server(),
[{pid, Pid} | Config].
%% end_per_testcase/2
end_per_testcase(_TestCase, Config) ->
Pid = get_pid(Config),
ok = binbo:stop_server(Pid),
ok.
%% get_pid/1
get_pid(Config) ->
?value(pid, Config).
%% load_pgn_empty/1
load_pgn_empty(Config) ->
Pid = get_pid(Config),
Pgn = <<>>,
{error,empty_pgn} = binbo:load_pgn(Pid, Pgn),
ok.
%% load_pgn_not_binary/1
load_pgn_not_binary(Config) ->
Pid = get_pid(Config),
Pgn = " not binary PGN ",
{error,invalid_pgn_datatype} = binbo:load_pgn(Pid, Pgn),
ok.
%% load_pgn_no_moves/1
load_pgn_no_moves(Config) ->
Pid = get_pid(Config),
Pgn1 = <<" ">>,
Pgn2 = <<
"[Event \"Sicilian Schev. (90m+30s)/40+(15m+30s)\"]\n",
"[Black \"White\"]\n",
"[Date \"2017.7.13\"]\n",
"[Result \"0-1\"]\n",
"[White \"Rated game\"]\n"
>>,
Pgn3 = <<"*">>,
{ok, continue} = binbo:load_pgn(Pid, Pgn1),
{ok, continue} = binbo:load_pgn(Pid, Pgn2),
{ok, continue} = binbo:load_pgn(Pid, Pgn3),
ok.
%% load_pgn_no_result/1
load_pgn_no_result(Config) ->
Pid = get_pid(Config),
Pgn = pgn_no_result(),
{ok,continue} = binbo:load_pgn(Pid, Pgn),
ok.
%% load_pgn_nightmare/1
load_pgn_nightmare(Config) ->
Pid = get_pid(Config),
Pgn = pgn_nightmare(),
{ok, {checkmate, black_wins}} = binbo:load_pgn(Pid, Pgn),
ok.
%% load_pgn_from_file/1
load_pgn_from_file(Config) ->
Pid = get_pid(Config),
DataDir = ?value(data_dir, Config), % ./pgn_SUITE_data/
Filename = filename:join(DataDir, "simple.pgn"),
{ok, _} = binbo:load_pgn_file(Pid, Filename),
ok.
%% load_pgn_with_queen_castling/1
load_pgn_with_queen_castling(Config) ->
Pid = get_pid(Config),
Pgn = pgn_with_queen_castling(),
{ok, continue} = binbo:load_pgn(Pid, Pgn),
ok.
%%%------------------------------------------------------------------------------
%%% PGNs
%%%------------------------------------------------------------------------------
%% pgn_no_result/0
pgn_no_result() ->
<<"
[Event \"IBM Kasparov vs. Deep Blue Rematch\"]
[Site \"New York, NY USA\"]
[Date \"1997.05.11\"]
[Round \"6\"]
[White \"Deep Blue\"]
[Black \"Kasparov, Garry\"]
[Opening \"Caro-Kann: 4...Nd7\"]
[ECO \"B17\"]
[Result \"1-0\"]
1.e4 c6 2.d4 d5 3.Nc3 dxe4 4.Nxe4 Nd7 5.Ng5 Ngf6 6.Bd3 e6 7.N1f3 h6
8.Nxe6 Qe7 9.O-O fxe6 10.Bg6+ Kd8 {Каспаров встряхнул головой}
11.Bf4 b5 12.a4 Bb7 13.Re1 Nd5 14.Bg3 Kc8 15.axb5 cxb5
">>.
%% pgn_nightmare/0
pgn_nightmare() ->
<<"
[Event \"Sicilian Schev. (90m+30s)/40+(15m+30s)\"]
[Black \"White\"]
[Date \"2017.7.13\"]
[Result \"0-1\"]
[White \"Rated game\"]
{ B84: Sicilian Scheveningen: 6 Be2 a6, lines without early Be3 }
1.e4
{ 0 }
\t\t c5 \t\t {% !!! INCLUDE TABS FOR TEST !!! %}
{ 37 }
2.Nf3
{ 0 }
d6
{ 2 }
3.d4
{ 0 }
cxd4
{ 2 }
4.Nxd4
{ 0 }
Nf6
{ 4 }
5.Nc3
{ 0 }
a6
{ 23 }
6.Be2
{ 0 }
e6
{ 19 }
7.O-O
{ 0 }
Be7
{ 14 }
8.f4
{ 0.22/17 0 last book move }
e5
{ 0.22/17 237 }
( 8...b5
( 8...Qb6
( 8...Qc7 9.a3
( 9.Qe1 Nbd7 10.a4
( 10.Bf3 h5 11.Kh1 g6 12.Be3 e5 13.Nb3 b6 14.fxe5 dxe5 15.Nd5 Nxd5 16.exd5 Bb7 17.Rc1 f5 18.c4 a5 19.Qg3 Kf7 20.Be4 Nf6 21.Bb1 h4 22.Qh3 Kg7 23.c5 Nxd5 24.cxb6 Qd7 { Zuckerman,B (2450)-Benko,P (2480) New York 1976 1-0 (38) } )
10...b6 11.Bf3 Bb7 12.Kh1 Rd8 13.Be3 O-O 14.Qg3 Nc5 15.f5 e5 16.Bh6 Ne8 17.Nb3 Nd7 18.Rad1 Kh8 19.Be3 Nef6 20.Qf2 Rfe8 21.Rfe1 Bf8 22.Bg5 h6 23.Bh4 Rc8 { Polgar,J (2630)-Kasparov,G (2805) Linares 1994 0-1 (46) } )
9...O-O 10.Be3 b5 11.Bf3 Bb7 12.Qe2 Nbd7 13.Rad1 Rac8 14.g4 Nc5 15.Qg2 Rfe8 16.g5 Nfd7 17.h4 Bf8 18.h5 e5 19.Nde2 Nb6 20.f5 Nca4 21.g6 Nc4 22.gxh7+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nc6 22.Nd1 g6 23.Ne3 { Bueno Perez,L (2200)-Soler,A (2345) Cienfuegos 1976 1/2-1/2 (44) } )
( 8...Qb6
( 8...Qc7 9.a3
( 9.Qe1 Nbd7 10.a4
( 10.Bf3 h5 11.Kh1 g6 12.Be3 e5 13.Nb3 b6 14.fxe5 dxe5 15.Nd5 Nxd5 16.exd5 Bb7 17.Rc1 f5 18.c4 a5 19.Qg3 Kf7 20.Be4 Nf6 21.Bb1 h4 22.Qh3 Kg7 23.c5 Nxd5 24.cxb6 Qd7 { Zuckerman,B (2450)-Benko,P (2480) New York 1976 1-0 (38) } )
10...b6 11.Bf3 Bb7 12.Kh1 Rd8 13.Be3 O-O 14.Qg3 Nc5 15.f5 e5 16.Bh6 Ne8 17.Nb3 Nd7 18.Rad1 Kh8 19.Be3 Nef6 20.Qf2 Rfe8 21.Rfe1 Bf8 22.Bg5 h6 23.Bh4 Rc8 { Polgar,J (2630)-Kasparov,G (2805) Linares 1994 0-1 (46) } )
9...O-O 10.Be3 b5 11.Bf3 Bb7 12.Qe2 Nbd7 13.Rad1 Rac8 14.g4 Nc5 15.Qg2 Rfe8 16.g5 Nfd7 17.h4 Bf8 18.h5 e5 19.Nde2 Nb6 20.f5 Nca4 21.g6 Nc4 22.gxh7+ Kxh7 23.Bf2 { Paoli,E (2300)-Ribli,Z (2505) Kecskemet 1972 0-1 (47) } )
9.Kh1 Nbd7 10.a4 O-O 11.a5 Qc7 12.Bf3 Rb8 13.g4 b5 14.g5 Ne8 15.Be3 Bb7 16.Bg2 b4 17.Na4 Nc5 18.Nxc5 dxc5 19.Nb3 c4 20.Bb6 Qc8 21.Nd4 Nd6 22.Qe2 Re8 23.Rad1 { Toth,A (2180)-Biro,G (2210) Hungary 1995 0-1 (38) } )
( 8...Qc7 9.a3
( 9.Qe1 Nbd7 10.a4
( 10.Bf3 h5 11.Kh1 g6 12.Be3 e5 13.Nb3 b6 14.fxe5 dxe5 15.Nd5 Nxd5 16.exd5 Bb7 17.Rc1 f5 18.c4 a5 19.Qg3 Kf7 20.Be4 Nf6 21.Bb1 h4 22.Qh3 Kg7 23.c5 Nxd5 24.cxb6 Qd7 { Zuckerman,B (2450)-Benko,P (2480) New York 1976 1-0 (38) } )
10...b6 11.Bf3 Bb7 12.Kh1 Rd8 13.Be3 O-O 14.Qg3 Nc5 15.f5 e5 16.Bh6 Ne8 17.Nb3 Nd7 18.Rad1 Kh8 19.Be3 Nef6 20.Qf2 Rfe8 21.Rfe1 Bf8 22.Bg5 h6 23.Bh4 Rc8 { Polgar,J (2630)-Kasparov,G (2805) Linares 1994 0-1 (46) } )
9...O-O 10.Be3 b5 11.Bf3 Bb7 12.Qe2 Nbd7 13.Rad1 Rac8 14.g4 Nc5 15.Qg2 Rfe8 16.g5 Nfd7 17.h4 Bf8 18.h5 e5 19.Nde2 Nb6 20.f5 Nca4 21.g6 Nc4 22.gxh7+ Kxh7 23.Bf2 { Paoli,E (2300)-Ribli,Z (2505) Kecskemet 1972 0-1 (47) } )
9.fxe5
{ 0.14/17 0 }
( 9.Nf5 { Fritz 15: } Bxf5 10.exf5 Nc6 11.Qd3 O-O 12.Bf3 Re8 13.Be3 Rb8 14.fxe5 Nxe5 15.Qe2 Qd7 16.Bd5 Rbc8 17.Rad1 Qc7 { 0.22/17 } )
9...dxe5
{ 0.14/17 12 }
10.Nf5
{ 0.11/17 0 White threatens to win material: Nf5xg7 }
( 10.Nb3 { Fritz 15: } O-O 11.Be3 Nc6 12.Qxd8 Rxd8 13.Bb6 Rd7 14.Rad1 Nb4 15.Rc1 Nc6 16.Rfd1 Rxd1+ 17.Rxd1 Nb4 18.Bc5 Bxc5+ 19.Nxc5 Kf8 20.N3a4 Ke7 21.Nb6 Rb8 22.c3 Nxa2 { 0.14/17 } )
10...O-O
{ 0.73/17 139 }
( 10...Qxd1
( 10...Qxd1 { Fritz 15: } 11.Rxd1 Bxf5 12.exf5 Nc6 13.Bg5 Nd4 14.Bd3 Rd8 15.Re1 Nc6 16.Rad1 Bb4 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1 { 0.18/17 } )
13...Nc6
{ 0.06/17 80 }
14.Rad1
{ 0.06/17 0 }
Re8
{ 0.06/17 112 Black intends e4. White has an active position }
15.Bf3
{ -0.05/17 0 White has a very active position }
( 15.Nd5 { Fritz 15: } Nd4 16.Bxd4 exd4 17.Nxf6+ Bxf6 18.Bf3 Bg5 19.Rfe1 Be3+ 20.Kh1 Rac8 21.Re2 b5 22.g4 g6 23.fxg6 fxg6 24.Bb7 Rc5 25.b4 Rce5 26.Kg2 R8e6 27.Bf3 Re8 { 0.06/17 } )
15...Rc8
{ 0.85/17 186 }
( 15...e4
( 15...e4 { Fritz 15: } 16.Be2 Rc8 17.a3 Na5 18.Rfe1 Be7 19.Bd4 Nc6 20.Be3 Ne5 21.Bd4 Bc5 22.Bxc5 Rxc5 23.Kf2 Nc6 24.g4 e3+ 25.Kg3 g6 26.g5 Ne4+ 27.Nxe4 Rxe4 28.Bd3 { -0.05/17 } )
16.Be2 Rc8 $11 )
( 15...e4 { Fritz 15: } 16.Be2 Rc8 17.a3 Na5 18.Rfe1 Be7 19.Bd4 Nc6 20.Be3 Ne5 21.Bd4 Bc5 22.Bxc5 Rxc5 23.Kf2 Nc6 24.g4 e3+ 25.Kg3 g6 26.g5 Ne4+ 27.Nxe4 Rxe4 28.Bd3 { -0.05/17 } )
16.Rf2
{ -0.75/17 0 Black has a cramped position. hands over the advantage to the opponent }
( 16.Ne4 $142
( 16.Ne4 { Fritz 15: } Be7 17.Nxf6+ Bxf6 18.Be4 b5 19.c3 Na5 20.b3 Nc6 21.Rd3 h6 22.Rfd1 Red8 23.Rxd8+ Nxd8 24.Bb6 Nc6 25.Kf2 { 0.85/17 } )
16...Be7 17.Nxf6+ Bxf6 18.Be4 $16 )
( 16.Ne4 { Fritz 15: } Be7 17.Nxf6+ Bxf6 18.Be4 b5 19.c3 Na5 20.b3 Nc6 21.Rd3 h6 22.Rfd1 Red8 23.Rxd8+ Nxd8 24.Bb6 Nc6 25.Kf2 { 0.85/17 } )
16...e4
{ -0.75/17 55 Black threatens to win material: e4xf3 }
17.Be2
{ -0.75/17 0 }
h5
{ -0.14/17 53 }
( 17...Nb4 $17
( 17...Nb4 { Fritz 15: } 18.Ba7 Ba5 { ....! } 19.Bd4 Nxc2 20.Bxf6 gxf6 21.Nd5 Rc6 22.Bg4 Nb4 23.Nxb4 Bxb4 24.Re2 Bc5+ 25.Kf1 Re5 26.Rd7 h5 27.Bh3 b5 28.a3 a5 29.g3 { -0.75/17 } )
)
( 17...Nb4 { Fritz 15: } 18.Ba7 Ba5 { ....! } 19.Bd4 Nxc2 20.Bxf6 gxf6 21.Nd5 Rc6 22.Bg4 Nb4 23.Nxb4 Bxb4 24.Re2 Bc5+ 25.Kf1 Re5 26.Rd7 h5 27.Bh3 b5 28.a3 a5 29.g3 { -0.75/17 } )
18.b3
{ -2.84/17 0 }
( 18.a3 { would hold out }
( 18.a3 { Fritz 15: } Ne5 19.Bd4 Bc7 20.g3 Bd6 21.h3 Bc5 22.Bxc5 Rxc5 23.Rf4 Nc6 24.Kf2 e3+ 25.Kf3 Ne5+ 26.Kg2 Rec8 27.Rh4 Nc6 28.Rf4 { -0.14/17 } )
)
( 18.a3 { Fritz 15: } Ne5 19.Bd4 Bc7 20.g3 Bd6 21.h3 Bc5 22.Bxc5 Rxc5 23.Rf4 Nc6 24.Kf2 e3+ 25.Kf3 Ne5+ 26.Kg2 Rec8 27.Rh4 Nc6 28.Rf4 { -0.14/17 } )
18...Nb4
{ -2.84/17 166 }
19.Bc4
{ -2.97/17 0 }
Ng4
{ -1.94/17 146 }
( 19...b5 { seems even better }
( 19...b5 { Fritz 15: } 20.Nxb5 axb5 21.Bxb5 Re5 22.a4 Rd5 23.Rff1 Nxc2 24.Ba7 Be7 25.Rxd5 Nxd5 26.g3 Rc7 27.Bf2 Nc3 28.Rc1 e3 29.Be1 Nxb5 30.axb5 Rc5 31.b6 Nxe1 { -2.97/17 } )
20.Nxb5 axb5 21.Bxb5 Rf8 $19 )
( 19...b5 { Frit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 Rh4+ 35.Ke5 Rb3 36.Kd6 Rb5 37.Ne3 Re4 38.Nc2 Rc4 39.Ne3 Rc6+ 40.Kd7 Rb3 41.Nd5 Rd3 42.Kd8 Rxd5# { -14.74/17 } )
30...Re2
{ -#8/17 20 }
31.b4
{ -#7/17 0 }
Rexe3+
{ -#6/17 58 }
32.Kf4
{ -#6/17 0 }
( 32.Kd5 { cannot change what is in store for ? } Kf6 33.h3 Red3+ 34.Ke4 Rg3 35.Kd5 b5 36.Ke4 Rc4+ 37.Kd5 Rd3# )
32...Kf6
{ -#5/17 21 }
33.h3
{ -#4/17 0 }
( 33.g3 { doesn't improve anything } b5 34.g4 Rf3+ 35.Ke4 hxg4 36.Kd5 Rc4 37.h4 Rd3# )
33...Rg3
{ -#3/17 21 }
34.Ke4
{ -#3/17 0 }
( 34.b5 { does not improve anything } axb5 35.Ke4 Rc4+ 36.Kd5 Rd3# )
34...Rc4+
{ -#2/7 42 }
35.Kd5
{ -#2/17 0 }
Rxb4
{ -#4/17 14 }
( 35...b5 { ....! } 36.Kd6 Rd3# )
36.Kc5
{ -#4/17 0 }
a5
{ -#3/17 16 }
37.Kd6
{ -#3/17 0 }
Rc4
{ -#2/17 36 }
38.Kd7
{ -#2/17 0 }
( 38.Kd5 { doesn't do any good } b5 39.Kd6 Rd3# )
38...Rd3+
{ -#1/17 39 }
39.Ke8
{ -#1/17 0 }
Re4+
{ -#1/17 13 }
( 39...Rc8# )
40.Kf8
{ -#1/17 0 }
Rd8#
{ 2 }
0-1
">>.
pgn_with_queen_castling() ->
<<"
1. d4 Nf6 2. c4 Nc6 3. Nc3 e5 4. d5 Ne7 5. e4 Ng6 6. Be3 Bb4 7. f3 Qe7 8. Bd3
c6 9. Nge2 cxd5 10. cxd5 Nh5 11. g3 O-O 12. a3 Bc5 13. Bxc5 Qxc5 14. b4 Qe3 15.
Qd2 Qxf3 16. O-O-O d6 17. Rdf1 Qg4 18. Nb5 Qd7 19. Qg5 Nf6 20. Rxf6 gxf6 21.
Qxf6 Rd8 22. h4 Qe7 23. Qf3 Bd7 24. Nbc3 a5 25. b5 Rac8 26. Kb2 Rf8 27. g4 f6
28. Ng3 Nf4 29. Nf5 Bxf5 30. exf5 Kh8 31. Re1 Qg7 32. Rg1 Rc5 33. Ne4 Rxd5 34.
Bc4 Rd4 35. Ba2 Qc7 36. g5 fxg5 37. hxg5 Rxf5 38. Qb3 d5 39. Nf6 Nd3+ 40. Kb1
Rf2 41. Nxd5 Rxd5 42. Qxd5 Qc2+ 0-1
">>.