An artificial intelligence chess player.
More...
#include <chessengine.h>
|
|
virtual void | go () |
| |
|
virtual void | kill () |
| |
|
virtual void | quit () |
| |
| virtual void | go () |
| |
| virtual void | kill () |
| |
| virtual void | quit () |
| |
An artificial intelligence chess player.
ChessEngine is a separate process (run locally or over a network) using either the Xboard or Uci chess protocol. Communication between the GUI and the chess engines happens via a QIODevice.
- See also
- XboardEngine
-
UciEngine
◆ WriteMode
The write mode used by write() when the engine is being pinged. This doesn't affect the IO device's buffering.
| Enumerator |
|---|
| Buffered | Use the write buffer.
|
| Unbuffered | Bypass the write buffer.
|
◆ ChessEngine()
| ChessEngine::ChessEngine |
( |
QObject * |
parent = nullptr | ) |
|
◆ addOption()
Adds option to the engine options list.
◆ addVariant()
| void ChessEngine::addVariant |
( |
const QString & |
variant | ) |
|
|
protected |
Adds variant to the list of supported variants.
◆ applyConfiguration()
Applies configuration to the engine.
◆ clearVariants()
| void ChessEngine::clearVariants |
( |
| ) |
|
|
protected |
Clears the list of supported variants.
◆ clearWriteBuffer
| void ChessEngine::clearWriteBuffer |
( |
| ) |
|
|
protectedslot |
Clear the write buffer without flushing it.
◆ device()
Returns the current device associated with the engine.
◆ endGame()
Tells the player that the game ended by result.
- Note
- Subclasses that reimplement this function must call the base implementation.
Reimplemented from ChessPlayer.
Reimplemented in UciEngine, and XboardEngine.
◆ firstToken()
Reads the first whitespace-delimited token from a string and returns a QStringRef reference to the token.
If readToEnd is true, the whole string is read, except for leading and trailing whitespace. Otherwise only one word is read.
If str doesn't contain any words, a null QStringRef object is returned.
◆ flushWriteBuffer
| void ChessEngine::flushWriteBuffer |
( |
| ) |
|
|
protectedslot |
Flushes the write buffer. If there are any commands in the buffer, they will be sent to the engine.
◆ getOption()
Returns the option that matches name. Returns 0 if an option with that name doesn't exist.
◆ id()
| int ChessEngine::id |
( |
| ) |
const |
|
protected |
Gives id number of the engine
◆ isHuman()
| bool ChessEngine::isHuman |
( |
| ) |
const |
|
virtual |
Returns true if the player is human.
Implements ChessPlayer.
◆ isPondering()
| bool ChessEngine::isPondering |
( |
| ) |
const |
|
protectedvirtual |
Returns true if the engine is currently thinking on the opponent's move; otherwise returns false.
Reimplemented in UciEngine.
◆ isReady()
| bool ChessEngine::isReady |
( |
| ) |
const |
|
virtual |
Returns true if the player is ready for input.
- Note
- When the player's state is Disconnected, this function still returns true if all the cleanup following the disconnection is done.
Reimplemented from ChessPlayer.
◆ nextToken()
Reads the first whitespace-delimited token after the token referenced by previous.
If readToEnd is true, everything from the first word after previous to the end of the string is read, except for leading and trailing whitespace. Otherwise only one word is read.
If previous is null or it's not followed by any words, a null QStringRef object is returned.
◆ onIdleTimeout
| void ChessEngine::onIdleTimeout |
( |
| ) |
|
|
protectedslot |
Called when the engine idles for too long.
◆ onPingTimeout
| void ChessEngine::onPingTimeout |
( |
| ) |
|
|
protectedslot |
Called when the engine doesn't respond to ping.
◆ onProtocolStart
| void ChessEngine::onProtocolStart |
( |
| ) |
|
|
protectedslot |
Called when the engine has started the chess protocol and is ready to start a game.
◆ onReadyRead
| void ChessEngine::onReadyRead |
( |
| ) |
|
|
protectedslot |
Reads input from the engine.
◆ options()
Returns a list of supported options and their values.
◆ parseLine()
| virtual void ChessEngine::parseLine |
( |
const QString & |
line | ) |
|
|
protectedpure virtual |
◆ ping()
| void ChessEngine::ping |
( |
bool |
sendCommand = true | ) |
|
Sends a ping message (an echo request) to the engine to check if it's still responding to input, and to synchronize it with the game operator. If the engine doesn't respond in reasonable time, it will be terminated.
if sendCommand is false, nothing is actually sent to the engine (but we'll pretend a message was sent); otherwise the ping message is sent.
- Note
- All input to the engine will be delayed until we get a response to the ping.
◆ pondering()
| bool ChessEngine::pondering |
( |
| ) |
const |
|
protected |
Returns true if pondering is enabled for the engine; otherwise returns false.
- Note
- Even if pondering is enabled, it's still possible that the engine does not support pondering.
◆ pong
| void ChessEngine::pong |
( |
bool |
emitReady = true | ) |
|
|
protectedslot |
Called when the engine responds to ping.
Does nothing if the engine is not being pinged. Flushes any pending output to the engine. If emitReady is true, the ready() signal is emitted after pending output is flushed.
◆ protocol()
| virtual QString ChessEngine::protocol |
( |
| ) |
const |
|
pure virtual |
◆ restartMode()
◆ restartsBetweenGames()
| bool ChessEngine::restartsBetweenGames |
( |
| ) |
const |
|
protectedvirtual |
Returns true if the engine restarts between games; otherwise returns false.
Reimplemented in XboardEngine.
◆ sendOption()
| virtual void ChessEngine::sendOption |
( |
const QString & |
name, |
|
|
const QVariant & |
value |
|
) |
| |
|
protectedpure virtual |
◆ sendPing()
| virtual bool ChessEngine::sendPing |
( |
| ) |
|
|
protectedpure virtual |
Sends a ping command to the engine. Returns true if successful; otherwise returns false.
Implemented in UciEngine, and XboardEngine.
◆ sendQuit()
| virtual void ChessEngine::sendQuit |
( |
| ) |
|
|
protectedpure virtual |
◆ sendStop()
| virtual void ChessEngine::sendStop |
( |
| ) |
|
|
protectedpure virtual |
◆ setDevice()
| void ChessEngine::setDevice |
( |
QIODevice * |
device | ) |
|
Sets the current device to device.
◆ setOption()
| void ChessEngine::setOption |
( |
const QString & |
name, |
|
|
const QVariant & |
value |
|
) |
| |
Sets an option with the name name to value.
- Note
- If the engine doesn't have an option called name, nothing happens.
◆ start()
| void ChessEngine::start |
( |
| ) |
|
Starts communicating with the engine.
- Note
- The engine device must already be started.
◆ startGame()
| virtual void ChessEngine::startGame |
( |
| ) |
|
|
protectedpure virtual |
◆ startProtocol()
| virtual void ChessEngine::startProtocol |
( |
| ) |
|
|
protectedpure virtual |
Puts the engine in the correct mode to start communicating with it, using the chosen chess protocol.
Implemented in UciEngine, and XboardEngine.
◆ stopThinking()
| bool ChessEngine::stopThinking |
( |
| ) |
|
|
protected |
Tells the engine to stop thinking and move now (if on move).
Returns true if the stop message was actually sent; otherwise returns false.
◆ supportsVariant()
| bool ChessEngine::supportsVariant |
( |
const QString & |
variant | ) |
const |
|
virtual |
Returns true if the player can play variant.
Implements ChessPlayer.
◆ variants()
Returns a list of supported chess variants.
◆ whiteEvalPov()
| bool ChessEngine::whiteEvalPov |
( |
| ) |
const |
|
protected |
Are evaluation scores from white's point of view?
◆ write()
Writes text data to the chess engine.
If mode is Unbuffered, the data will be written to the device immediately even if the engine is being pinged.
The documentation for this class was generated from the following files: