33 std::ostream& operator<<(std::ostream& os, ChessNotation
const& chess_notation)
35 if (chess_notation.M_type)
36 chess_notation.print_on(os,* chess_notation.M_type);
37 if (chess_notation.M_piece)
38 chess_notation.print_on(os,* chess_notation.M_piece);
39 if (chess_notation.M_index)
40 chess_notation.print_on(os,* chess_notation.M_index);
41 if (chess_notation.M_move)
42 chess_notation.print_on(os,* chess_notation.M_move);
46 void ChessNotation::print_on(std::ostream& os,
Piece const& piece)
const 48 print_on(os, piece.type());
51 void ChessNotation::print_on(std::ostream& os, Type
const& type)
const 73 void ChessNotation::print_on(std::ostream& os, Index
const& index)
const 75 char column =
'a' + index.col();
76 char rank =
'1' + index.row();
80 void ChessNotation::print_on(std::ostream& os, Move
const& move)
const 83 int col_diff = move.from().col() - move.to().col();
84 if (piece ==
king && (col_diff == 2 || col_diff == -2))
94 print_on(os, move.from());
95 bool target_square_empty = M_chess_position.
piece_at(move.to()) ==
nothing;
96 bool en_passant = col_diff != 0 && piece ==
pawn && target_square_empty;
97 if (target_square_empty && !en_passant)
101 print_on(os, move.to());
104 if (move.is_promotion())
107 print_on(os, move.promotion_type());
111 Debug(dc::place.off());
112 ChessPosition tmp(M_chess_position);
113 if (!tmp.legal(move))
114 os <<
" illegal move!";
117 bool draw = tmp.execute(move);
120 for (PieceIterator piece_iter = tmp.piece_begin(tmp.to_move()); piece_iter != tmp.piece_end(); ++piece_iter)
122 MoveIterator move_end(tmp.move_end());
123 for (MoveIterator iter = tmp.move_begin(piece_iter.index()); iter != move_end; ++iter)
126 bool check = tmp.check();
127 bool check_mate =
false;
128 bool stale_mate =
false;
148 if (tmp.to_move() ==
black)
158 Debug(dc::place.on());
A namespace for all chess related objects that are not related to the GUI.
TypeData const pawn
A constant representing a pawn.
TypeData const king
A constant representing a king.
uint8_t const bishop_bits
The underlaying integral value of type& #39;bishop'.
Piece piece_at(Index const& index) const
Return the Piece on the square index.
uint8_t const king_bits
The underlaying integral value of type& #39;king'.
TypeData const nothing
A constant representing the absence of a piece.
uint8_t const knight_bits
The underlaying integral value of type& #39;knight'.
uint8_t const queen_bits
The underlaying integral value of type& #39;queen'.
This file contains the declaration of class ChessNotation.
uint8_t const rook_bits
The underlaying integral value of type& #39;rook'.
ColorData const black
A constant representing the color black.