24 #ifndef MOVEITERATOR_H 25 #define MOVEITERATOR_H 35 #define CWCHESSBOARD_LIKELY(condition) __builtin_expect(condition, true) 58 class MoveIterator :
public std::iterator<std::bidirectional_iterator_tag, Move> {
78 M_chess_position(iter.M_chess_position), M_targets(iter.M_targets), M_current_move(iter.M_current_move) { }
124 if (CWCHESSBOARD_LIKELY(!M_current_move.
is_promotion()) || next_promotion())
126 Index current_index(M_current_move.
to());
128 M_current_move.
set_to(current_index);
137 if (CWCHESSBOARD_LIKELY(!M_current_move.
is_promotion()) || prev_promotion())
139 Index current_index(M_current_move.
to());
141 M_current_move.
set_to(current_index);
150 public_notdocumented:
152 uint32_t index(
void)
const {
return M_current_move.
to()(); }
155 bool next_promotion(
void);
156 bool prev_promotion(
void);
160 Type initial_type(
Index const& index)
const;
165 #endif // MOVEITERATOR_H A namespace for all chess related objects that are not related to the GUI.
void prev_bit_in(uint64_t mask)
Retreat Index to the previous bit that is set.
A chess move in a particular chess position.
void next_bit_in(uint64_t mask)
Advance the index to the next bit that is set in mask.
Non-mutable iterator over all moves of a given chess piece.
MoveIterator(void)
Construct a one-past-the-end MoveIterator.
void set_to(Index to)
Set different target square.
bool is_promotion(void) const
Return TRUE if this move is a pawn promotion.
A one-boolean-per-square chessboard.
The index of a chess square.
MoveIterator & operator=(MoveIterator const& iter)
Assignment operator.
ChessPosition const * M_chess_position
The underlaying chess position.
Move M_current_move
The actual move that is returned when dereferenced.
This file contains the declaration of class BitBoard.
Index to(void) const
Return the square the piece moves to.
MoveIterator(MoveIterator const& iter)
Copy-Constructor.
TypeData const nothing
A constant representing the absence of a piece.
IndexData const index_pre_begin
A constant representing& #39;one before the start'.
This file contains the definition of class Move.
IndexData const index_end
A constant representing& #39;one past the end'.
BitBoard M_targets
The targets that this piece can move to.
This file contains the declaration of class Piece.