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

A base board for games with the goal of lining up a number of pieces. More...

#include <connectboard.h>

Inheritance diagram for Chess::ConnectBoard:
Chess::WesternBoard Chess::Board Chess::GomokuFreestyleBoard Chess::TicTacToeBoard Chess::GomokuBoard

Public Member Functions

 ConnectBoard ()
 
virtual Boardcopy () const
 
virtual QString defaultFenString () const
 
virtual int height () const
 
virtual QList< Chess::PiecereservePieceTypes () const
 
virtual Result result ()
 
virtual QString variant () const
 
virtual bool variantHasDrops () const
 
virtual int width () const
 
- Public Member Functions inherited from Chess::WesternBoard
virtual int reversibleMoveCount () const
 
 WesternBoard (WesternZobrist *zobrist)
 
- 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
 
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 variantHasWallSquares () const
 
virtual ~Board ()
 

Protected Member Functions

virtual int connectToWin () const
 
virtual void generateMovesForPiece (QVarLengthArray< Chess::Move > &moves, int pieceType, int square) const
 
virtual bool hasGravity () const
 
virtual bool isLegalPosition ()
 
bool kingsCountAssertion (int, int) const
 
virtual bool overlinesWin (Side side) const
 
virtual int requiredNumberOfPieces () const
 
virtual void vInitialize ()
 
virtual void vMakeMove (const Chess::Move &move, Chess::BoardTransition *transition)
 
virtual bool vSetFenString (const QStringList &fen)
 
virtual void vUndoMove (const Chess::Move &move)
 
- Protected Member Functions inherited from Chess::WesternBoard
virtual void addPromotions (int sourceSquare, int targetSquare, QVarLengthArray< Move > &moves) const
 
virtual int captureType (const Move &move) const
 
virtual int castlingFile (CastlingSide castlingSide) const
 
virtual bool defendedByKnight (Side side, int square) const
 
int enpassantSquare () 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 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 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
 
virtual bool pieceHasCaptureMovement (Piece piece, int square, unsigned movement) const
 
virtual bool pieceHasMovement (Piece piece, int square, unsigned movement) const
 
virtual bool pieceTypeHasMovement (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 base board for games with the goal of lining up a number of pieces.

A board for Cfour

Cfour is an abstract strategy game

Two players take turns to drop pieces onto the board of 7 files and 6 ranks. Every piece goes to the lowest unoccupied rank of the chosen file. The side that connects four pieces horizontally, vertically or diagonally wins.

Introduced in 1973/1974 by Howard Wexler and Ned Strongin, USA.

Constructor & Destructor Documentation

◆ ConnectBoard()

Chess::ConnectBoard::ConnectBoard ( )

Creates a new ConnectBoard object.

Member Function Documentation

◆ connectToWin()

int Chess::ConnectBoard::connectToWin ( ) const
protectedvirtual

Returns the number of pieces to connect in order to win

Reimplemented in Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.

◆ copy()

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

Creates and returns a deep copy of this board.

Implements Chess::Board.

Reimplemented in Chess::GomokuBoard, Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.

◆ defaultFenString()

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

Returns the variant's default starting FEN string.

Implements Chess::Board.

Reimplemented in Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.

◆ generateMovesForPiece()

void Chess::ConnectBoard::generateMovesForPiece ( QVarLengthArray< Chess::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.

◆ hasGravity()

bool Chess::ConnectBoard::hasGravity ( ) const
protectedvirtual

Returns true if all pieces gravitate towards the first rank. No empty squares can occur between pieces of the same file. Returns false if this condition is not met.

Reimplemented in Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.

◆ height()

int Chess::ConnectBoard::height ( ) const
virtual

Returns the height of the board in squares.

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.

◆ isLegalPosition()

bool Chess::ConnectBoard::isLegalPosition ( )
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.

Reimplemented from Chess::WesternBoard.

◆ kingsCountAssertion()

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

◆ overlinesWin()

bool Chess::ConnectBoard::overlinesWin ( Side  side) const
protectedvirtual

Returns true if the game is won in case the number of connected pieces of side side exceeds the required number, else false. Default: true.

Reimplemented in Chess::GomokuBoard.

◆ requiredNumberOfPieces()

int Chess::ConnectBoard::requiredNumberOfPieces ( ) const
protectedvirtual

The return value determines the total number of pieces. No determination is made if -1 is returned.

◆ reservePieceTypes()

QList< Chess::Piece > Chess::ConnectBoard::reservePieceTypes ( ) const
virtual

Returns a list of piece types that can be in the reserve, ie. captured pieces that can be dropped on the board.

The default implementation returns an empty list.

Reimplemented from Chess::Board.

◆ result()

Result Chess::ConnectBoard::result ( )
virtual

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

Reimplemented from Chess::WesternBoard.

◆ variant()

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

Returns the name of the chess variant.

Implements Chess::Board.

Reimplemented in Chess::GomokuBoard, Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.

◆ variantHasDrops()

bool Chess::ConnectBoard::variantHasDrops ( ) const
virtual

Returns true if the variant allows piece drops. The default value is false.

See also
CrazyhouseBoard

Reimplemented from Chess::Board.

◆ vInitialize()

void Chess::ConnectBoard::vInitialize ( )
protectedvirtual

Initializes the variant.

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

Reimplemented from Chess::WesternBoard.

◆ vMakeMove()

void Chess::ConnectBoard::vMakeMove ( const Chess::Move move,
Chess::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::WesternBoard.

◆ vSetFenString()

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

◆ vUndoMove()

void Chess::ConnectBoard::vUndoMove ( const Chess::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::WesternBoard.

◆ width()

int Chess::ConnectBoard::width ( ) const
virtual

Returns the width of the board in squares.

Reimplemented from Chess::WesternBoard.

Reimplemented in Chess::GomokuFreestyleBoard, and Chess::TicTacToeBoard.


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