Cute Chess 0.1
xboardengine.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 XBOARDENGINE_H
20#define XBOARDENGINE_H
21
22#include "chessengine.h"
23#include "board/board.h"
24
30class LIB_EXPORT XboardEngine : public ChessEngine
31{
32 Q_OBJECT
33
34 public:
36 XboardEngine(QObject* parent = nullptr);
37
38 // Inherited from ChessEngine
39 virtual void endGame(const Chess::Result& result);
40 virtual void makeMove(const Chess::Move& move);
41 virtual QString protocol() const;
42
43 protected:
44 // Inherited from ChessEngine
45 virtual bool sendPing();
46 virtual void sendStop();
47 virtual void sendQuit();
48 virtual void startProtocol();
49 virtual void startGame();
50 virtual void startThinking();
51 virtual void parseLine(const QString& line);
52 virtual void sendOption(const QString& name, const QVariant& value);
53 virtual bool restartsBetweenGames() const;
54
55 protected slots:
56 // Inherited from ChessEngine
57 virtual void onTimeout();
58
59 private slots:
61 void initialize();
62
63 private:
64 EngineOption* parseOption(const QString& line);
65 void setFeature(const QString& name, const QString& val);
66 void setForceMode(bool enable);
67 void sendTimeLeft();
68 void finishGame();
69 QString moveString(const Chess::Move& move);
70 int adaptScore(int score) const;
71 const QString transformMove(const QString& str, int height, int shift) const;
72
73 bool m_forceMode;
74 bool m_drawOnNextMove;
75
76 // Engine features
77 bool m_ftName;
78 bool m_ftPing;
79 bool m_ftSetboard;
80 bool m_ftTime;
81 bool m_ftUsermove;
82 bool m_ftReuse;
83 bool m_ftNps;
84
85 bool m_gotResult;
86 int m_lastPing;
87 Chess::Move m_nextMove;
88 QString m_nextMoveString;
90 QTimer* m_initTimer;
91};
92
93#endif // XBOARDENGINE_H
virtual void startProtocol()=0
virtual void startGame()=0
virtual bool sendPing()=0
virtual void parseLine(const QString &line)=0
virtual bool restartsBetweenGames() const
Definition chessengine.cpp:259
virtual void sendQuit()=0
virtual void sendOption(const QString &name, const QVariant &value)=0
virtual QString protocol() const =0
ChessEngine(QObject *parent=nullptr)
Definition chessengine.cpp:72
virtual void endGame(const Chess::Result &result)
Definition chessengine.cpp:279
virtual void sendStop()=0
virtual void onTimeout()
Definition chessplayer.cpp:297
QString name() const
Definition chessplayer.cpp:202
virtual void startThinking()=0
virtual void makeMove(const Chess::Move &move)=0
MoveNotation
Definition board.h:88
A small and efficient chessmove class.
Definition move.h:43
The result of a chess game.
Definition result.h:35
Definition engineoption.h:26
XboardEngine(QObject *parent=nullptr)
Definition xboardengine.cpp:68