Skip to content

Commit

Permalink
Add test for the draw by repetition
Browse files Browse the repository at this point in the history
  • Loading branch information
DOBRO committed Mar 23, 2022
1 parent 8832a61 commit 0b5aa4e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
16 changes: 14 additions & 2 deletions test/pgn_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
load_pgn_from_file_fifty_move_rule_timman_lutz/1,
load_pgn_from_file_fifty_move_rule_karpov_kasparov/1,
load_pgn_from_file_fifty_move_rule_lputian_harutjunyan/1,
load_pgn_from_file_fifty_move_rule_nguyen_vachier_lagrave/1
load_pgn_from_file_fifty_move_rule_nguyen_vachier_lagrave/1,
load_pgn_from_file_threefold_repetition_spassky_fischer/1
]).

%% all/0
Expand All @@ -51,7 +52,8 @@ groups() ->
load_pgn_from_file_fifty_move_rule_timman_lutz,
load_pgn_from_file_fifty_move_rule_karpov_kasparov,
load_pgn_from_file_fifty_move_rule_lputian_harutjunyan,
load_pgn_from_file_fifty_move_rule_nguyen_vachier_lagrave
load_pgn_from_file_fifty_move_rule_nguyen_vachier_lagrave,
load_pgn_from_file_threefold_repetition_spassky_fischer
]}].

%% init_per_suite/1
Expand Down Expand Up @@ -188,6 +190,16 @@ load_pgn_from_file_fifty_move_rule_nguyen_vachier_lagrave(Config) ->
{ok,{draw,rule50}} = binbo:game_status(Pid),
ok.

%% load_pgn_from_file_threefold_repetition_spassky_fischer/1
load_pgn_from_file_threefold_repetition_spassky_fischer(Config) ->
Pid = get_pid(Config),
DataDir = ?value(data_dir, Config), % ./pgn_SUITE_data/
Filename = filename:join(DataDir, "threefold-repetition-Spassky-Fischer.pgn"),
{ok,continue} = binbo:load_pgn_file(Pid, Filename),
{ok,continue} = binbo:game_status(Pid),
{ok,{draw,threefold_repetition}} = binbo:san_move(Pid, <<"Qh6">>),
{ok,{draw,threefold_repetition}} = binbo:game_status(Pid),
ok.

%%%------------------------------------------------------------------------------
%%% PGNs
Expand Down
27 changes: 27 additions & 0 deletions test/pgn_SUITE_data/threefold-repetition-Spassky-Fischer.pgn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Event "Spassky - Fischer World Championship Match"]
[Site "Reykjavik ISL"]
[Date "1972.08.24"]
[EventDate "?"]
[Round "18"]
[Result "1/2-1/2"]
[White "Robert James Fischer"]
[Black "Boris Spassky"]
[ECO "B69"]
[WhiteElo "?"]
[BlackElo "?"]
[PlyCount "94"]

{
Source: https://www.chessgames.com/perl/nph-chesspgn?text=1&gid=1044371
}

1. e4 c5 2. Nf3 d6 3. Nc3 Nc6 4. d4 cxd4 5. Nxd4 Nf6 6. Bg5 e6
7. Qd2 a6 8. O-O-O Bd7 9. f4 Be7 10. Nf3 b5 11. Bxf6 gxf6
12. Bd3 Qa5 13. Kb1 b4 14. Ne2 Qc5 15. f5 a5 16. Nf4 a4
17. Rc1 Rb8 18. c3 b3 19. a3 Ne5 20. Rhf1 Nc4 21. Bxc4 Qxc4
22. Rce1 Kd8 23. Ka1 Rb5 24. Nd4 Ra5 25. Nd3 Kc7 26. Nb4 h5
27. g3 Re5 28. Nd3 Rb8 29. Qe2 Ra5 30. fxe6 fxe6 31. Rf2 e5
32. Nf5 Bxf5 33. Rxf5 d5 34. exd5 Qxd5 35. Nb4 Qd7 36. Rxh5
Bxb4 37. cxb4 Rd5 38. Rc1+ Kb7 39. Qe4 Rc8 40. Rb1 Kb6 41. Rh7
Rd4 42. Qg6 Qc6 43. Rf7 Rd6 44. Qh6 Qf3 45. Qh7 Qc6 46. Qh6
Qf3 47. Qh7 Qc6 1/2-1/2

0 comments on commit 0b5aa4e

Please sign in to comment.