24 #ifndef CHESSPOSITION_H 25 #define CHESSPOSITION_H 58 uint16_t M_full_move_number;
59 uint8_t M_half_move_clock;
266 public_notdocumented:
269 BitBoard attackers(
Color const& color)
const {
return M_attackers[color]; }
270 BitBoard pinned(
Color const& color)
const {
return M_pinning[color]; }
277 std::string
FEN(
void)
const;
286 n -= (n > 4) ? 3 : 2;
301 Piece const& piece(M_pieces[index]);
306 data.
M_bitmask = (flags << 50) | (flags << 40);
307 data.
M_bitmask& = CW_MASK_T_CONST(0xe0400000000000);
365 return M_defended[opposite_color].count(M_bitboards[data]) - M_king_battery_attack_count[opposite_color] > 1; }
419 void reset_en_passant(
void) {
if (M_en_passant.
exists()) clear_en_passant(); }
423 void clear_en_passant(
void);
426 bool increment_counters(
bool pawn_advance_or_capture);
429 void update_removed(uint8_t col, uint8_t row,
Color const& color);
432 void update_placed(uint8_t col, uint8_t row,
Color const& color);
438 BitBoard all_pieces_minus_bishop_movers(
Color const& color,
Index const& index)
const;
442 void update_blocked_defendables(
Code const& code,
Index const& index,
bool add);
450 #ifndef DOXYGEN // Hide this from doxygen in order to make some graph less wide. 455 #endif // CHESSPOSITION_H bool double_check(Color const& color) const
Return true if the king of color color is in double check.
CodeData const black_pawn
A constant representing a black pawn.
The POD base type of class Code.
A namespace for all chess related objects that are not related to the GUI.
mask_t M_bitmask
A one-bit-per-square chessboard mask.
bool load_FEN(std::string const& FEN)
Read a FEN code.
MoveIterator move_end(void) const
Return an iterator one beyond the last move.
void clear_has_moved(Index const& index)
Specifically specify that a king or rook didn't move yet.
void set_has_moved(Index const& index)
Specifically specify that a king or rook has already moved.
Color opposite(void) const
Return a Color object with the opposite color of this object.
bool execute(Move const& move)
Execute move move.
Index mask2index(mask_t mask)
Convert a single bit mask into it's Index.
Piece piece_at(int col, int row) const
Return the Piece on the square col, row.
BitBoard const & all(Code const& code) const
Return a BitBoard with bits set for all code, where code may not be& #39;nothing'.
ColorData const white
A constant representing the color white.
A chess move in a particular chess position.
This file contains the declaration of class CastleFlags.
MoveIterator move_begin(Index const& index) const
Return an iterator to the first move of the piece at index index.
BitBoard candidates(Index const& index) const
Return a BitBoard with bits set for all squares that are candidates to move to.
TypeData const king
A constant representing a king.
bool has_moved(Code const& code, Index const& index)
Return TRUE if code at index is marked as having moved.
unsigned int half_move_clock(void) const
Return the half move clock.
The POD base type of class BitBoard.
int candidates_table_offset(Type const& type) const
Return the offset into the candidates_table for type type.
Non-mutable iterator over all moves of a given chess piece.
Index index_of_king(Color const& color) const
Return the index of the king with color color.
bool set_en_passant(Index const& index)
Explicity set the en passant information.
bool check(void) const
Return true if the king is in check.
Type type(void) const
The type of this piece.
void clear(void)
Clear the board.
unsigned int full_move_number(void) const
Return the full move number.
An object representing en passant information.
This file contains the definition of class Array.
A one-boolean-per-square chessboard.
The index of a chess square.
CastleFlags const & castle_flags(void) const
Return the castle flag object.
bool legal(Move const& move) const
Return true if the move is a legal move.
PieceIterator piece_end(void) const
Return an iterator one beyond the last piece.
bool has_moved(Index const& index)
Return true if the king or rook on index has moved or not.
bool check(Color const& color) const
Return true if the king of color color is in check.
A class to keep track of castling rights.
A particular piece on the board.
This file contains the declaration of class EnPassant.
This file contains the inline definitions of class MoveIterator.
uint64_t mask_t
The type of an internal BitBoard mask.
ChessPosition(void)
Construct an uninitialized position.
This file contains the inline definitions of class PieceIterator.
Piece piece_at(Index const& index) const
Return the Piece on the square index.
void set_half_move_clock(int count)
Explicitly set the number of half moves since the last pawn move or capture.
uint8_t const king_bits
The underlaying integral value of type& #39;king'.
bool skip_move(void)
Skip a move.
EnPassant const & en_passant(void) const
Return the en passant object.
PieceIterator piece_begin(Color const& color) const
Return an iterator to the first piece of color color.
PieceIterator piece_begin(Code const& code) const
Return an iterator to the first piece with code code.
This file contains the declaration of class BitBoard.
This file contains the definition of class PieceIterator.
BitBoard reachables(Index const& index, bool attacked_squares=false) const
Return a BitBoard with bits set for each square that a piece can reach in one move.
A chess piece type including color.
std::string FEN(void) const
Return the FEN code for this position.
This file contains the declaration of class CountBoard.
void set_full_move_number(int move)
Explicitly set the move number.
Flags flags(void) const
The flags of this piece.
CodeData const white_pawn
A constant representing a white pawn.
bool exists(void) const
Return TRUE if the last move was a pawn advancing two squares.
void swap_colors(void)
Swap colors.
A color (black or white).
BitBoard defendables(Code const& code, Index const& index, bool& battery) const
Return a BitBoard with bits set for each square that a piece defends, or would defend if an exchange ...
BitBoard moves(Index const& index) const
Return a BitBoard with bits set for each square the piece at index can legally go to...
This file contains the declaration of class MoveIterator.
Non-mutable iterator over selective chess pieces in a chess position.
void initial_position(void)
Set up the initial position.
Color to_move(void) const
Return whose turn it is.
bool place(Code const& code, Index const& index)
Place a piece on the board.
BitBoard const & all(Color const& color) const
Return a BitBoard with bits set for all pieces of color color.
This file contains the declaration of class Piece.