• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

kigo

  • Kigo
  • Game
Public Types | Public Slots | Signals | Public Member Functions | List of all members
Kigo::Game Class Reference

#include <game.h>

Inheritance diagram for Kigo::Game:
Inheritance graph
[legend]

Public Types

enum  FinalState {
  FinalAlive = 1, FinalDead, FinalSeki, FinalWhiteTerritory,
  FinalBlackTerritory, FinalDame, FinalStateInvalid
}
 

Public Slots

void gameSetup ()
 

Signals

void boardChanged ()
 
void boardInitialized ()
 
void boardSizeChanged (int)
 
void canRedoChanged (bool)
 
void canUndoChanged (bool)
 
void consecutivePassMovesPlayed (int)
 
void currentPlayerChanged (const Player &)
 
void passMovePlayed (const Player &)
 
void resigned (const Player &)
 
void waiting (bool)
 

Public Member Functions

 Game (QObject *parent=0)
 
 ~Game ()
 
QList< Stone > bestMoves (const Player &player)
 
Player & blackPlayer ()
 
const Player & blackPlayer () const
 
int boardSize () const
 
bool canRedo () const
 
bool canUndo () const
 
int captures (const Player &player)
 
int currentMoveNumber () const
 
Player & currentPlayer ()
 
const Player & currentPlayer () const
 
QString engineCommand () const
 
QString engineName () const
 
QString engineVersion () const
 
Score estimatedScore ()
 
Score finalScore ()
 
FinalState finalState (const Stone &field)
 
QList< Stone > finalStates (FinalState state)
 
int fixedHandicap () const
 
int fixedHandicapUpperBound ()
 
bool generateMove (const Player &player, bool undoable=true)
 
bool init ()
 
bool init (const QString &fileName, int moveNumber=0)
 
bool isFinished () const
 
bool isRunning () const
 
float komi () const
 
Move lastMove () const
 
QList< Stone > legalMoves (const Player &player)
 
QList< Stone > liberties (const Stone &field)
 
int moveCount ()
 
QList< Move > moves (const Player &player)
 
QList< Move > moves ()
 
bool playMove (const Move &move, bool undoable=true)
 
bool playMove (const Player &player, const Stone &stone=Stone(), bool undoable=true)
 
bool redoMove ()
 
bool save (const QString &fileName)
 
bool setBoardSize (int size)
 
bool setFixedHandicap (int handicap)
 
bool setKomi (float komi)
 
bool start (const QString &command="gnugo --mode gtp")
 
QList< Stone > stones (const Player &player)
 
void stop ()
 
bool undoMove ()
 
QUndoStack * undoStack ()
 
Player & whitePlayer ()
 
const Player & whitePlayer () const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The Game class implements the Go game and acts as a wrapper around a remote Go Game game implementing the Go Text Protocol (GTP).

It uses GTP protocol version 2 and interfaces the game executable in an synchronous manor. The best supported game should (naturally) be GnuGo.

Game *game = new Game;
// Run a session with a Go game in GTP mode
game->start("gnugo --mode gtp");
// Get some information about the Go game
game->name();
game->version();
game->stop();
Author
Sascha Peilicke sasch.nosp@m..pe@.nosp@m.gmx.d.nosp@m.e
Since
0.1

Definition at line 60 of file game.h.

Member Enumeration Documentation

enum Kigo::Game::FinalState

Enumeration of all possible final states of a field when a game is over.

Enumerator
FinalAlive 

The stone on the field is alive.

FinalDead 

The stone on the field is dead.

FinalSeki 
FinalWhiteTerritory 

The field belongs to the white player.

FinalBlackTerritory 

The field belongs to the black player.

FinalDame 

The field belongs to no player.

FinalStateInvalid 

The state is invalid, shows error.

Definition at line 68 of file game.h.

Constructor & Destructor Documentation

Kigo::Game::Game ( QObject *  parent = 0)
explicit

Definition at line 51 of file game.cpp.

Kigo::Game::~Game ( )

Definition at line 64 of file game.cpp.

Member Function Documentation

QList< Stone > Kigo::Game::bestMoves ( const Player &  player)

Generate a list of the best moves for a player with weights.

Definition at line 593 of file game.cpp.

Player& Kigo::Game::blackPlayer ( )
inline

Definition at line 162 of file game.h.

const Player& Kigo::Game::blackPlayer ( ) const
inline

Definition at line 163 of file game.h.

void Kigo::Game::boardChanged ( )
signal

This signal is emitted when the board situation changed and can be used to trigger an update to a visual representation.

void Kigo::Game::boardInitialized ( )
signal

This signal is emitted when the board is first started and can be used to trigger an update to a visual representation.

int Kigo::Game::boardSize ( ) const
inline

Definition at line 132 of file game.h.

void Kigo::Game::boardSizeChanged ( int  )
signal

This signal is emitted when the board size was changed.

bool Kigo::Game::canRedo ( ) const
inline

Definition at line 248 of file game.h.

void Kigo::Game::canRedoChanged ( bool  )
signal

This signal is emitted when availability of redo moves changes.

bool Kigo::Game::canUndo ( ) const
inline

Definition at line 249 of file game.h.

void Kigo::Game::canUndoChanged ( bool  )
signal

This signal is emitted when availability of undo moves changes.

int Kigo::Game::captures ( const Player &  player)

List the number of captures taken by either player.

Definition at line 636 of file game.cpp.

void Kigo::Game::consecutivePassMovesPlayed ( int  )
signal

This signal is emitted when both players played a pass move after another.

It is also send when pass moves are gone (which is indicated by a value of 0).

int Kigo::Game::currentMoveNumber ( ) const
inline

Definition at line 171 of file game.h.

Player& Kigo::Game::currentPlayer ( )
inline

Definition at line 158 of file game.h.

const Player& Kigo::Game::currentPlayer ( ) const
inline

Definition at line 159 of file game.h.

void Kigo::Game::currentPlayerChanged ( const Player &  )
signal

This signal is emitted when the current player changes.

QString Kigo::Game::engineCommand ( ) const
inline

Definition at line 102 of file game.h.

QString Kigo::Game::engineName ( ) const
inline

Definition at line 100 of file game.h.

QString Kigo::Game::engineVersion ( ) const
inline

Definition at line 101 of file game.h.

Score Kigo::Game::estimatedScore ( )

Returns an estimate of the final score based on the current game situation.

Definition at line 706 of file game.cpp.

Score Kigo::Game::finalScore ( )

Compute the score of a finished game.

This method can take a long time to complete. It is thus recommended to use estimatedScore().

Returns
Score in SGF format (RE property)

Definition at line 696 of file game.cpp.

Game::FinalState Kigo::Game::finalState ( const Stone &  field)

Report the final status of a field in a finished game.

Parameters
fieldReport status for that feed
See also
FinalState

Definition at line 650 of file game.cpp.

QList< Stone > Kigo::Game::finalStates ( FinalState  state)

Report fields with a specified final status in a finished game.

Parameters
stateReport only fields with that state
See also
FinalState

Definition at line 669 of file game.cpp.

int Kigo::Game::fixedHandicap ( ) const
inline

Definition at line 148 of file game.h.

int Kigo::Game::fixedHandicapUpperBound ( )

Returns the maximum amount fixed handicap stones placeable at the current Go board size.

Returns
The maximum allowed fixed handicap

Definition at line 255 of file game.cpp.

void Kigo::Game::gameSetup ( )
slot

Definition at line 769 of file game.cpp.

bool Kigo::Game::generateMove ( const Player &  player,
bool  undoable = true 
)

Definition at line 359 of file game.cpp.

bool Kigo::Game::init ( )

Initialize a new game.

Definition at line 110 of file game.cpp.

bool Kigo::Game::init ( const QString &  fileName,
int  moveNumber = 0 
)

Initialize from a SGF file and start from a specific move number if desired.

Parameters
fileNameThe SGF file name
moveNumberThe move number

Definition at line 136 of file game.cpp.

bool Kigo::Game::isFinished ( ) const
inline

Definition at line 251 of file game.h.

bool Kigo::Game::isRunning ( ) const
inline

Check whether the Game object is connected to a Go game, running and waiting for commands to be fed with.

Definition at line 99 of file game.h.

float Kigo::Game::komi ( ) const
inline

Definition at line 140 of file game.h.

Move Kigo::Game::lastMove ( ) const

Returns the last move made by either player.

Don't call this method when no moves where made at all!

Definition at line 509 of file game.cpp.

QList< Stone > Kigo::Game::legalMoves ( const Player &  player)

List all legal moves for either player.

Definition at line 616 of file game.cpp.

QList< Stone > Kigo::Game::liberties ( const Stone &  field)

Returns the positions of the liberties for the stone at 'field'.

Parameters
fieldThe field to return liberties for

Definition at line 577 of file game.cpp.

int Kigo::Game::moveCount ( )

Returns the number of moves in the game so far.

Especially helpful when loading a game.

Definition at line 518 of file game.cpp.

QList< Move > Kigo::Game::moves ( const Player &  player)

Returns a list of all moves by that player.

Definition at line 558 of file game.cpp.

QList<Move> Kigo::Game::moves ( )
inline

Definition at line 194 of file game.h.

void Kigo::Game::passMovePlayed ( const Player &  )
signal
bool Kigo::Game::playMove ( const Move &  move,
bool  undoable = true 
)

Definition at line 275 of file game.cpp.

bool Kigo::Game::playMove ( const Player &  player,
const Stone &  stone = Stone(),
bool  undoable = true 
)

Definition at line 280 of file game.cpp.

bool Kigo::Game::redoMove ( )

Definition at line 481 of file game.cpp.

void Kigo::Game::resigned ( const Player &  )
signal

This signal is emitted when a player resigns.

bool Kigo::Game::save ( const QString &  fileName)

Save the current game as a SGF file.

Parameters
fileNameThe SGF file name

Definition at line 179 of file game.cpp.

bool Kigo::Game::setBoardSize ( int  size)

Set the board size to NxN.

Parameters
sizeThe board size (standard are 9x9, 13x13 and 19x19)

Definition at line 189 of file game.cpp.

bool Kigo::Game::setFixedHandicap ( int  handicap)

Set up fixed placement handicap stones.

Parameters
handicapThe number of handicap stones.

Definition at line 230 of file game.cpp.

bool Kigo::Game::setKomi ( float  komi)

Set the komi.

Parameters
komiThe komi to be set (usually 4.5 or 4.5 on 19x19 boards)

Definition at line 214 of file game.cpp.

bool Kigo::Game::start ( const QString &  command = "gnugo --mode gtp")

Connect to the given Go game game in GTP mode.

The most common used case is 'gnugo –mode gtp' but this depends on your platform and installed Go game(s).

Parameters
commandThe executable command to start in GTP mode.

Definition at line 69 of file game.cpp.

QList< Stone > Kigo::Game::stones ( const Player &  player)

Returns a list of all stones of that player on the board.

Definition at line 531 of file game.cpp.

void Kigo::Game::stop ( )

Gracefully stop and exit the Go game game.

Definition at line 102 of file game.cpp.

bool Kigo::Game::undoMove ( )

Definition at line 444 of file game.cpp.

QUndoStack* Kigo::Game::undoStack ( )
inline

Definition at line 103 of file game.h.

void Kigo::Game::waiting ( bool  )
signal

This signal is emitted when the game starts or ends a non-blocking wait.

This is useful to reflect the wait state in the UI.

Player& Kigo::Game::whitePlayer ( )
inline

Definition at line 160 of file game.h.

const Player& Kigo::Game::whitePlayer ( ) const
inline

Definition at line 161 of file game.h.


The documentation for this class was generated from the following files:
  • game.h
  • game.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:29 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kigo

Skip menu "kigo"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal