#include <GoPlayer.h>
Inheritance diagram for GoPlayer:
Definition at line 23 of file GoPlayer.h.
Public Member Functions | |
GoPlayer (const GoBoard &bd) | |
Constructor. | |
virtual | ~GoPlayer () |
GoBoard & | Board () |
See m_board. | |
const GoBoard & | Board () const |
See m_board. | |
virtual SgPoint | GenMove (const SgTimeRecord &time, SgBlackWhite toPlay)=0 |
Generate a move. | |
virtual std::string | Name () const |
Get the name of this player. | |
SgNode * | CurrentNode () const |
Get node for appending search traces. | |
void | SetCurrentNode (SgNode *node) |
Set node for appending search traces. | |
virtual int | MoveValue (SgPoint p) |
Return value for a move. | |
virtual void | OnGameFinished () |
Inform the player that the game was finished. | |
virtual void | OnNewGame () |
Inform the player that a new game was started. | |
virtual void | Ponder () |
Think during opponent's time. | |
int | Variant () const |
See m_variant. | |
void | SetVariant (int variant) |
See m_variant. | |
void | SetSubscriber (GoBoard &subscriber) |
Set the board that will subscribe to all the changes of the publisher. | |
void | UpdateSubscriber () |
Update the subscriber board. | |
Protected Member Functions | |
Hook functions for incremental update events | |
virtual void | OnBoardChange () |
Board was initialized with new size. | |
virtual void | PrePlay (GoPlayerMove move) |
Move about to be executed. | |
virtual void | OnPlay (GoPlayerMove move) |
Move was executed. | |
virtual void | PreUndo () |
Move about to be undone. | |
virtual void | OnUndo () |
Move was undone. | |
Protected Attributes | |
SgNode * | m_currentNode |
Node in game tree. | |
Private Member Functions | |
GoPlayer (const GoPlayer &) | |
Not implemented. | |
GoPlayer & | operator= (const GoPlayer &) |
Not implemented. | |
Private Attributes | |
GoBoard | m_bd |
The player's own Go board. | |
int | m_variant |
Player variant. |
GoPlayer::GoPlayer | ( | const GoBoard & | bd | ) |
Constructor.
Definition at line 17 of file GoPlayer.cpp.
References m_bd, and GoBoardSynchronizer::SetSubscriber().
GoPlayer::~GoPlayer | ( | ) | [virtual] |
Definition at line 26 of file GoPlayer.cpp.
GoPlayer::GoPlayer | ( | const GoPlayer & | ) | [private] |
Not implemented.
const GoBoard & GoPlayer::Board | ( | ) | const |
GoBoard & GoPlayer::Board | ( | ) |
See m_board.
Definition at line 130 of file GoPlayer.h.
References m_bd.
Referenced by GoGtpEngine::CmdPlaceFreeHandicap(), and GoGtpEngine::DumpState().
SgNode * GoPlayer::CurrentNode | ( | ) | const |
Get node for appending search traces.
Definition at line 140 of file GoPlayer.h.
References m_currentNode.
virtual SgPoint GoPlayer::GenMove | ( | const SgTimeRecord & | time, | |
SgBlackWhite | toPlay | |||
) | [pure virtual] |
int GoPlayer::MoveValue | ( | SgPoint | p | ) | [virtual] |
Return value for a move.
Not all players assign values to moves. If a player cannot score moves in general, or cannot score this move in particular, it should return numeric_limits<int>::min() (which is what the default implementation does). Values can be positive or negative; better moves should have higher values; the units of the values are not specified.
Definition at line 30 of file GoPlayer.cpp.
References SG_UNUSED().
Referenced by GoGtpEngine::CmdAllMoveValues().
std::string GoPlayer::Name | ( | ) | const [virtual] |
Get the name of this player.
Default implementation returns "Unknown"
Definition at line 36 of file GoPlayer.cpp.
Referenced by GoGtpEngine::CmdName(), and GoGtpEngine::GenMove().
void GoBoardSynchronizer::OnBoardChange | ( | ) | [protected, virtual, inherited] |
Board was initialized with new size.
Default implementation does nothing.
Definition at line 48 of file GoBoardSynchronizer.cpp.
Referenced by GoBoardSynchronizer::UpdateFromInit().
void GoPlayer::OnGameFinished | ( | ) | [virtual] |
Inform the player that the game was finished.
This function gives the player the opportunity to do some work at the end of a game, for example perform some learning. However it is not guaranteed that this function will be called at all, the player should not rely on it. The reason is that a game start and end is not always well-defined (setup, undo, etc.) For example, it will be called in the GTP interface if after a change on the board GoBoardUtil::EndOfGame() is true. The default implementation does nothing.
Definition at line 41 of file GoPlayer.cpp.
Referenced by GoGtpEngine::GameFinished().
void GoPlayer::OnNewGame | ( | ) | [virtual] |
Inform the player that a new game was started.
This function gives the player the opportunity to clear some cached data, that is useful only within the same game. However it is not guaranteed that this function will be called at all, the player should not rely on it. The reason is that a game start and end is not always well-defined (setup, undo, etc.) For example, it will be called in the GTP interface in GoGtpEngine::Init(), or on the clear_board and loadsgf commands. The default implementation does nothing.
Definition at line 45 of file GoPlayer.cpp.
Referenced by GoGtpEngine::CmdClearBoard(), GoGtpEngine::CmdLoadSgf(), and GoGtpEngine::SetPlayer().
void GoBoardSynchronizer::OnPlay | ( | GoPlayerMove | move | ) | [protected, virtual, inherited] |
Move was executed.
Default implementation does nothing.
Definition at line 57 of file GoBoardSynchronizer.cpp.
References SG_UNUSED().
Referenced by GoBoardSynchronizer::ExecuteSubscriber().
void GoBoardSynchronizer::OnUndo | ( | ) | [protected, virtual, inherited] |
Move was undone.
Default implementation does nothing.
Definition at line 66 of file GoBoardSynchronizer.cpp.
Referenced by GoBoardSynchronizer::UpdateIncremental().
void GoPlayer::Ponder | ( | ) | [virtual] |
Think during opponent's time.
This function should poll SgUserAbort() and return immediately if it returns true. It is good style to enable pondering in the player with a parameter and return immediately if it is not enabled. If it is enabled, it should stop after some resource limit is reached to avoid that a program is hogging the CPU if it is just waiting for commands. The function Ponder() is typically called from a different thread but without overlap with other uses of the player, so the player does not have to care about thread-safety. Default implementation does nothing and returns immediately.
Definition at line 49 of file GoPlayer.cpp.
void GoBoardSynchronizer::PrePlay | ( | GoPlayerMove | move | ) | [protected, virtual, inherited] |
Move about to be executed.
Default implementation does nothing.
Definition at line 52 of file GoBoardSynchronizer.cpp.
References SG_UNUSED().
Referenced by GoBoardSynchronizer::ExecuteSubscriber().
void GoBoardSynchronizer::PreUndo | ( | ) | [protected, virtual, inherited] |
Move about to be undone.
Default implementation does nothing.
Definition at line 62 of file GoBoardSynchronizer.cpp.
Referenced by GoBoardSynchronizer::UpdateIncremental().
void GoPlayer::SetCurrentNode | ( | SgNode * | node | ) |
Set node for appending search traces.
Definition at line 145 of file GoPlayer.h.
References m_currentNode.
Referenced by GoGame::UpdatePlayer().
void GoBoardSynchronizer::SetSubscriber | ( | GoBoard & | subscriber | ) | [inherited] |
Set the board that will subscribe to all the changes of the publisher.
Can only be called once.
Definition at line 24 of file GoBoardSynchronizer.cpp.
References GoBoardSynchronizer::m_subscriber, and SG_ASSERT.
Referenced by GoAutoBookState::GoAutoBookState(), and GoPlayer().
void GoPlayer::SetVariant | ( | int | variant | ) |
void GoBoardSynchronizer::UpdateSubscriber | ( | ) | [inherited] |
Update the subscriber board.
Calls Init, Play, Undo and/or SetToPlay to update the subscriber to the current state of the publisher. If no subscriber was set with SetSubscriber, this function does nothing.
Definition at line 96 of file GoBoardSynchronizer.cpp.
References GoBoard::GetHashCode(), GoBoardSynchronizer::m_publisher, GoBoardSynchronizer::m_subscriber, GoBoard::Rules(), GoBoard::Setup(), SG_ASSERT, GoBoard::Size(), GoBoardSynchronizer::UpdateFromInit(), GoBoardSynchronizer::UpdateIncremental(), and GoBoardSynchronizer::UpdateToPlay().
Referenced by GoGtpEngine::CmdSetupPlayer(), GoGtpEngine::RulesChanged(), GoAutoBookState::Synchronize(), and GoGame::UpdatePlayer().
int GoPlayer::Variant | ( | ) | const |
GoBoard GoPlayer::m_bd [private] |
The player's own Go board.
Definition at line 114 of file GoPlayer.h.
Referenced by Board(), and GoPlayer().
SgNode* GoPlayer::m_currentNode [protected] |
Node in game tree.
Used for appending search traces
Definition at line 110 of file GoPlayer.h.
Referenced by CurrentNode(), and SetCurrentNode().
int GoPlayer::m_variant [private] |
Player variant.
Used for short-term testing of small modifications. The default variant is 0. Do not use to create significantly different players - implement a new player instead.
Definition at line 121 of file GoPlayer.h.
Referenced by SetVariant(), and Variant().