chessCAMO
|
This class describes the pieces on the board at any given moment. It contains functions for determining the piece's type, color, possible/legal moves, and more helpful utilities for making decisions regarding move candidates. More...
#include <chess.h>
Public Member Functions | |
virtual | ~Piece () |
Piece () | |
Default constructor with default board parameter initialization - Constructs a new instance. More... | |
Piece (int square, pieceType type, pieceColor color) | |
Constructs a new instance with valid piece information initialization. More... | |
int | getPieceSquare () const |
(Accessor) Gets the piece square information. More... | |
void | setPieceSquare (int square) |
(Mutator) Sets the piece square information. More... | |
pieceType | getPieceType () const |
(Accessor) Gets the piece type information. More... | |
void | setPieceType (pieceType type) |
(Mutator) Sets the piece type information. More... | |
pieceColor | getPieceColor () const |
(Accessor) Gets the piece color information. More... | |
void | setPieceColor (pieceColor color) |
(Mutator) Sets the piece color information. More... | |
bool | getPieceMoveInfo () const |
(Accessor) Gets the piece move information useful for pawns, rooks, kings. More... | |
void | setPieceMoveInfo (bool moved) |
(Mutator) Sets the piece move information. More... | |
virtual bool | getEnPassantLeft () const |
(Accessor) Gets the piece en-passant ability information for left side. More... | |
virtual void | setEnPassantLeft (bool en_passant_left) |
(Mutator) Sets the piece en-passant ability information for left side. More... | |
virtual bool | getEnPassantRight () const |
(Accessor) Gets the piece en-passant ability information for right side. More... | |
virtual void | setEnPassantRight (bool en_passant_right) |
(Mutator) Sets the piece en-passant ability information for right side. More... | |
bool | isEmpty () |
Determines if the square is empty. More... | |
bool | isPawn () |
Determines if the piece is a pawn. More... | |
bool | isKnight () |
Determines if the piece is a knight. More... | |
bool | isBishop () |
Determines if the piece is a bishop. More... | |
bool | isRook () |
Determines if the piece is a rook. More... | |
bool | isQueen () |
Determines if the piece is a queen. More... | |
bool | isKing () |
Determines if the piece is a king. More... | |
bool | isPieceWhite () |
Determines if the piece is white. More... | |
bool | isPieceBlack () |
Determines if the piece is black. More... | |
bool | isSameColor (int dest, const Chess &chess) |
Determines if 2 pieces have the same color. More... | |
bool | isPinned (int dest, const Chess &chess) |
Determines if a given piece is pinned to the king by opposing piece. More... | |
bool | isPathFree (int dest, const Chess &chess) |
Determines if the path from the piece to its destination is empty. More... | |
bool | isLegalMove (int dest, Chess &chess) |
Determines if a move is legal based on the rules of chess. More... | |
bool | causeCheck (int dest, Chess &chess) |
Did the move cause a check? More... | |
bool | causeDoubleCheck (int dest, Chess &chess) |
Did the move cause a double check? More... | |
virtual bool | isPossibleMove (int dest, const Chess &chess) |
Determine if the piece has a possible move towards the destination square. More... | |
virtual void | enPassantHandling (int src, Chess &chess) |
Pawn attacks opposing pawn with en-passant More... | |
virtual void | promotePawn (Chess &chess, istream &in) |
Promotes the pawn if needed. More... | |
virtual bool | canCastle (int dest, const Chess &chess) |
Can the king castle? More... | |
virtual bool | movedIntoCheck (int dest, Chess &chess) |
Did the king move into check? More... | |
Private Attributes | |
int | square |
bool | moved |
pieceType | type |
pieceColor | color |
This class describes the pieces on the board at any given moment. It contains functions for determining the piece's type, color, possible/legal moves, and more helpful utilities for making decisions regarding move candidates.
|
inlinevirtual |
|
inline |
Default constructor with default board parameter initialization - Constructs a new instance.
|
inline |
Constructs a new instance with valid piece information initialization.
[in] | square | The square of the piece |
[in] | type | The type of the piece |
[in] | color | The color of the piece |
|
inline |
(Accessor) Gets the piece square information.
|
inline |
(Mutator) Sets the piece square information.
[in] | square | The piece square information |
|
inline |
(Accessor) Gets the piece type information.
|
inline |
(Mutator) Sets the piece type information.
[in] | type | The piece type information |
|
inline |
(Accessor) Gets the piece color information.
|
inline |
(Mutator) Sets the piece color information.
[in] | color | The color information |
|
inline |
(Accessor) Gets the piece move information useful for pawns, rooks, kings.
|
inline |
(Mutator) Sets the piece move information.
[in] | moved | Indicates if piece moved |
|
inlinevirtual |
(Accessor) Gets the piece en-passant ability information for left side.
Reimplemented in Pawn.
|
inlinevirtual |
(Mutator) Sets the piece en-passant ability information for left side.
[in] | en_passant_left | The piece en-passant ability information in left direction |
Reimplemented in Pawn.
|
inlinevirtual |
(Accessor) Gets the piece en-passant ability information for right side.
Reimplemented in Pawn.
|
inlinevirtual |
(Mutator) Sets the piece en-passant ability information for right side.
[in] | en_passant_right | The piece en-passant ability information in right direction |
Reimplemented in Pawn.
|
inline |
Determines if the square is empty.
|
inline |
Determines if the piece is a pawn.
|
inline |
Determines if the piece is a knight.
|
inline |
Determines if the piece is a bishop.
|
inline |
Determines if the piece is a rook.
|
inline |
Determines if the piece is a queen.
|
inline |
Determines if the piece is a king.
|
inline |
Determines if the piece is white.
|
inline |
Determines if the piece is black.
bool Piece::isSameColor | ( | int | dest, |
const Chess & | chess | ||
) |
Determines if 2 pieces have the same color.
[in] | dest | The destination square of the piece |
chess | The chess object |
bool Piece::isPinned | ( | int | dest, |
const Chess & | chess | ||
) |
Determines if a given piece is pinned to the king by opposing piece.
[in] | dest | The destination square of the piece |
chess | The chess object |
bool Piece::isPathFree | ( | int | dest, |
const Chess & | chess | ||
) |
Determines if the path from the piece to its destination is empty.
[in] | dest | The destination square of the piece |
chess | The chess object |
bool Piece::isLegalMove | ( | int | dest, |
Chess & | chess | ||
) |
Determines if a move is legal based on the rules of chess.
[in] | dest | The destination square of the piece |
chess | The chess object |
bool Piece::causeCheck | ( | int | dest, |
Chess & | chess | ||
) |
Did the move cause a check?
[in] | dest | The destination square of the piece |
chess | The chess object |
bool Piece::causeDoubleCheck | ( | int | dest, |
Chess & | chess | ||
) |
Did the move cause a double check?
[in] | dest | The destination square of the piece |
chess | The chess object |
|
inlinevirtual |
Determine if the piece has a possible move towards the destination square.
[in] | dest | The destination square of the piece |
chess | The chess object |
Reimplemented in King, Queen, Rook, Bishop, Knight, and Pawn.
|
inlinevirtual |
Pawn attacks opposing pawn with en-passant
[in] | src | The source square of the piece |
chess | The chess object |
Reimplemented in Pawn.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Did the king move into check?
[in] | dest | The destination square of the piece |
chess | The chess object |
Reimplemented in King.
|
private |
position of the piece on the board [0, 63] -> [top left, bottom right]
|
private |
has the piece been moved yet?
|
private |
BLACK, NEUTRAL, OR WHITE