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

A board for Losing Chess, LC1 (main variant, international rules) a.k.a Antichess. More...

#include <antiboard.h>

Inheritance diagram for Chess::AntiBoard:
Chess::StandardBoard Chess::WesternBoard Chess::Board Chess::GiveawayBoard Chess::SuicideBoard Chess::CodrusBoard

Public Member Functions

 AntiBoard ()
 
virtual Boardcopy () const
 
virtual QString defaultFenString () const
 
virtual Result result ()
 
virtual QString variant () const
 
- Public Member Functions inherited from Chess::StandardBoard
 StandardBoard ()
 
virtual Result tablebaseResult (unsigned int *dtm=nullptr) 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
 
void undoMove ()
 
virtual Side upperCaseSide () const
 
virtual bool variantHasDrops () const
 
virtual bool variantHasOptionalPromotions () const
 
virtual bool variantHasWallSquares () const
 
virtual ~Board ()
 

Protected Member Functions

virtual void addPromotions (int sourceSquare, int targetSquare, QVarLengthArray< Move > &moves) const
 
virtual bool hasCastling () const
 
virtual bool inCheck (Side side, int square=0) const
 
virtual bool kingsCountAssertion (int whiteKings, int blackKings) const
 
virtual bool vIsLegalMove (const Move &move)
 
virtual Result vResultOfStalemate () const
 
virtual bool vSetFenString (const QStringList &fen)
 
- Protected Member Functions inherited from Chess::WesternBoard
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
 
bool hasCastlingRight (Side side, CastlingSide castlingSide) const
 
virtual bool hasEnPassantCaptures () const
 
virtual bool isLegalPosition ()
 
virtual bool kingCanCapture () 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 void vMakeMove (const Move &move, BoardTransition *transition)
 
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)
 

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 Types inherited from Chess::WesternBoard
enum  CastlingSide { QueenSide, KingSide, NoCastlingSide }
 
enum  StepType { NoStep = 0, FreeStep = 1, CaptureStep = 2 }
 
- Protected Attributes inherited from Chess::WesternBoard
QVarLengthArray< PawnStep, 8 > m_pawnSteps
 
- 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 Losing Chess, LC1 (main variant, international rules) a.k.a Antichess.

Losing Chess is a variant of standard chess but has a different aim.

The side that has no legal moves wins, either by losing all pieces or by being stalemated.

The king has no royal powers, so there is no check and the king can be captured. Pawns can also promote to king. Castling is not allowed. If a side can capture then they must make a capture move.

Note
Rules: https://en.wikipedia.org/wiki/Losing_chess#Rules_.28main_variant.29

Losing Chess is believed to be several centuries old. Giveaway Chess and Suicide Chess are variants of Losing Chess.

See also
GiveawayBoard
SuicideBoard

AntiBoard uses Polyglot-compatible zobrist position keys, so adequate opening books in Polyglot format can be used.

Note
Standard Chess Rules: http://www.fide.com/component/handbook/?id=124&view=article
See also
PolyglotBook

Constructor & Destructor Documentation

Chess::AntiBoard::AntiBoard ( )

Creates a new AntiBoard object.

Member Function Documentation

void Chess::AntiBoard::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::CodrusBoard.

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

Creates and returns a deep copy of this board.

Reimplemented from Chess::StandardBoard.

Reimplemented in Chess::CodrusBoard, Chess::SuicideBoard, and Chess::GiveawayBoard.

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

Returns the variant's default starting FEN string.

Reimplemented from Chess::StandardBoard.

Reimplemented in Chess::GiveawayBoard.

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

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

See also
ShatranjBoard

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::GiveawayBoard.

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

bool Chess::AntiBoard::kingsCountAssertion ( int  whiteKings,
int  blackKings 
) const
protectedvirtual

Returns true if both counts of kings given by whiteKings and blackKings are correct. WesternBoard expects exactly one king per side.

See also
AntiBoard
HordeBoard

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::CodrusBoard.

Result Chess::AntiBoard::result ( )
virtual

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

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::CodrusBoard.

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

Returns the name of the chess variant.

Reimplemented from Chess::StandardBoard.

Reimplemented in Chess::CodrusBoard, Chess::SuicideBoard, and Chess::GiveawayBoard.

bool Chess::AntiBoard::vIsLegalMove ( const Move move)
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::WesternBoard.

Reimplemented in Chess::CodrusBoard.

Result Chess::AntiBoard::vResultOfStalemate ( ) const
protectedvirtual

Rules stalemate outcome.

Reimplemented in Chess::CodrusBoard, and Chess::SuicideBoard.

bool Chess::AntiBoard::vSetFenString ( const QStringList fen)
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.

Reimplemented from Chess::WesternBoard.


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