Cute Chess  0.1
connectboard.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 CONNECTBOARD_H
20 #define CONNECTBOARD_H
21 
22 #include "westernboard.h"
23 
24 namespace Chess {
25 
39 class LIB_EXPORT ConnectBoard : public WesternBoard
40 {
41  public:
43  ConnectBoard();
44 
45  // Inherited from WesternBoard
46  virtual Board* copy() const;
47  virtual QString variant() const;
48  virtual QString defaultFenString() const;
49  virtual bool variantHasDrops() const;
50  virtual QList<Chess::Piece> reservePieceTypes() const;
51  virtual int width() const;
52  virtual int height() const;
53  virtual Result result();
54 
55  protected:
61  virtual bool hasGravity() const;
63  virtual int connectToWin() const;
68  virtual int requiredNumberOfPieces() const;
74  virtual bool overlinesWin(Side side) const;
75 
76  // Inherited from WesternBoard
77  virtual void vInitialize();
78  virtual bool vSetFenString(const QStringList & fen);
79  bool kingsCountAssertion(int, int) const;
80  virtual void generateMovesForPiece(QVarLengthArray<Chess::Move> & moves,
81  int pieceType,
82  int square) const;
83  virtual void vMakeMove(const Chess::Move & move,
84  Chess::BoardTransition * transition);
85  virtual void vUndoMove(const Chess::Move & move);
86  virtual bool isLegalPosition();
87 
88  private:
89  bool pieceCountOk() const;
90  bool connected(int n, Side side) const;
91 
92  int m_hasGravity;
93  int m_connectToWin;
94  QVector<int> m_pieceCounter;
95 };
96 
109 class LIB_EXPORT TicTacToeBoard : public ConnectBoard
110 {
111  public:
113  TicTacToeBoard();
114 
115  // Inherited from ConnectBoard
116  virtual Board* copy() const;
117  virtual QString variant() const;
118  virtual QString defaultFenString() const;
119  virtual int width() const;
120  virtual int height() const;
121  virtual int connectToWin() const;
122 
123  protected:
124  virtual bool hasGravity() const;
125 };
126 
143 //TODO: Black begins, One ply per move, starting phase
144 class LIB_EXPORT GomokuFreestyleBoard : public ConnectBoard
145 {
146  public:
149 
150  // Inherited from ConnectBoard
151  virtual Board* copy() const;
152  virtual QString variant() const;
153  virtual QString defaultFenString() const;
154  virtual int width() const;
155  virtual int height() const;
156  virtual int connectToWin() const;
157 
158  protected:
159  virtual bool hasGravity() const;
160 };
161 
178 class LIB_EXPORT GomokuBoard : public GomokuFreestyleBoard
179 {
180  public:
182  GomokuBoard();
183 
184  // Inherited from GomokuBoard
185  virtual Board* copy() const;
186  virtual QString variant() const;
187 
188  protected:
189  virtual bool overlinesWin(Side side) const;
190 };
191 }// namespace Chess
192 #endif // CONNECTBOARD_H
A board for Gomoku.
Definition: connectboard.h:178
A board for TicTacToe.
Definition: connectboard.h:109
A base board for games with the goal of lining up a number of pieces.
Definition: connectboard.h:39
An internal chessboard class.
Definition: board.h:56
A board for Gomoku Free-Style.
Definition: connectboard.h:144
A board for western chess variants.
Definition: westernboard.h:40
Definition: boardscene.h:30
The side or color of a chess player.
Definition: side.h:35
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