Moved global.* to mastersettings.*, and converted many error messages to use the...
[tagua/yd.git] / src / xboardengine.h
blob543a30382f80e0aebe02a3f1667a8d9396086ef7
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program 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 2 of the License, or
8 (at your option) any later version.
9 */
11 #ifndef XBOARDENGINE_H
12 #define XBOARDENGINE_H
14 #include "engine.h"
15 #include "kboard.h"
17 class QRegExp;
19 /**
20 * @brief A chess engine compatible with xboard.
22 * XBoard compatible engines are defined by Tim Mann's
23 * Chess Engine Communication Protocol (available at
24 * http://tim-mann.org/xboard/engine-intf.html), used
25 * by GNU Chess, Crafty and many other free and commercial
26 * chess engines.
27 * This class encapsulates such communication protocol,
28 * calling appropriate methods of the notifier upon engine
29 * generated events.
31 * @note This code is partially stolen from Maurizio Monge's
32 * old interface project outoftime.
34 class XBoardEngine : public Engine {
35 Q_OBJECT
36 struct Features {
37 bool ping : 1;
38 bool setboard : 1;
39 bool playother : 1;
40 bool san : 1;
41 bool usermove : 1;
42 bool time : 1;
43 bool draw : 1;
44 bool sigint : 1;
45 bool sigterm : 1;
46 bool reuse : 1;
47 bool analyze : 1;
48 QString myname;
49 QString variants;
50 bool colors : 1;
51 bool ics : 1;
52 bool name : 1;
53 bool pause : 1;
54 bool done : 1;
57 Features m_features;
58 bool m_analysing;
60 static QRegExp m_move_pattern;
61 protected:
62 /**
63 * Initialize the engine.
65 virtual void initializeEngine();
66 protected slots:
67 /**
68 * Parse engine command line and emit the appropriate
69 * signals.
71 void processCommand(const QString& command);
72 public:
73 /**
74 * Create an xboard compatible engine.
76 XBoardEngine(const QString& path, const QStringList& arguments);
78 /**
79 * Terminate the engine.
81 virtual ~XBoardEngine();
83 /**
84 * Send a move to the engine.
86 virtual void sendMove(AbstractMove::Ptr move, AbstractPosition::Ptr ref);
88 /**
89 * Back up a move.
90 * @param pos The position before the move. Used if the engine
91 * does not support the undo command.
93 virtual void backUp(AbstractPosition::Ptr pos);
95 virtual void setBoard(AbstractPosition::Ptr pos, int halfmove, int fullmove);
98 /**
99 * Begin a new game.
101 virtual void reset(int side);
104 * Stop the engine.
106 virtual void stop();
108 virtual void startAnalysis();
109 virtual void stopAnalysis();
112 #endif // XBOARDENGINE_H