Cute Chess  0.1
xboardengine.h
1 /*
2  This file is part of Cute Chess.
3 
4  Cute Chess is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  Cute Chess is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with Cute Chess. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef XBOARDENGINE_H
19 #define XBOARDENGINE_H
20 
21 #include "chessengine.h"
22 #include "board/board.h"
23 
29 class LIB_EXPORT XboardEngine : public ChessEngine
30 {
31  Q_OBJECT
32 
33  public:
35  XboardEngine(QObject* parent = nullptr);
36 
37  // Inherited from ChessEngine
38  virtual void endGame(const Chess::Result& result);
39  virtual void makeMove(const Chess::Move& move);
40  virtual QString protocol() const;
41 
42  protected:
43  // Inherited from ChessEngine
44  virtual bool sendPing();
45  virtual void sendStop();
46  virtual void sendQuit();
47  virtual void startProtocol();
48  virtual void startGame();
49  virtual void startThinking();
50  virtual void parseLine(const QString& line);
51  virtual void sendOption(const QString& name, const QVariant& value);
52  virtual bool restartsBetweenGames() const;
53 
54  protected slots:
55  // Inherited from ChessEngine
56  virtual void onTimeout();
57 
58  private slots:
60  void initialize();
61 
62  private:
63  EngineOption* parseOption(const QString& line);
64  void setFeature(const QString& name, const QString& val);
65  void setForceMode(bool enable);
66  void sendTimeLeft();
67  void finishGame();
68  QString moveString(const Chess::Move& move);
69 
70  bool m_forceMode;
71  bool m_drawOnNextMove;
72 
73  // Engine features
74  bool m_ftName;
75  bool m_ftPing;
76  bool m_ftSetboard;
77  bool m_ftTime;
78  bool m_ftUsermove;
79  bool m_ftReuse;
80  bool m_ftNps;
81 
82  bool m_gotResult;
83  int m_lastPing;
84  Chess::Move m_nextMove;
85  QString m_nextMoveString;
86  Chess::Board::MoveNotation m_notation;
87  QTimer* m_initTimer;
88 };
89 
90 #endif // XBOARDENGINE_H
virtual void sendQuit()=0
virtual void sendOption(const QString &name, const QVariant &value)=0
MoveNotation
Definition: board.h:86
virtual bool sendPing()=0
virtual void startThinking()=0
virtual void endGame(const Chess::Result &result)
Definition: chessengine.cpp:276
virtual void makeMove(const Chess::Move &move)=0
virtual QString protocol() const =0
virtual void sendStop()=0
An artificial intelligence chess player.
Definition: chessengine.h:40
The result of a chess game.
Definition: result.h:33
virtual bool restartsBetweenGames() const
Definition: chessengine.cpp:256
Definition: engineoption.h:24
A chess engine which uses the Xboard chess engine communication protocol.
Definition: xboardengine.h:29
A small and efficient chessmove class.
Definition: move.h:41
virtual void startGame()=0
virtual void startProtocol()=0
virtual void parseLine(const QString &line)=0