Cute Chess 0.1
shogiboard.h
1/*
2 This file is part of Cute Chess.
3 Copyright (C) 2008-2018 Cute Chess authors
4
5 Cute Chess is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Cute Chess is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef SHOGIBOARD_H
20#define SHOGIBOARD_H
21
22#include "board.h"
23
24namespace Chess {
25
75class LIB_EXPORT ShogiBoard : public Board
76{
77 public:
79 ShogiBoard();
80
81 // Inherited from Board
82 virtual Board* copy() const;
83 virtual QList<Piece> reservePieceTypes() const;
84 virtual QString variant() const;
85 virtual bool variantHasDrops() const;
86 virtual bool variantHasOptionalPromotions() const;
87 virtual QString defaultFenString() const;
88 virtual CoordinateSystem coordinateSystem() const;
89 virtual int width() const;
90 virtual int height() const;
91 virtual Result result();
92
93 protected:
98 {
99 Pawn = 1,
106 King,
108
117 PromotedRook
118 };
119
121 static const unsigned KnightMovement = 2;
123 static const unsigned BishopMovement = 4;
125 static const unsigned RookMovement = 8;
127 static const unsigned FerzMovement = 16;
129 static const unsigned WazirMovement = 64;
131 static const unsigned LanceMovement = 128;
133 static const unsigned SilverMovement = 256;
135 static const unsigned GoldMovement = 512;
136
140 virtual int promotedPieceType(int type) const;
144 virtual int promotionRank() const;
148 virtual int normalPieceType(int type) const;
153 virtual bool ranksAreAllowed() const;
157 virtual bool hasImpassePointRule() const;
163 virtual Result impassePointRule(int points, int pieces) const;
164
165 // Inherited from Board
166 virtual int reserveType(int pieceType) const;
167 virtual void vInitialize();
168 virtual QString vFenString(FenNotation notation) const;
169 virtual bool vSetFenString(const QStringList& fen);
170 virtual QString lanMoveString(const Move& move);
171 virtual QString sanMoveString(const Move& move);
172 virtual Move moveFromLanString(const QString& str);
173 virtual Move moveFromSanString(const QString& str);
174 virtual void vMakeMove(const Move& move,
175 BoardTransition* transition);
176 virtual void vUndoMove(const Move& move);
177 virtual void generateMovesForPiece(QVarLengthArray<Move>& moves,
178 int pieceType,
179 int square) const;
180 virtual bool isLegalPosition();
181 virtual bool vIsLegalMove(const Move& move);
182 virtual bool inCheck(Side side, int square = 0) const;
183
184 private:
185 // Data for reversing/unmaking a move
186 struct MoveData
187 {
188 Piece capture;
189 };
190
191 bool rankIsAllowed(int pieceType, int square) const;
192 bool fileIsAllowed(int pieceType, int square) const;
193 bool inPromotionZone(int square) const;
194 Result resultFromImpassePointRule() const;
195
196 int m_kingSquare[2];
197 int m_promotionRank;
198 int m_minIndex;
199 int m_maxIndex;
200 int m_plyOffset;
201 bool m_multiDigitNotation;
202 bool m_hasImpassePointRule;
203
204 QVarLengthArray<int> m_bishopOffsets;
205 QVarLengthArray<int> m_rookOffsets;
206 QVarLengthArray<int> m_lanceOffsets[2];
207 QVarLengthArray<int> m_knightOffsets[2];
208 QVarLengthArray<int> m_silverGeneralOffsets[2];
209 QVarLengthArray<int> m_goldGeneralOffsets[2];
210 QVector<MoveData> m_history;
211};
212
213} // namespace Chess
214#endif // SHOGIBOARD_H
Details of a board transition caused by a move.
Definition: boardtransition.h:41
An internal chessboard class.
Definition: board.h:58
FenNotation
Definition: board.h:94
CoordinateSystem
Definition: board.h:64
A small and efficient chessmove class.
Definition: move.h:43
A chess piece.
Definition: piece.h:41
The result of a chess game.
Definition: result.h:35
A board for Shogi.
Definition: shogiboard.h:76
ShogiPieceType
Definition: shogiboard.h:98
@ Knight
Cassia Horse N (Keima) KE.
Definition: shogiboard.h:101
@ PromotedLance
Promoted Incense +L (Narikyō) NY.
Definition: shogiboard.h:113
@ PromotedBishop
Dragon Horse +B (Ryūma) UM.
Definition: shogiboard.h:116
@ PromotedPawn
Reaches Gold +P (Tokin) TO.
Definition: shogiboard.h:112
@ PromotedKnight
Promoted Cassia +N (Narikei) NK.
Definition: shogiboard.h:114
@ SilverGeneral
Silver General S (Ginshō) GI.
Definition: shogiboard.h:102
@ Bishop
Angle Mover B (Kakugyō) KA.
Definition: shogiboard.h:104
@ Lance
Incense Chariot L (Kyōsha) KY.
Definition: shogiboard.h:100
@ Rook
Flying Chariot R (Hisha) HI.
Definition: shogiboard.h:105
@ PromotedSilver
Promoted Silver +S (Narigin) NG.
Definition: shogiboard.h:115
@ GoldGeneral
Gold General G (Kinshō) KI.
Definition: shogiboard.h:103
The side or color of a chess player.
Definition: side.h:36