File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -42,21 +42,33 @@ std::string get_scholars_mate_as_pgn_str() noexcept
42
42
return " 1. e4 e5 2. Qh5 Nc6 3. Bc4 Nf6?? Qxf7# 1-0" ;
43
43
}
44
44
45
- void play_game (const replay& r)
45
+ void play_game (const replay& r, const bool verbose )
46
46
{
47
47
game g;
48
48
const auto & moves{r.get_moves ()};
49
49
const int n_moves = moves.size ();
50
50
for (int i{0 }; i!=n_moves; ++i)
51
51
{
52
52
const auto & m{moves[i]};
53
- std::clog << i << " : " << m << ' \n ' ;
53
+ if (verbose) std::clog << i << " : " << m << ' \n ' ;
54
54
start_chess_move (g, m);
55
55
for (int j{0 }; j!=4 ; ++j) g.tick (delta_t (0.25 ));
56
- std::clog << to_board_str (
56
+ if (verbose) std::clog << to_board_str (
57
57
g.get_pieces (),
58
58
board_to_text_options (true , true )
59
59
) << ' \n ' ;
60
+ const auto messages{collect_messages (g)};
61
+ const long n_cannot{
62
+ std::count_if (
63
+ std::begin (messages),
64
+ std::end (messages),
65
+ [](const auto & msg)
66
+ {
67
+ return msg.get_message_type () == message_type::cannot;
68
+ }
69
+ )
70
+ };
71
+ assert (n_cannot == 0 );
60
72
}
61
73
}
62
74
Original file line number Diff line number Diff line change @@ -34,7 +34,10 @@ replay get_replay_1() noexcept;
34
34
35
35
// / Play a replay, using \link{game} (not \link{game_controller})
36
36
// / as the actor
37
- void play_game (const replay& r);
37
+ void play_game (
38
+ const replay& r,
39
+ const bool verbose = false
40
+ );
38
41
39
42
// / Split the PGN string into its moves
40
43
// / E.g. '1. e4 e5 2. Nc3' will be split into {'e4', 'e5', 'Nc3'}
You can’t perform that action at this time.
0 commit comments