Add a PromotionManager.
[tagua/yd.git] / src / xboardengine.h
blob7c45b174d1b857e7c0d6ae775efe836c53dfdf54
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
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"
16 class Components;
17 class QRegExp;
18 class IMoveSerializer;
20 /**
21 * @brief A chess engine compatible with xboard.
23 * XBoard compatible engines are defined by Tim Mann's
24 * Chess Engine Communication Protocol (available at
25 * http://tim-mann.org/xboard/engine-intf.html), used
26 * by GNU Chess, Crafty and many other free and commercial
27 * chess engines.
28 * This class encapsulates such communication protocol,
29 * calling appropriate methods of the notifier upon engine
30 * generated events.
32 * @note This code is partially stolen from Maurizio Monge's
33 * old interface project outoftime.
35 class XBoardEngine : public Engine {
36 Q_OBJECT
37 struct Features {
38 bool ping : 1;
39 bool setboard : 1;
40 bool playother : 1;
41 bool san : 1;
42 bool usermove : 1;
43 bool time : 1;
44 bool draw : 1;
45 bool sigint : 1;
46 bool sigterm : 1;
47 bool reuse : 1;
48 bool analyze : 1;
49 QString myname;
50 QString variants;
51 bool colors : 1;
52 bool ics : 1;
53 bool name : 1;
54 bool pause : 1;
55 bool done : 1;
58 Features m_features;
59 bool m_analysing;
60 Components* m_components;
61 IMoveSerializer* m_serializer;
63 static QRegExp m_move_pattern;
64 protected:
65 /**
66 * Initialize the engine.
68 virtual void initializeEngine();
69 protected Q_SLOTS:
70 /**
71 * Parse engine command line and the appropriate
72 * signals.
74 void processCommand(const QString& command);
75 public:
76 /**
77 * Create an xboard compatible engine.
79 XBoardEngine(Components* components,
80 const QString& path,
81 const QStringList& arguments);
83 /**
84 * Terminate the engine.
86 virtual ~XBoardEngine();
88 /**
89 * Send a move to the engine.
91 virtual void sendMove(const Move& move, const StatePtr& ref);
93 /**
94 * Back up a move.
95 * @param pos The position before the move. Used if the engine
96 * does not support the undo command.
98 virtual void backUp(const StatePtr& pos);
100 virtual void setBoard(const StatePtr& pos);
104 * Begin a new game.
106 virtual void reset();
109 * Start playing.
111 virtual void play();
114 * Stop the engine.
116 virtual void stop();
118 virtual void startAnalysis();
119 virtual void stopAnalysis();
122 #endif // XBOARDENGINE_H