|
Cute Chess
0.1
|
A board for Shogi. More...
#include <shogiboard.h>
Public Member Functions | |
| virtual CoordinateSystem | coordinateSystem () const |
| virtual Board * | copy () const |
| virtual QString | defaultFenString () const |
| virtual int | height () const |
| virtual QList< Piece > | reservePieceTypes () const |
| virtual Result | result () |
| ShogiBoard () | |
| virtual QString | variant () const |
| virtual bool | variantHasDrops () const |
| virtual bool | variantHasOptionalPromotions () const |
| virtual int | width () const |
Public Member Functions inherited from Chess::Board | |
| Board (Zobrist *zobrist) | |
| 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 |
| void | reset () |
| virtual int | reversibleMoveCount () const |
| 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 Types | |
| enum | ShogiPieceType { Pawn = 1, Lance, Knight, SilverGeneral, GoldGeneral, Bishop, Rook, King, PromotedPawn, PromotedLance, PromotedKnight, PromotedSilver, PromotedBishop, PromotedRook } |
Protected Member Functions | |
| virtual void | generateMovesForPiece (QVarLengthArray< Move > &moves, int pieceType, int square) const |
| virtual bool | hasImpassePointRule () const |
| virtual Result | impassePointRule (int points, int pieces) const |
| virtual bool | inCheck (Side side, int square=0) const |
| virtual bool | isLegalPosition () |
| virtual QString | lanMoveString (const Move &move) |
| virtual Move | moveFromLanString (const QString &str) |
| virtual Move | moveFromSanString (const QString &str) |
| virtual int | normalPieceType (int type) const |
| virtual int | promotedPieceType (int type) const |
| virtual int | promotionRank () const |
| virtual bool | ranksAreAllowed () const |
| virtual int | reserveType (int pieceType) const |
| virtual QString | sanMoveString (const Move &move) |
| 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 () |
| virtual int | captureType (const Move &move) const |
| 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) |
| 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 | BishopMovement = 4 |
| static const unsigned | FerzMovement = 16 |
| static const unsigned | GoldMovement = 512 |
| static const unsigned | KnightMovement = 2 |
| static const unsigned | LanceMovement = 128 |
| static const unsigned | RookMovement = 8 |
| static const unsigned | SilverMovement = 256 |
| static const unsigned | WazirMovement = 64 |
Additional Inherited Members | |
Public Types inherited from Chess::Board | |
| enum | CoordinateSystem { NormalCoordinates, InvertedCoordinates } |
| enum | FenNotation { XFen, ShredderFen } |
| enum | MoveNotation { StandardAlgebraic, LongAlgebraic } |
A board for Shogi.
Shōgi is a Japanese form of chess where captured pieces can be brought back ("dropped") into the game,
It is played on a 9x9 board. The piece set traditionally consists of flat five-sided pieces with their names written on them. Such sets have been in use at least since the 11th century AD.
Shōgi emerged from the earlier game of Shō Shōgi by the reinsertion of captured pieces as own pieces (15th century AD) and removal of the Drunk Elephant piece by imperial order (16th century AD).
Shōgi has eight types of original pieces. Either side starts with a set of 9 x Pawn (on the third rank), 2 x Lance, 2 x Knight, 2 x Silver (General), 2 x Gold (General), 1 x Bishop, 1 x Rook, 1 x King. The latter three types move like in standard chess. The Pawn moves and captures 1 square straight forward. The Lance moves and captures like a Rook, but only forwards. Similarly, the Knight leaps like a chess Knight, but only in the two forward directions. The Silver goes one square diagonally or forward (5 moves). The Gold goes like a King but not diagonally backward (6 moves).
All these pieces except King and Gold General have the option to promote if their move starts or ends in the opponent's third of the board. A Pawn or Lance reaching the highest rank must promote. A Knight must promote when reaching the highest two ranks. All promoted Pawns, Lances, Knights, and Silvers move like Gold Generals. A promoted Bishop moves like Bishop or King, a promoted Rook like Rook or King.
A captured piece switches sides and goes into the hand of the capturing side. Promoted pieces change back to their original types. A player may drop a piece in hand onto an empty square of the board. This counts as a move. Pawns, Lances, and Knights must not be dropped onto the highest ranks where they would be unable to move. Pawns must not be dropped onto files with own Pawns and must not be dropped to give mate immediately.
A side must avert an attack on their King (check, ote 王手) immediately. It is forbidden to enter check. If there is no legal move to avert check then the side in check loses by checkmate (tsumi 詰み).
When a game position occurs four times with the same player to move and the same pieces in hand for each player the game is drawn by repetition (sennichite, 千日手). If the situation has arisen from a perpetual check then the side giving check loses.
|
protected |
Piece types for Shogi.
| Chess::ShogiBoard::ShogiBoard | ( | ) |
Creates a new ShogiBoard object.
|
virtual |
Returns the coordinate system used in the variant.
Reimplemented from Chess::Board.
|
virtual |
Creates and returns a deep copy of this board.
Implements Chess::Board.
Reimplemented in Chess::DobutsuShogiBoard, Chess::EuroShogiBoard, Chess::JudkinsShogiBoard, and Chess::MiniShogiBoard.
|
virtual |
Returns the variant's default starting FEN string.
Implements Chess::Board.
Reimplemented in Chess::DobutsuShogiBoard, Chess::EuroShogiBoard, Chess::JudkinsShogiBoard, and Chess::MiniShogiBoard.
|
protectedvirtual |
Generates pseudo-legal moves for a piece of pieceType at square square.
Implements Chess::Board.
Reimplemented in Chess::EuroShogiBoard.
|
protectedvirtual |
Returns true if the impassé point rule is active else false.
|
virtual |
Returns the height of the board in squares.
Implements Chess::Board.
Reimplemented in Chess::DobutsuShogiBoard, Chess::EuroShogiBoard, Chess::JudkinsShogiBoard, and Chess::MiniShogiBoard.
|
protectedvirtual |
Criteria of impasse rule limit given material value of points and the number of pieces of the side to move in the promotion zone.
Reimplemented in Chess::JudkinsShogiBoard.
|
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::DobutsuShogiBoard.
Converts a Move object into a string in Long Algebraic Notation (LAN)
Reimplemented from Chess::Board.
Converts a string in LAN format into a Move object.
Reimplemented from Chess::Board.
Converts a string in SAN format into a Move object.
Implements Chess::Board.
|
protectedvirtual |
Returns original piece type corresponding to promoted type.
|
protectedvirtual |
Returns promoted piece type corresponding to normal type.
Reimplemented in Chess::DobutsuShogiBoard.
|
protectedvirtual |
Returns the lowest (relative) rank of the promotion zone.
Reimplemented in Chess::EuroShogiBoard.
|
protectedvirtual |
Returns whether the current position has no pieces on forbidden ranks.
Reimplemented in Chess::EuroShogiBoard.
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.
|
protectedvirtual |
Returns the reserve piece type corresponding to pieceType.
The returned value is the type of piece a player receives (in variants that have piece drops) when he captures a piece of type pieceType.
The default value is pieceType.
Reimplemented from Chess::Board.
|
virtual |
Returns the result of the game, or Result::NoResult if the game is in progress.
Implements Chess::Board.
Reimplemented in Chess::DobutsuShogiBoard, Chess::EuroShogiBoard, and Chess::MiniShogiBoard.
Converts a Move object into a string in Standard Algebraic Notation (SAN).
Implements Chess::Board.
|
virtual |
Returns the name of the chess variant.
Implements Chess::Board.
Reimplemented in Chess::DobutsuShogiBoard, Chess::EuroShogiBoard, Chess::JudkinsShogiBoard, and Chess::MiniShogiBoard.
|
virtual |
Returns true if the variant allows piece drops. The default value is false.
Reimplemented from Chess::Board.
|
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.
|
protectedvirtual |
Initializes the variant.
This function is called by initialize(). Subclasses shouldn't generally call it by themselves.
Implements Chess::Board.
Reimplemented in Chess::EuroShogiBoard.
|
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.
|
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.
|
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.
|
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.
|
virtual |
Returns the width of the board in squares.
Implements Chess::Board.
Reimplemented in Chess::DobutsuShogiBoard, Chess::EuroShogiBoard, Chess::JudkinsShogiBoard, and Chess::MiniShogiBoard.
|
staticprotected |
Movement mask for Bishop moves.
|
staticprotected |
Movement mask for Ferz move pattern.
|
staticprotected |
Movement mask for Gold General moves.
|
staticprotected |
Movement mask for Knight moves.
|
staticprotected |
Movement mask for Lance moves.
|
staticprotected |
Movement mask for Rook moves.
|
staticprotected |
Movement mask for Silver General moves.
|
staticprotected |
Movement mask for Wazir move pattern.
1.8.14