Cute Chess  0.1
makrukboard.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 MAKRUKBOARD_H
20 #define MAKRUKBOARD_H
21 
22 #include "shatranjboard.h"
23 
24 namespace Chess {
25 
78 class LIB_EXPORT MakrukBoard : public ShatranjBoard
79 {
80  public:
82  MakrukBoard();
83 
84  // Inherited from ShatranjBoard
85  virtual Board* copy() const;
86  virtual QString variant() const;
87  virtual QString defaultFenString() const;
88  virtual Result result();
89 
90  protected:
93  {
94  Bia = Pawn,
95  Ma = Knight,
96  Khon = Bishop,
97  Rua = Rook,
98  Met = Queen,
99  Khun = King
100  };
101 
103  static const unsigned SilverGeneralMovement = 256;
112  virtual int promotionRank(int file = 0) const;
120  int pieceCount(Side side = Side::NoSide,
121  int pieceType = Piece::NoPiece) const;
126  virtual int countingLimit() const;
130  enum CountingRules {Makruk, BareKing};
135  virtual CountingRules countingRules() const;
139  void initHistory();
144  void setAllPieceCounters();
148  Result resultFromCounting() const;
152  virtual void generatePawnMoves(int sourceSquare,
153  QVarLengthArray<Move>& moves) const;
158  virtual bool insufficientMaterial() const;
159 
160  // Inherited from ShatranjBoard
161  virtual void vInitialize();
162  virtual QString vFenString(FenNotation notation) const;
163  virtual bool vSetFenString(const QStringList& fen);
164  virtual bool inCheck(Side side, int square = 0) const;
165  virtual void vMakeMove(const Move& move,
166  BoardTransition* transition);
167  virtual void vUndoMove(const Move& move);
168  virtual void generateMovesForPiece(QVarLengthArray<Move>& moves,
169  int pieceType,
170  int square) const;
171 
172  private:
173  QVarLengthArray<int> m_silverGeneralOffsets[2];
174  int m_promotionRank;
175  enum CountingRules m_rules;
176  bool m_useWesternCounting;
177  // Data for reversing/unmaking a move
178  struct MoveData
179  {
180  bool piecesHonour;
181  int countingLimit;
182  int plyCount;
183  int totalPlies;
184  int pieceCount[King + 1][2];
185  };
186  QVarLengthArray<MoveData> m_history;
187 
188  int material() const;
189 };
190 
191 } // namespace Chess
192 #endif // MAKRUKBOARD_H
static const int NoPiece
Definition: piece.h:44
A board for Shatranj.
Definition: shatranjboard.h:54
FenNotation
Definition: board.h:93
An internal chessboard class.
Definition: board.h:57
MakrukPieceType
Definition: makrukboard.h:92
Definition: boardscene.h:29
A board for Makruk (Thai Chess)
Definition: makrukboard.h:78
The side or color of a chess player.
Definition: side.h:35
No side.
Definition: side.h:45
The result of a chess game.
Definition: result.h:34
Details of a board transition caused by a move.
Definition: boardtransition.h:40
A small and efficient chessmove class.
Definition: move.h:42
CountingRules
Definition: makrukboard.h:130