Cute Chess  0.1
Public Member Functions | Protected Types | Protected Member Functions | Static Protected Attributes | List of all members
Chess::ShatranjBoard Class Reference

A board for Shatranj. More...

#include <shatranjboard.h>

Inheritance diagram for Chess::ShatranjBoard:
Chess::WesternBoard Chess::Board Chess::CourierBoard Chess::MakrukBoard Chess::AiWokBoard Chess::AseanBoard Chess::OukBoard Chess::SittuyinBoard Chess::KarOukBoard

Public Member Functions

virtual Boardcopy () const
 
virtual QString defaultFenString () const
 
virtual Result result ()
 
 ShatranjBoard ()
 
virtual QString variant () const
 
- Public Member Functions inherited from Chess::WesternBoard
virtual int height () const
 
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
 
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< MovelegalMoves ()
 
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< PiecereservePieceTypes () 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 bool variantHasDrops () const
 
virtual bool variantHasOptionalPromotions () const
 
virtual bool variantHasWallSquares () const
 
virtual ~Board ()
 

Protected Types

enum  ShatranjPieceType { Ferz = Queen, Alfil = Bishop }
 
- Protected Types inherited from Chess::WesternBoard
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 bool canBareOpponentKing ()
 
virtual void generateMovesForPiece (QVarLengthArray< Move > &moves, int pieceType, int square) const
 
virtual bool hasCastling () const
 
virtual bool inCheck (Side side, int square=0) const
 
virtual bool pawnHasDoubleStep () const
 
virtual void vInitialize ()
 
- Protected Member Functions inherited from Chess::WesternBoard
virtual int captureType (const Move &move) const
 
virtual int castlingFile (CastlingSide castlingSide) const
 
int enpassantSquare () const
 
bool hasCastlingRight (Side side, CastlingSide castlingSide) const
 
virtual bool hasEnPassantCaptures () 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
 
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 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 MovelastMove () 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)
 

Static Protected Attributes

static const unsigned AlfilMovement = 32
 
static const unsigned FerzMovement = 16
 
- Static Protected Attributes inherited from Chess::WesternBoard
static const unsigned BishopMovement = 4
 
static const unsigned KnightMovement = 2
 
static const unsigned RookMovement = 8
 

Additional Inherited Members

- Public Types inherited from Chess::WesternBoard
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 }
 
- Protected Attributes inherited from Chess::WesternBoard
QVarLengthArray< PawnStep, 8 > m_pawnSteps
 

Detailed Description

A board for Shatranj.

Shatranj evolved from the Indian game Chaturanga and is the immediate ancestor of standard chess.

This game spread from India to Persia (named Chatrang, Shatrang) and then to Arabia as Shatranj. Shatranj rules, theory and problems (mansubat) are well documented. The game had stable rules and was popular for nine centuries in Arabia (about AD 650-1500). There were Arabian professional master players, player grades and handicap play.

Spanish and Italian players changed some rules of the game during the 15th and 16th century resulting in the much faster modern chess.

Focussing on the differences to standard chess:

Instead of the Queen Shatranj has the Ferz (Counselor) which only moves one square diagonally. There are no Bishops but Alfils (War Elephants), which leap two squares diagonally. The kings may start either on the d-file or e-file, facing each other. Shatranj has no pawn double steps and no castling. A Pawn can only promote to Ferz.

A side wins if their opponent cannot make a legal move (mate or stalemate), or has no pieces left besides their "bare" King. However a bare King is given one chance to get level by the next move: Two bare kings is a draw.

Note
Rules: http://en.wikipedia.org/wiki/Shatranj

Member Enumeration Documentation

Special piece types for Shatranj variants.

Enumerator
Ferz 

Ferz (leaps 1 square diag.) overrides Queen.

Alfil (leaps 2 squares diag.) overrides Bishop

Constructor & Destructor Documentation

Chess::ShatranjBoard::ShatranjBoard ( )

Creates a new ShatranjBoard object.

Member Function Documentation

void Chess::ShatranjBoard::addPromotions ( int  sourceSquare,
int  targetSquare,
QVarLengthArray< Move > &  moves 
) const
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 from Chess::WesternBoard.

Reimplemented in Chess::SittuyinBoard, and Chess::AseanBoard.

bool Chess::ShatranjBoard::canBareOpponentKing ( )
protectedvirtual

Returns true if the side to move can bare the opponent king with this move and the rules allow a counter bare king move else false.

Board * Chess::ShatranjBoard::copy ( ) const
virtual

Creates and returns a deep copy of this board.

Implements Chess::Board.

Reimplemented in Chess::KarOukBoard, Chess::MakrukBoard, Chess::SittuyinBoard, Chess::AseanBoard, Chess::CourierBoard, Chess::OukBoard, and Chess::AiWokBoard.

QString Chess::ShatranjBoard::defaultFenString ( ) const
virtual

Returns the variant's default starting FEN string.

Implements Chess::Board.

Reimplemented in Chess::KarOukBoard, Chess::MakrukBoard, Chess::SittuyinBoard, Chess::AseanBoard, Chess::CourierBoard, Chess::OukBoard, and Chess::AiWokBoard.

void Chess::ShatranjBoard::generateMovesForPiece ( QVarLengthArray< Move > &  moves,
int  pieceType,
int  square 
) const
protectedvirtual

Generates pseudo-legal moves for a piece of pieceType at square square.

Note
It doesn't matter if square doesn't contain a piece of pieceType, the move generator ignores it.

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::MakrukBoard, Chess::SittuyinBoard, Chess::CourierBoard, and Chess::OukBoard.

bool Chess::ShatranjBoard::hasCastling ( ) const
protectedvirtual

Returns true if castling is allowed. The default value is true.

See also
ShatranjBoard

Reimplemented from Chess::WesternBoard.

bool Chess::ShatranjBoard::inCheck ( Side  side,
int  square = 0 
) const
protectedvirtual

Returns true if side is under attack at square. If square is 0, then the king square is used.

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::MakrukBoard, Chess::CourierBoard, and Chess::OukBoard.

bool Chess::ShatranjBoard::pawnHasDoubleStep ( ) const
protectedvirtual

Returns true if pawns have an initial double step option. The default value is true.

See also
ShatranjBoard

Reimplemented from Chess::WesternBoard.

Result Chess::ShatranjBoard::result ( )
virtual

Returns the result of the game, or Result::NoResult if the game is in progress.

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::SittuyinBoard, Chess::KarOukBoard, Chess::MakrukBoard, and Chess::AseanBoard.

QString Chess::ShatranjBoard::variant ( ) const
virtual
void Chess::ShatranjBoard::vInitialize ( )
protectedvirtual

Initializes the variant.

This function is called by initialize(). Subclasses shouldn't generally call it by themselves.

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::MakrukBoard, and Chess::CourierBoard.

Member Data Documentation

const unsigned Chess::ShatranjBoard::AlfilMovement = 32
staticprotected

Movement mask for Alfil moves.

const unsigned Chess::ShatranjBoard::FerzMovement = 16
staticprotected

Movement mask for Ferz moves.


The documentation for this class was generated from the following files: