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

A board for Ouk Chatrang (Ouk Khmer, Cambodian Chess) More...

#include <oukboard.h>

Inheritance diagram for Chess::OukBoard:
Chess::MakrukBoard Chess::ShatranjBoard Chess::WesternBoard Chess::Board Chess::KarOukBoard

Public Member Functions

virtual Boardcopy () const
 
virtual QString defaultFenString () const
 
 OukBoard ()
 
virtual QString variant () const
 
- Public Member Functions inherited from Chess::MakrukBoard
 MakrukBoard ()
 
virtual Result result ()
 
- Public Member Functions inherited from Chess::ShatranjBoard
 ShatranjBoard ()
 
- 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  OukPieceType {
  Fish = Pawn, Horse = Knight, Pillar = Bishop, Boat = Rook,
  Maiden = Queen, King
}
 
- Protected Types inherited from Chess::MakrukBoard
enum  CountingRules { Makruk, BareKing }
 
enum  MakrukPieceType {
  Bia = Pawn, Ma = Knight, Khon = Bishop, Rua = Rook,
  Met = Queen, Khun = King
}
 
- Protected Types inherited from Chess::ShatranjBoard
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 CountingRules countingRules () const
 
virtual void generateMovesForPiece (QVarLengthArray< Move > &moves, int pieceType, int square) const
 
virtual bool inCheck (Side side, int square=0) const
 
virtual bool parseCastlingRights (QChar c)
 
virtual QString vFenString (FenNotation notation) const
 
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::MakrukBoard
virtual int countingLimit () const
 
virtual void generatePawnMoves (int sourceSquare, QVarLengthArray< Move > &moves) const
 
void initHistory ()
 
virtual bool insufficientMaterial () const
 
int pieceCount (Side side=Side::NoSide, int pieceType=Piece::NoPiece) const
 
virtual int promotionRank (int file=0) const
 
Result resultFromCounting () const
 
void setAllPieceCounters ()
 
virtual void vInitialize ()
 
- Protected Member Functions inherited from Chess::ShatranjBoard
virtual void addPromotions (int sourceSquare, int targetSquare, QVarLengthArray< Move > &moves) const
 
virtual bool canBareOpponentKing ()
 
virtual bool hasCastling () const
 
virtual bool pawnHasDoubleStep () const
 
- 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)
 
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 bool vIsLegalMove (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)
 

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
 
- Static Protected Attributes inherited from Chess::MakrukBoard
static const unsigned SilverGeneralMovement = 256
 
- Static Protected Attributes inherited from Chess::ShatranjBoard
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
 

Detailed Description

A board for Ouk Chatrang (Ouk Khmer, Cambodian Chess)

Ouk Chatrang is a variant of chess popular and with a long tradition in Cambodia. It is closely related to Chaturanga and Makruk.

Cambodian Chess (Ouk) and Thai Chess (Makruk) are essentially the same game, but the pieces are named differently.

Ouk has additional moves, which have been abandoned in Makruk:

The King has the option to make an initial leap sideways like a Horse (Knight), but only if not in check. The Advisor (Maiden, Neang) may leap straight forward two squares on its initial move. These moves cannot capture.

Note
Rules: http://history.chess.free.fr/cambodian/Cambodian%20Chess%20Games.htm http://www.khmerinstitute.com/culture/ok.html
See also
MakrukBoard
ShatranjBoard

Member Enumeration Documentation

Piece types for ouk variants.

Enumerator
Fish 

Trey, Trei.

Horse 

Ses, Se.

Pillar 

Kol, Koul.

Boat 

Tuuk.

Maiden 

Neang (Met)

King 

Sdaach, Ang.

Constructor & Destructor Documentation

Chess::OukBoard::OukBoard ( )

Creates a new OukBoard object.

Pawn

Knight

replaces Alfil

Rook

Queen, Counselor, Mantri, Met

King

Member Function Documentation

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

Creates and returns a deep copy of this board.

Reimplemented from Chess::MakrukBoard.

Reimplemented in Chess::KarOukBoard.

MakrukBoard::CountingRules Chess::OukBoard::countingRules ( ) const
protectedvirtual

Returns type of counting rules to apply. Default: Makruk.

See also
OukBoard

Reimplemented from Chess::MakrukBoard.

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

Returns the variant's default starting FEN string.

Reimplemented from Chess::MakrukBoard.

Reimplemented in Chess::KarOukBoard.

void Chess::OukBoard::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::MakrukBoard.

bool Chess::OukBoard::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::MakrukBoard.

bool Chess::OukBoard::parseCastlingRights ( QChar  c)
protectedvirtual

Parse castling rights given by character c of the FEN token. Returns true if successful.

Reimplemented from Chess::WesternBoard.

QString Chess::OukBoard::variant ( ) const
virtual

Returns the name of the chess variant.

Reimplemented from Chess::MakrukBoard.

Reimplemented in Chess::KarOukBoard.

QString Chess::OukBoard::vFenString ( Board::FenNotation  notation) const
protectedvirtual

Ouk Chatrang has special initial moves for King (Ang) and Maiden (Neang). The initial files of unmoved Kings and Maidens are listed in the castling field of the FEN. So it is status "DEde" for the starting position.

Reimplemented from Chess::MakrukBoard.

void Chess::OukBoard::vMakeMove ( const Move move,
BoardTransition transition 
)
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.

Reimplemented from Chess::MakrukBoard.

bool Chess::OukBoard::vSetFenString ( const QStringList inputFen)
protectedvirtual

This method reads FEN with full Makruk/Ouk counting support (A), standard FEN (B), and short FEN-like notation without castling rights and en passant fields (C). The latter two use Western counting and ignore Makruk counting.

A: rnsmksnr/8/pppppppp/8/8/PPPPPPPP/8/RNSKMSNR w - 0 0 1

B: rnsmksnr/8/pppppppp/8/8/PPPPPPPP/8/RNSKMSNR w - - 0 1 C: rnsmksnr/8/pppppppp/8/8/PPPPPPPP/8/RNSKMSNR w 0 1

FEN with Ouk initial move rights instead of castling rights are supported by OukBoard. Format C does not carry this information. Also see OukBoard.

Reimplemented from Chess::MakrukBoard.

void Chess::OukBoard::vUndoMove ( const Move move)
protectedvirtual

Reverses move on the board.

This function is called by undoMove() after changing the side to move to the side that made it.

Note
Unlike vMakeMove(), this function doesn't require subclasses to update the zobrist position key.

Reimplemented from Chess::MakrukBoard.


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