|
Cute Chess
0.1
|
A board for western chess variants. More...
#include <westernboard.h>
Classes | |
| struct | PawnStep |
Public Types | |
| enum | WesternPieceType { Pawn = 1, Knight, Bishop, Rook, Queen, King } |
Public Types inherited from Chess::Board | |
| enum | CoordinateSystem { NormalCoordinates, InvertedCoordinates } |
| enum | FenNotation { XFen, ShredderFen } |
| enum | MoveNotation { StandardAlgebraic, LongAlgebraic } |
Public Member Functions | |
| virtual int | height () const |
| virtual Result | result () |
| virtual int | reversibleMoveCount () const |
| WesternBoard (WesternZobrist *zobrist) | |
| virtual int | width () const |
Public Member Functions inherited from Chess::Board | |
| Board (Zobrist *zobrist) | |
| virtual CoordinateSystem | coordinateSystem () const |
| virtual Board * | copy () const =0 |
| virtual QString | defaultFenString () const =0 |
| QString | fenString (FenNotation notation=XFen) const |
| GenericMove | genericMove (const Move &move) const |
| void | initialize () |
| bool | isLegalMove (const Move &move) |
| virtual bool | isRandomVariant () const |
| bool | isRepetition (const Move &move) |
| bool | isValidSquare (const Square &square) const |
| quint64 | key () const |
| QVector< Move > | legalMoves () |
| void | makeMove (const Move &move, BoardTransition *transition=nullptr) |
| Move | moveFromGenericMove (const GenericMove &move) const |
| Move | moveFromString (const QString &str) |
| QString | moveString (const Move &move, MoveNotation notation) |
| Piece | pieceAt (const Square &square) const |
| Piece | pieceFromSymbol (const QString &pieceSymbol) const |
| QStringList | pieceList (Side side) const |
| QString | pieceString (int pieceType) const |
| QString | pieceSymbol (Piece piece) const |
| int | plyCount () const |
| int | repeatCount () const |
| QString | representation (Piece piece) const |
| int | reserveCount (Piece piece) const |
| virtual QList< Piece > | reservePieceTypes () const |
| void | reset () |
| bool | setFenString (const QString &fen) |
| Side | sideToMove () const |
| QString | startingFenString () const |
| Side | startingSide () const |
| virtual Result | tablebaseResult (unsigned int *dtm=nullptr) const |
| void | undoMove () |
| virtual Side | upperCaseSide () const |
| virtual QString | variant () const =0 |
| virtual bool | variantHasDrops () const |
| virtual bool | variantHasOptionalPromotions () const |
| virtual bool | variantHasWallSquares () const |
| virtual | ~Board () |
Protected Types | |
| enum | CastlingSide { QueenSide, KingSide, NoCastlingSide } |
| enum | StepType { NoStep = 0, FreeStep = 1, CaptureStep = 2 } |
Protected Member Functions | |
| virtual void | addPromotions (int sourceSquare, int targetSquare, QVarLengthArray< Move > &moves) const |
| virtual int | captureType (const Move &move) const |
| virtual int | castlingFile (CastlingSide castlingSide) const |
| int | enpassantSquare () const |
| virtual void | generateMovesForPiece (QVarLengthArray< Move > &moves, int pieceType, int square) const |
| virtual bool | hasCastling () const |
| bool | hasCastlingRight (Side side, CastlingSide castlingSide) const |
| virtual bool | hasEnPassantCaptures () const |
| virtual bool | inCheck (Side side, int square=0) const |
| virtual bool | isLegalPosition () |
| virtual bool | kingCanCapture () const |
| virtual bool | kingsCountAssertion (int whiteKings, int blackKings) const |
| int | kingSquare (Side side) const |
| virtual QString | lanMoveString (const Move &move) |
| virtual Move | moveFromLanString (const QString &str) |
| virtual Move | moveFromSanString (const QString &str) |
| virtual bool | parseCastlingRights (QChar c) |
| int | pawnAmbiguity (StepType type=FreeStep) const |
| virtual bool | pawnHasDoubleStep () const |
| void | removeCastlingRights (int square) |
| void | removeCastlingRights (Side side) |
| virtual QString | sanMoveString (const Move &move) |
| virtual bool | variantHasChanneling (Side side, int square) const |
| virtual QString | vFenIncludeString (FenNotation notation) const |
| virtual QString | vFenString (FenNotation notation) const |
| virtual void | vInitialize () |
| virtual bool | vIsLegalMove (const Move &move) |
| virtual void | vMakeMove (const Move &move, BoardTransition *transition) |
| virtual bool | vSetFenString (const QStringList &fen) |
| virtual void | vUndoMove (const Move &move) |
Protected Member Functions inherited from Chess::Board | |
| void | addToReserve (const Piece &piece, int count=1) |
| int | arraySize () const |
| bool | canMove () |
| Square | chessSquare (int index) const |
| Square | chessSquare (const QString &str) const |
| void | generateDropMoves (QVarLengthArray< Move > &moves, int pieceType) const |
| void | generateHoppingMoves (int sourceSquare, const QVarLengthArray< int > &offsets, QVarLengthArray< Move > &moves) const |
| void | generateMoves (QVarLengthArray< Move > &moves, int pieceType=Piece::NoPiece) const |
| void | generateSlidingMoves (int sourceSquare, const QVarLengthArray< int > &offsets, QVarLengthArray< Move > &moves) const |
| const Move & | lastMove () const |
| virtual int | maxPieceSymbolLength () const |
| bool | moveExists (const Move &move) const |
| Piece | pieceAt (int square) const |
| bool | pieceHasMovement (int pieceType, unsigned movement) const |
| void | removeFromReserve (const Piece &piece) |
| virtual int | reserveType (int pieceType) const |
| void | setPieceType (int type, const QString &name, const QString &symbol, unsigned movement=0, const QString &gsymbol=QString()) |
| void | setSquare (int square, Piece piece) |
| int | squareIndex (const Square &square) const |
| int | squareIndex (const QString &str) const |
| QString | squareString (int index) const |
| QString | squareString (const Square &square) const |
| void | xorKey (quint64 key) |
Protected Attributes | |
| QVarLengthArray< PawnStep, 8 > | m_pawnSteps |
Static Protected Attributes | |
| static const unsigned | BishopMovement = 4 |
| static const unsigned | KnightMovement = 2 |
| static const unsigned | RookMovement = 8 |
A board for western chess variants.
WesternBoard serves as the overclass for all western variants. In addition to possibly unique pieces, a western variant has the same pieces as standard chess, the same rules for castling, en-passant capture, promotion, etc.
WesternBoard implements the rules of standard chess, including check, checkmate, stalemate, promotion, 3-fold repetition, 50 move rule and draws by insufficient material.
|
protected |
|
protected |
| Chess::WesternBoard::WesternBoard | ( | WesternZobrist * | zobrist | ) |
Creates a new WesternBoard object.
|
protectedvirtual |
Adds pawn promotions to a move list.
This function is called when a pawn can promote by moving from sourceSquare to targetSquare. This function generates all the possible promotions and adds them to moves.
Reimplemented in Chess::SittuyinBoard, Chess::ShatranjBoard, Chess::AseanBoard, Chess::AntiBoard, Chess::SeirawanBoard, Chess::CodrusBoard, Chess::ModernBoard, Chess::ExtinctionBoard, Chess::ChancellorBoard, Chess::JanusBoard, Chess::GustavBoard, Chess::ChigorinBoard, Chess::KnightMateBoard, Chess::RifleBoard, Chess::CapablancaBoard, and Chess::LosAlamosBoard.
|
protectedvirtual |
Returns the type of piece captured by move. Returns Piece::NoPiece if move is not a capture.
Reimplemented from Chess::Board.
|
protectedvirtual |
Defines the file a king may castle to on castlingSide. Defaults: 2 (c-file) and width() - 2 (normally g-file)
Reimplemented in Chess::JanusBoard, Chess::ModernBoard, Chess::ChancellorBoard, Chess::GustavBoard, and Chess::EmbassyBoard.
|
protected |
Returns the current en-passant square.
|
protectedvirtual |
Generates pseudo-legal moves for a piece of pieceType at square square.
Implements Chess::Board.
Reimplemented in Chess::ChangeOverBoard, Chess::MakrukBoard, Chess::SimplifiedGryphonBoard, Chess::SittuyinBoard, Chess::ShatranjBoard, Chess::CourierBoard, Chess::NewZealandBoard, Chess::SeirawanBoard, Chess::CrazyhouseBoard, Chess::OukBoard, Chess::PlacementBoard, Chess::GrandBoard, Chess::GryphonBoard, Chess::PocketKnightBoard, Chess::TwoKingsEachBoard, Chess::KnightMateBoard, and Chess::HoppelPoppelBoard.
|
protectedvirtual |
Returns true if castling is allowed. The default value is true.
Reimplemented in Chess::ShatranjBoard, Chess::AntiBoard, Chess::GrandBoard, Chess::GiveawayBoard, and Chess::LosAlamosBoard.
|
protected |
Returns true if side has a right to castle on castlingSide; otherwise returns false.
|
protectedvirtual |
Returns true if a pawn can be captured en passant after an initial double step. The default value is the value of pawnHasDoubleStep().
|
virtual |
Returns the height of the board in squares.
Implements Chess::Board.
Reimplemented in Chess::GrandBoard, Chess::ModernBoard, Chess::ChancellorBoard, Chess::GustavBoard, Chess::JesonMorBoard, and Chess::LosAlamosBoard.
|
protectedvirtual |
Returns true if side is under attack at square. If square is 0, then the king square is used.
Reimplemented in Chess::MakrukBoard, Chess::CircularGryphonBoard, Chess::ShatranjBoard, Chess::CourierBoard, Chess::OukBoard, Chess::AntiBoard, Chess::ExtinctionBoard, Chess::GryphonBoard, Chess::KnightMateBoard, Chess::TwoKingsEachBoard, Chess::RifleBoard, Chess::CoRegalBoard, Chess::JesonMorBoard, Chess::ThreeKingsBoard, Chess::AtomicBoard, and Chess::RestrictedMoveBoard.
|
protectedvirtual |
Returns true if the current position is a legal position. If the position isn't legal it usually means that the last move was illegal.
Implements Chess::Board.
Reimplemented in Chess::ChangeOverBoard, Chess::SittuyinBoard, Chess::PlacementBoard, Chess::GryphonBoard, Chess::RacingKingsBoard, and Chess::ChecklessBoard.
|
protectedvirtual |
Returns true if the king can capture opposing pieces. The default value is true.
Reimplemented in Chess::AtomicBoard.
|
protectedvirtual |
Returns true if both counts of kings given by whiteKings and blackKings are correct. WesternBoard expects exactly one king per side.
Reimplemented in Chess::CircularGryphonBoard, Chess::SittuyinBoard, Chess::PlacementBoard, Chess::AntiBoard, Chess::CodrusBoard, Chess::ExtinctionBoard, Chess::HordeBoard, Chess::GryphonBoard, Chess::TwoKingsEachBoard, Chess::JesonMorBoard, and Chess::ThreeKingsBoard.
|
protected |
Returns the king square of side.
Converts a Move object into a string in Long Algebraic Notation (LAN)
Reimplemented from Chess::Board.
Reimplemented in Chess::SeirawanBoard.
Converts a string in LAN format into a Move object.
Reimplemented from Chess::Board.
Reimplemented in Chess::SeirawanBoard, and Chess::TwoKingsEachBoard.
Converts a string in SAN format into a Move object.
Implements Chess::Board.
Reimplemented in Chess::SeirawanBoard, Chess::CrazyhouseBoard, Chess::JanusBoard, Chess::AndernachBoard, Chess::TwoKingsEachBoard, Chess::KnightMateBoard, and Chess::ModernBoard.
|
protectedvirtual |
Parse castling rights given by character c of the FEN token. Returns true if successful.
Reimplemented in Chess::SeirawanBoard, and Chess::OukBoard.
Helper function for Pawn moves. Returns the count of moves of the given type that are specified in pawnSteps.
|
protectedvirtual |
Returns true if pawns have an initial double step option. The default value is true.
Reimplemented in Chess::ShatranjBoard, and Chess::LosAlamosBoard.
|
protected |
Removes castling rights at square.
If one of the players has a rook at square, the rook can't be used for castling. This function should be called when a capture happens at square.
|
protected |
Removes all castling rights of side.
|
virtual |
Returns the result of the game, or Result::NoResult if the game is in progress.
Implements Chess::Board.
Reimplemented in Chess::SittuyinBoard, Chess::KarOukBoard, Chess::MakrukBoard, Chess::AseanBoard, Chess::ShatranjBoard, Chess::AntiBoard, Chess::CodrusBoard, Chess::ExtinctionBoard, Chess::PlacementBoard, Chess::HordeBoard, Chess::NCheckBoard, Chess::TwoKingsEachBoard, Chess::KingOfTheHillBoard, Chess::JesonMorBoard, Chess::RacingKingsBoard, Chess::ThreeKingsBoard, Chess::LosersBoard, and Chess::AtomicBoard.
|
virtual |
Returns the number of consecutive reversible moves made.
The default implementation always returns -1.
Reimplemented from Chess::Board.
Converts a Move object into a string in Standard Algebraic Notation (SAN).
Implements Chess::Board.
Reimplemented in Chess::SeirawanBoard, Chess::CrazyhouseBoard, Chess::JanusBoard, Chess::AndernachBoard, and Chess::ModernBoard.
|
protectedvirtual |
Returns true if a rule provides side to insert a reserve piece at a vacated source square immediately after a move. The default value is false.
Reimplemented in Chess::SeirawanBoard.
|
protectedvirtual |
Returns FEN extensions. The default is an empty string.
This function is called by fenString() via vFenString(). Returns additional parts of the current position's (extended) FEN string which succeed the en passant field.
Reimplemented in Chess::NCheckBoard.
|
protectedvirtual |
Returns the latter part of the current position's FEN string.
This function is called by fenString(). The board state, side to move and hand pieces are handled by the base class. This function returns the rest of it, if any.
Implements Chess::Board.
Reimplemented in Chess::MakrukBoard, Chess::SeirawanBoard, Chess::OukBoard, and Chess::AseanBoard.
|
protectedvirtual |
Initializes the variant.
This function is called by initialize(). Subclasses shouldn't generally call it by themselves.
Implements Chess::Board.
Reimplemented in Chess::MakrukBoard, Chess::ShatranjBoard, Chess::CourierBoard, Chess::NCheckBoard, Chess::GryphonBoard, Chess::TwoKingsEachBoard, and Chess::AtomicBoard.
|
protectedvirtual |
Returns true if move is a legal move.
This function is called by isLegalMove() after making sure that there is a pseudo-legal move same as move. This function shouldn't check for the existence of move by generating moves.
The default implementation only checks if the position after move is legal.
Reimplemented from Chess::Board.
Reimplemented in Chess::SittuyinBoard, Chess::ShootBoard, Chess::AntiBoard, Chess::CodrusBoard, Chess::GrandBoard, Chess::HordeBoard, Chess::AtomicBoard, Chess::LosersBoard, and Chess::RestrictedMoveBoard.
|
protectedvirtual |
Makes move on the board.
This function is called by makeMove(), and should take care of everything except changing the side to move and updating the move history.
Details about piece movement, promotions, captures, drops, etc. should be stored in transition. If transition is 0 then it should be ignored.
Implements Chess::Board.
Reimplemented in Chess::MakrukBoard, Chess::SimplifiedGryphonBoard, Chess::SittuyinBoard, Chess::OukBoard, Chess::SeirawanBoard, Chess::CrazyhouseBoard, Chess::PlacementBoard, Chess::AndernachBoard, Chess::NCheckBoard, Chess::GryphonBoard, Chess::GiveawayBoard, Chess::PocketKnightBoard, Chess::AtomicBoard, and Chess::RifleBoard.
|
protectedvirtual |
Sets the board according to a FEN string.
This function is called by setFenString(). The board state, side to move and hand pieces are handled by the base class. This function reads the rest of the string, if any.
Implements Chess::Board.
Reimplemented in Chess::MakrukBoard, Chess::SittuyinBoard, Chess::OukBoard, Chess::AseanBoard, Chess::SeirawanBoard, Chess::PlacementBoard, Chess::AntiBoard, Chess::NCheckBoard, Chess::AtomicBoard, and Chess::LosersBoard.
|
protectedvirtual |
Reverses move on the board.
This function is called by undoMove() after changing the side to move to the side that made it.
Implements Chess::Board.
Reimplemented in Chess::MakrukBoard, Chess::SimplifiedGryphonBoard, Chess::SittuyinBoard, Chess::OukBoard, Chess::SeirawanBoard, Chess::CrazyhouseBoard, Chess::PlacementBoard, Chess::AndernachBoard, Chess::NCheckBoard, Chess::GryphonBoard, Chess::PocketKnightBoard, Chess::AtomicBoard, and Chess::RifleBoard.
|
virtual |
Returns the width of the board in squares.
Implements Chess::Board.
Reimplemented in Chess::CourierBoard, Chess::ModernBoard, Chess::ChancellorBoard, Chess::JanusBoard, Chess::GustavBoard, Chess::LosAlamosBoard, Chess::JesonMorBoard, and Chess::CapablancaBoard.
|
staticprotected |
Movement mask for Bishop moves.
|
staticprotected |
Movement mask for Knight moves.
|
protected |
Movement mask for Pawn moves. Lists pawn move types and relative files
Default: A Pawn can step straight ahead onto a free square or capture diagonally forward. So initialise this as { {CaptureStep, -1}, {FreeStep, 0}, {CaptureStep, 1} }
|
staticprotected |
Movement mask for Rook moves.
1.8.11