Cute Chess 0.1
HumanPlayer Class Reference

A chess player controlled by a human user. More...

#include <humanplayer.h>

Inheritance diagram for HumanPlayer:
ChessPlayer QObject

Public Slots

void onHumanMove (const Chess::GenericMove &move, const Chess::Side &side)
Public Slots inherited from ChessPlayer
virtual void go ()
virtual void kill ()
virtual void quit ()

Signals

void wokeUp ()
Signals inherited from ChessPlayer
void debugMessage (const QString &data)
void disconnected ()
void moveMade (const Chess::Move &move)
void nameChanged (const QString &name)
void ready ()
void resultClaim (const Chess::Result &result)
void startedThinking (int timeLeft)
void stoppedThinking ()
void thinking (const MoveEvaluation &eval)

Public Member Functions

virtual void endGame (const Chess::Result &result)
 HumanPlayer (QObject *parent=nullptr)
virtual bool isHuman () const
virtual void makeMove (const Chess::Move &move)
virtual bool supportsVariant (const QString &variant) const
Public Member Functions inherited from ChessPlayer
bool areClaimsValidated () const
 ChessPlayer (QObject *parent=nullptr)
virtual void clearPonderState ()
QString errorString () const
const MoveEvaluationevaluation () const
bool hasError () const
virtual bool isReady () const
virtual void makeBookMove (const Chess::Move &move)
QString name () const
void newGame (Chess::Side side, ChessPlayer *opponent, Chess::Board *board)
void setCanPlayAfterTimeout (bool enable)
void setClaimsValidated (bool validate)
void setName (const QString &name)
void setTimeControl (const TimeControl &timeControl)
Chess::Side side () const
virtual void startPondering ()
State state () const
const TimeControltimeControl () const

Protected Member Functions

virtual void startGame ()
virtual void startThinking ()
Protected Member Functions inherited from ChessPlayer
Chess::Boardboard ()
virtual bool canPlayAfterTimeout () const
void claimResult (const Chess::Result &result)
void emitMove (const Chess::Move &move)
void forfeit (Chess::Result::Type type, const QString &description=QString())
const ChessPlayeropponent () const
void setError (const QString &error)
void setState (State state)

Additional Inherited Members

Public Types inherited from ChessPlayer
enum  State {
  NotStarted , Starting , Idle , Observing ,
  Thinking , FinishingGame , Disconnected
}
Protected Slots inherited from ChessPlayer
virtual void onCrashed ()
virtual void onTimeout ()
Protected Attributes inherited from ChessPlayer
MoveEvaluation m_eval

Detailed Description

A chess player controlled by a human user.

A HumanPlayer object works between a graphical chessboard and a ChessGame object by forwarding the user's moves to the game.

Typically human players are created by using a HumanBuilder object.

Constructor & Destructor Documentation

◆ HumanPlayer()

HumanPlayer::HumanPlayer ( QObject * parent = nullptr)

Creates a new human player.

Member Function Documentation

◆ endGame()

void HumanPlayer::endGame ( const Chess::Result & result)
virtual

Tells the player that the game ended by result.

Note
Subclasses that reimplement this function must call the base implementation.

Reimplemented from ChessPlayer.

◆ isHuman()

bool HumanPlayer::isHuman ( ) const
virtual

Returns true if the player is human.

Implements ChessPlayer.

◆ makeMove()

void HumanPlayer::makeMove ( const Chess::Move & move)
virtual

Sends the next move of an ongoing game to the player. If the player is in force/observer mode, the move wasn't necessarily made by the opponent.

Implements ChessPlayer.

◆ onHumanMove

void HumanPlayer::onHumanMove ( const Chess::GenericMove & move,
const Chess::Side & side )
slot

Plays move as the human player's next move if side is the player's side and the move is legal; otherwise does nothing.

If the player is in Thinking state, it plays the move immediately. If its in Observing state, it saves the move for later, emits the wokeUp() signal, and plays the move when it gets its turn.

◆ startGame()

void HumanPlayer::startGame ( )
protectedvirtual

Starts the chess game set up by newGame().

Implements ChessPlayer.

◆ startThinking()

void HumanPlayer::startThinking ( )
protectedvirtual

Tells the player to start thinking of the next move.

The player is guaranteed to be ready to move when this function is called by go().

Implements ChessPlayer.

◆ supportsVariant()

bool HumanPlayer::supportsVariant ( const QString & variant) const
virtual

Returns true if the player can play variant.

Implements ChessPlayer.

◆ wokeUp

void HumanPlayer::wokeUp ( )
signal

This signal is emitted when the player receives a user-made move in Observing state.

Normally this signal is connected to ChessGame::resume() to resume a paused game when the user makes a move.


The documentation for this class was generated from the following files: