GtpEngine with GoBoard, GoPlayer and GoGame. More...
#include <GoGtpEngine.h>
Public Member Functions | |
GoGtpEngine (int fixedBoardSize=0, const char *programPath=0, bool noPlayer=false, bool noHandicap=false) | |
Constructor. | |
~GoGtpEngine () | |
GoBook & | Book () |
const GoGame & | Game () const |
const GoBoard & | Board () const |
void | SetPlayer (GoPlayer *player) |
Set player. | |
GoPlayer & | Player () const |
Throws GtpFailure if no player set. | |
void | DumpState (std::ostream &out) const |
Write game and player boards. | |
void | SetAutoSave (const std::string &prefix) |
Automatically save game after each move. | |
void | SetStatisticsFile (const std::string &fileName) |
File to save statistics. | |
void | SetAutoShowBoard (bool showBoard) |
Automatically write board to SgDebug() after changes. | |
void | SetDebugToComment (bool debugToComment) |
Write everything written to SgDebug() during a genmove command to the comment in the new game node. | |
void | SetMaxClearBoard (int n) |
Set maximum number of clear_board commands. | |
void | SetNamedRules (const std::string &namedRules) |
Set named rules. | |
void | SetTimeLimit (double timeLimit) |
See TimeLimit(). | |
double | TimeLimit () |
Time limit in seconds for move generation and other commands. | |
void | SetMpiSynchronizer (const SgMpiSynchronizerHandle &m_handle) |
SgMpiSynchronizerHandle | MpiSynchronizer () |
const SgMpiSynchronizerHandle | MpiSynchronizer () const |
void | ExecuteFile (const std::string &name, std::ostream &log=std::cerr) |
std::string | ExecuteCommand (const std::string &cmd, std::ostream &log=std::cerr) |
void | MainLoop (GtpInputStream &in, GtpOutputStream &out) |
void | Register (const std::string &name, GtpCallbackBase *callback) |
void | Register (const std::string &command, typename GtpCallback< T >::Method method, T *instance) |
bool | IsRegistered (const std::string &command) const |
void | SetQuit () |
bool | IsQuitSet () const |
virtual void | Ponder () |
virtual void | InitPonder () |
virtual void | StopPonder () |
virtual void | Interrupt () |
virtual void | CmdKnownCommand (GtpCommand &) |
virtual void | CmdListCommands (GtpCommand &) |
virtual void | CmdProtocolVersion (GtpCommand &) |
virtual void | CmdVersion (GtpCommand &) |
Command Callbacks | |
virtual void | CmdAllLegal (GtpCommand &) |
Return all legal move points. | |
virtual void | CmdAllMoveValues (GtpCommand &) |
Like GNU Go's all_move_values. | |
virtual void | CmdAnalyzeCommands (GtpCommand &) |
Return configuration for GoGui analyze commands. | |
virtual void | CmdBoard (GtpCommand &) |
Print some information about game board. | |
virtual void | CmdBoardSize (GtpCommand &) |
Init new game with given board size. | |
virtual void | CmdClearBoard (GtpCommand &) |
Init new game. | |
virtual void | CmdClock (GtpCommand &) |
Show clock info from GoGame::Time(). | |
virtual void | CmdFinalScore (GtpCommand &) |
Compute final score. | |
virtual void | CmdFixedHandicap (GtpCommand &) |
Standard GTP command fixed_handicap. | |
virtual void | CmdGameOver (GtpCommand &) |
Implementation of cgos-gameover as used by the CGOS Python client. | |
virtual void | CmdGenMove (GtpCommand &) |
Generate and play a move. | |
virtual void | CmdGenMoveCleanup (GtpCommand &) |
Generate cleanup move. | |
virtual void | CmdGetKomi (GtpCommand &) |
Get the komi. | |
virtual void | CmdGGUndo (GtpCommand &) |
Undo multiple moves. | |
virtual void | CmdInterrupt (GtpCommand &) |
This command indicates that commands can be interrupted using the GoGui convention. | |
virtual void | CmdIsLegal (GtpCommand &) |
Check if move is legal. | |
virtual void | CmdKgsTimeSettings (GtpCommand &cmd) |
Sets time settings on kgs. | |
virtual void | CmdKomi (GtpCommand &) |
Set the komi. | |
virtual void | CmdListStones (GtpCommand &) |
List stones on board. | |
virtual void | CmdLoadSgf (GtpCommand &) |
Load a position from a SGF file. | |
virtual void | CmdName (GtpCommand &) |
Return name of player, if set, GtpEngine::Name otherwise. | |
virtual void | CmdParam (GtpCommand &) |
Get and set GoGtpEngine parameters. | |
virtual void | CmdParamRules (GtpCommand &) |
Get and set detailed rule parameters. | |
virtual void | CmdParamTimecontrol (GtpCommand &) |
Get and set time control parameters. | |
virtual void | CmdPlaceFreeHandicap (GtpCommand &) |
Standard GTP command place_free_handicap. | |
virtual void | CmdPlay (GtpCommand &) |
Play a move. | |
virtual void | CmdPlayerBoard (GtpCommand &) |
Print some information about player board. | |
virtual void | CmdPlaySequence (GtpCommand &) |
Play a sequence of moves. | |
virtual void | CmdPointNumbers (GtpCommand &) |
Show point numbers used in GoBoard. | |
virtual void | CmdPointInfo (GtpCommand &) |
Print some information about point. | |
virtual void | CmdQuit (GtpCommand &cmd) |
virtual void | CmdRegGenMove (GtpCommand &) |
Generate a move, but do not play it. | |
virtual void | CmdRegGenMoveToPlay (GtpCommand &) |
Version of CmdRegGenMove() without color argument. | |
virtual void | CmdRules (GtpCommand &) |
Set named rules. | |
virtual void | CmdSaveSgf (GtpCommand &) |
Save current game to file. | |
virtual void | CmdSentinelFile (GtpCommand &) |
Define a file that makes future clear_board commands fail. | |
virtual void | CmdSetFreeHandicap (GtpCommand &) |
Standard GTP command for explicit placement of handicap stones. | |
virtual void | CmdSetInfo (GtpCommand &) |
Set game info property in root node of internal SGF tree. | |
virtual void | CmdSetup (GtpCommand &) |
Place setup stones. | |
virtual void | CmdSetupPlayer (GtpCommand &) |
Set color to play. | |
virtual void | CmdShowBoard (GtpCommand &) |
Show current position. | |
virtual void | CmdTimeLastMove (GtpCommand &) |
Time of last ganmove command. | |
virtual void | CmdTimeLeft (GtpCommand &) |
Standard GTP command. | |
virtual void | CmdTimeSettings (GtpCommand &) |
Standard GTP command. | |
virtual void | CmdUndo (GtpCommand &) |
Undo a move. | |
Protected Member Functions | |
void | BeforeHandleCommand () |
Hook function to be executed before each command. | |
void | BeforeWritingResponse () |
Hook function to be executed before the response of a command is written. | |
void | BoardChanged () |
void | CheckLegal (std::string message, SgBlackWhite color, SgPoint move, bool checkOnlyOccupied) |
Check if move is legal. | |
void | CheckMaxClearBoard () |
void | CheckMoveStackOverflow () const |
SgPoint | GenMove (SgBlackWhite color, bool ignoreClock) |
void | RespondNumberArray (GtpCommand &cmd, const SgPointArray< int > &array, int scale) |
Write integer array response to command. | |
void | Init (int size) |
void | Play (SgBlackWhite color, SgPoint move) |
Play a move in game and goto new node. | |
SgBlackWhite | BlackWhiteArg (const GtpCommand &cmd, std::size_t number) const |
SgEmptyBlackWhite | EmptyBlackWhiteArg (const GtpCommand &cmd, std::size_t number) const |
SgPoint | EmptyPointArg (const GtpCommand &cmd, std::size_t number) const |
SgPoint | MoveArg (const GtpCommand &cmd, std::size_t number) const |
SgPoint | PointArg (const GtpCommand &cmd) const |
Check that number of arguments is one and get point argument. | |
SgPoint | PointArg (const GtpCommand &cmd, std::size_t number) const |
SgVector< SgPoint > | PointListArg (const GtpCommand &cmd, std::size_t number) const |
SgVector< SgPoint > | PointListArg (const GtpCommand &cmd) const |
SgPoint | StoneArg (const GtpCommand &cmd, std::size_t number) const |
void | RulesChanged () |
Statistics file | |
virtual std::vector< std::string > | CreateStatisticsSlots () |
Create additional slots for the statistics file. | |
virtual void | AddPlayStatistics () |
Add statistics for the last generated move. | |
void | AddStatistics (const std::string &key, const std::string &value) |
See CreateStatisticsSlots(). | |
template<typename T > | |
void | AddStatistics (const std::string &key, const T &value) |
See CreateStatisticsSlots(). | |
Protected Attributes | |
GoPlayer * | m_player |
Current player. | |
boost::scoped_ptr< GoAutoBook > | m_autoBook |
Private Member Functions | |
void | ApplyTimeSettings () |
void | AutoSave () const |
void | CheckBoardEmpty () const |
void | CreateAutoSaveFileName () |
void | GameFinished () |
Do what is necessary when a game is finished. | |
SgPoint | GenBookMove (SgBlackWhite toPlay) |
void | InitStatistics () |
void | PlaceHandicap (const SgVector< SgPoint > &stones) |
void | SaveGame (const std::string &fileName) const |
void | SaveStatistics () |
void | StartStatistics () |
void | Undo (int n) |
Static Private Member Functions | |
static void | WriteBoardInfo (GtpCommand &cmd, const GoBoard &bd) |
Write board info. | |
Private Attributes | |
bool | m_noPlayer |
bool | m_acceptIllegal |
Accept illegal ko or suicide moves in CmdPlay(). | |
bool | m_autoSave |
See SetAutoSave(). | |
bool | m_autoShowBoard |
See SetAutoShowBoard(). | |
bool | m_debugToComment |
See SetDebugToComment(). | |
bool | m_useBook |
bool | m_isPonderPosition |
Flag set to false if pondering in current position would be a waste of CPU time. | |
int | m_fixedBoardSize |
int | m_maxClearBoard |
Maximum number of clear_board commands. | |
int | m_numberClearBoard |
Number of clear_board commands. | |
double | m_timeLastMove |
double | m_timeLimit |
See GoGtpEngine::CmdTimeLimit. | |
double | m_overhead |
Operator overhead time for time settings. | |
GoTimeSettings | m_timeSettings |
Time settings for game. | |
GoRules | m_defaultRules |
Default rules. | |
GoGame | m_game |
Order dependency: destruct m_game before m_board. | |
SgGtpCommands | m_sgCommands |
GoBook | m_book |
GoBookCommands | m_bookCommands |
std::string | m_autoSaveFileName |
std::string | m_autoSavePrefix |
boost::filesystem::path | m_sentinelFile |
See CmdSentinelFile(). | |
std::string | m_statisticsFile |
std::vector< std::string > | m_statisticsSlots |
See CreateStatisticsSlots(). | |
std::vector< std::string > | m_statisticsValues |
See CreateStatisticsSlots(). | |
SgMpiSynchronizerHandle | m_mpiSynchronizer |
GtpEngine with GoBoard, GoPlayer and GoGame.
Definition at line 28 of file GoGtpEngine.h.
GoGtpEngine::GoGtpEngine | ( | int | fixedBoardSize = 0 , |
|
const char * | programPath = 0 , |
|||
bool | noPlayer = false , |
|||
bool | noHandicap = false | |||
) |
Constructor.
fixedBoardSize | Initial and only allowed size of the board. 0 means startup with GO_DEFAULT_SIZE and allow to change board size | |
programPath | File path to the executable. Needed for SgGtpCommands::CmdDebugger | |
noPlayer | Indicate that the subclass will not set a player with SetPlayer(). Useful for GTP engines that cannot play moves (e.g. TsumeGo solvers) This causes player-specific GTP commands, like reg_genmove ) not to be registered. | |
noHandicap | Don't register handicap commands (useful, to avoid accepting handicap games on KGS) |
Definition at line 80 of file GoGtpEngine.cpp.
References Board(), CmdAllLegal(), CmdAllMoveValues(), CmdAnalyzeCommands(), CmdBoard(), CmdBoardSize(), CmdClearBoard(), CmdClock(), CmdFinalScore(), CmdFixedHandicap(), CmdGameOver(), CmdGenMove(), CmdGenMoveCleanup(), CmdGetKomi(), CmdGGUndo(), CmdInterrupt(), CmdIsLegal(), CmdKgsTimeSettings(), CmdKomi(), CmdListStones(), CmdLoadSgf(), CmdParam(), CmdParamRules(), CmdParamTimecontrol(), CmdPlaceFreeHandicap(), CmdPlay(), CmdPlayerBoard(), CmdPlaySequence(), CmdPointInfo(), CmdPointNumbers(), CmdRegGenMove(), CmdRegGenMoveToPlay(), CmdRules(), CmdSaveSgf(), CmdSentinelFile(), CmdSetFreeHandicap(), CmdSetInfo(), CmdSetup(), CmdSetupPlayer(), CmdShowBoard(), CmdTimeLastMove(), CmdTimeLeft(), CmdTimeSettings(), CmdUndo(), Init(), m_bookCommands, m_sgCommands, GoBookCommands::Register(), SgGtpCommands::Register(), and GtpEngine::Register().
GoGtpEngine::~GoGtpEngine | ( | ) |
Definition at line 161 of file GoGtpEngine.cpp.
References m_player.
void GoGtpEngine::AddPlayStatistics | ( | ) | [protected, virtual] |
Add statistics for the last generated move.
See CreateStatisticsSlots(). Default implementation does nothing.
Definition at line 166 of file GoGtpEngine.cpp.
Referenced by GenMove().
void GoGtpEngine::AddStatistics | ( | const std::string & | key, | |
const std::string & | value | |||
) | [protected] |
Definition at line 171 of file GoGtpEngine.cpp.
References m_statisticsSlots, m_statisticsValues, and SG_ASSERT.
Referenced by AddStatistics(), and GenMove().
void GoGtpEngine::AddStatistics | ( | const std::string & | key, | |
const T & | value | |||
) | [protected] |
Definition at line 434 of file GoGtpEngine.h.
References AddStatistics().
void GoGtpEngine::ApplyTimeSettings | ( | ) | [private] |
Definition at line 188 of file GoGtpEngine.cpp.
References Board(), m_game, m_timeSettings, GoGame::SetTimeSettingsGlobal(), and SG_ASSERT.
Referenced by CmdKgsTimeSettings(), CmdTimeSettings(), and Init().
void GoGtpEngine::AutoSave | ( | ) | const [private] |
Definition at line 194 of file GoGtpEngine.cpp.
References m_autoSave, m_autoSaveFileName, GtpFailure::Response(), SaveGame(), and SgWarning().
Referenced by BoardChanged(), CmdGameOver(), CmdGenMove(), and CmdSetInfo().
void GoGtpEngine::BeforeHandleCommand | ( | ) | [protected, virtual] |
Hook function to be executed before each command.
Resets user abort flag. Lengthy functions should poll SgUserAbort but should not reset the user abort flag themselves. Also flushes SgDebug() (see comment at BeforeWritingResponse()).
Reimplemented from GtpEngine.
Definition at line 221 of file GoGtpEngine.cpp.
References SgDebug(), and SgSetUserAbort().
void GoGtpEngine::BeforeWritingResponse | ( | ) | [protected, virtual] |
Hook function to be executed before the response of a command is written.
Flushes SgDebug().
Reimplemented from GtpEngine.
Definition at line 227 of file GoGtpEngine.cpp.
References SgDebug().
SgBlackWhite GoGtpEngine::BlackWhiteArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1239 of file GoGtpEngine.cpp.
Referenced by CmdAllLegal(), CmdGenMove(), CmdIsLegal(), CmdListStones(), CmdPlay(), CmdPlaySequence(), CmdRegGenMove(), CmdSetup(), CmdSetupPlayer(), and CmdTimeLeft().
const GoBoard & GoGtpEngine::Board | ( | ) | const |
Definition at line 441 of file GoGtpEngine.h.
References GoGame::Board(), and m_game.
Referenced by ApplyTimeSettings(), BoardChanged(), CheckBoardEmpty(), CheckLegal(), CheckMoveStackOverflow(), CmdAllLegal(), CmdAllMoveValues(), CmdBoard(), CmdBoardSize(), CmdClearBoard(), CmdFinalScore(), CmdFixedHandicap(), CmdGenMoveCleanup(), CmdGetKomi(), CmdIsLegal(), CmdKgsTimeSettings(), CmdListStones(), CmdLoadSgf(), CmdParamRules(), CmdPlaceFreeHandicap(), CmdPlayerBoard(), CmdPointInfo(), CmdPointNumbers(), CmdQuit(), CmdRegGenMoveToPlay(), CmdSetup(), CmdShowBoard(), CmdTimeSettings(), DumpState(), EmptyPointArg(), GenBookMove(), GoGtpEngine(), MoveArg(), PointArg(), PointListArg(), RespondNumberArray(), SetAutoShowBoard(), and StoneArg().
void GoGtpEngine::BoardChanged | ( | ) | [protected] |
Definition at line 208 of file GoGtpEngine.cpp.
References AutoSave(), Board(), GoBoardUtil::EndOfGame(), GenBookMove(), GoBoardUtil::IsBoardEmpty(), m_autoShowBoard, m_isPonderPosition, m_player, SG_NULLMOVE, SgDebug(), GoBoard::ToPlay(), and GoBoardSynchronizer::UpdateSubscriber().
Referenced by CmdClearBoard(), CmdGenMove(), CmdGGUndo(), CmdLoadSgf(), CmdPlay(), CmdPlaySequence(), CmdSetup(), CmdSetupPlayer(), CmdUndo(), Init(), and PlaceHandicap().
GoBook & GoGtpEngine::Book | ( | ) |
Definition at line 446 of file GoGtpEngine.h.
References m_book.
void GoGtpEngine::CheckBoardEmpty | ( | ) | const [private] |
Definition at line 232 of file GoGtpEngine.cpp.
References Board(), and GoBoardUtil::IsBoardEmpty().
Referenced by CmdPlaceFreeHandicap(), and PlaceHandicap().
void GoGtpEngine::CheckLegal | ( | std::string | message, | |
SgBlackWhite | color, | |||
SgPoint | move, | |||
bool | checkOnlyOccupied | |||
) | [protected] |
Check if move is legal.
message | Prefix for error message; move and reason will be appended | |
color | Player of move | |
move | The move | |
checkOnlyOccupied | Only check if point is empty (accepts moves that are illegal, because of the ko or suicide rules used) |
GtpFailure | if not legal. |
Definition at line 245 of file GoGtpEngine.cpp.
References GoModBoard::Board(), Board(), GoGame::CurrentMoveNumber(), GoRules::GetKoRule(), GoBoard::GetLastMoveInfo(), GO_MOVEFLAG_ILLEGAL, GO_MOVEFLAG_REPETITION, GO_MOVEFLAG_SUICIDE, m_game, GoBoard::Occupied(), GoBoard::Play(), GoBoard::Rules(), SG_PASS, SgBW(), and GoBoard::Undo().
void GoGtpEngine::CheckMaxClearBoard | ( | ) | [protected] |
Definition at line 285 of file GoGtpEngine.cpp.
References m_maxClearBoard, and m_numberClearBoard.
Referenced by CmdClearBoard().
void GoGtpEngine::CheckMoveStackOverflow | ( | ) | const [protected] |
Definition at line 1225 of file GoGtpEngine.cpp.
References Board(), and GO_MAX_NUM_MOVES.
void GoGtpEngine::CmdAllLegal | ( | GtpCommand & | cmd | ) | [virtual] |
Return all legal move points.
Compatible with GNU Go's all_legal command.
Arguments: color
Definition at line 296 of file GoGtpEngine.cpp.
References BlackWhiteArg(), Board(), GtpCommand::CheckNuArg(), and SgVector< T >::PushBack().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdAllMoveValues | ( | GtpCommand & | cmd | ) | [virtual] |
Like GNU Go's all_move_values.
Definition at line 308 of file GoGtpEngine.cpp.
References Board(), GtpCommand::CheckArgNone(), GoPlayer::MoveValue(), GoBoard::Occupied(), and Player().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdAnalyzeCommands | ( | GtpCommand & | cmd | ) | [virtual] |
Return configuration for GoGui analyze commands.
See the GoGui documentation http://gogui.sf.net
Definition at line 324 of file GoGtpEngine.cpp.
References GoBookCommands::AddGoGuiAnalyzeCommands(), SgGtpCommands::AddGoGuiAnalyzeCommands(), GtpCommand::CheckArgNone(), m_bookCommands, m_noPlayer, and m_sgCommands.
Referenced by GoGtpEngine().
void GoGtpEngine::CmdBoard | ( | GtpCommand & | cmd | ) | [virtual] |
Print some information about game board.
See WriteBoardInfo for optional arguments.
Definition at line 356 of file GoGtpEngine.cpp.
References Board(), and WriteBoardInfo().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdBoardSize | ( | GtpCommand & | cmd | ) | [virtual] |
Init new game with given board size.
Definition at line 362 of file GoGtpEngine.cpp.
References GtpCommand::ArgMinMax(), Board(), GtpCommand::CheckNuArg(), GameFinished(), Init(), m_fixedBoardSize, SG_MAX_SIZE, and SG_MIN_SIZE.
Referenced by GoGtpEngine().
void GoGtpEngine::CmdClearBoard | ( | GtpCommand & | cmd | ) | [virtual] |
Init new game.
Definition at line 375 of file GoGtpEngine.cpp.
References Board(), BoardChanged(), GtpCommand::CheckArgNone(), CheckMaxClearBoard(), GameFinished(), Init(), m_player, m_sentinelFile, and GoPlayer::OnNewGame().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdClock | ( | GtpCommand & | cmd | ) | [virtual] |
Show clock info from GoGame::Time().
Definition at line 391 of file GoGtpEngine.cpp.
References GtpCommand::CheckArgNone(), m_game, and GoGame::Time().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdFinalScore | ( | GtpCommand & | cmd | ) | [virtual] |
Compute final score.
Computes a final score only, if Tromp-Taylor rules are used (GoRules::CaptureDead() == true and GoRules::JapaneseScoring() == false). Otherwise it returns an error. Override this function for players that have enough knowledge to do a better scoring.
Definition at line 402 of file GoGtpEngine.cpp.
References Board(), GoRules::CaptureDead(), GtpCommand::CheckArgNone(), GoRules::JapaneseScoring(), GoRules::Komi(), GoBoard::Rules(), GoUtil::ScoreToString(), GoKomi::ToFloat(), and GoBoardUtil::TrompTaylorScore().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdFixedHandicap | ( | GtpCommand & | cmd | ) | [virtual] |
Standard GTP command fixed_handicap.
Definition at line 414 of file GoGtpEngine.cpp.
References GtpCommand::ArgMin(), Board(), GoGtpCommandUtil::GetHandicapStones(), PlaceHandicap(), and GoBoard::Size().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdGameOver | ( | GtpCommand & | cmd | ) | [virtual] |
Implementation of cgos-gameover as used by the CGOS Python client.
See http://cgos.sourceforge.net/client-python/doc/index.html Stores the game result in the root node of internal SGF tree and sets a flag that prevents the engine from pondering.
Definition at line 426 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), AutoSave(), GtpCommand::CheckNuArg(), m_game, m_isPonderPosition, and GoGame::UpdateResult().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdGenMove | ( | GtpCommand & | cmd | ) | [virtual] |
Generate and play a move.
Definition at line 436 of file GoGtpEngine.cpp.
References GoGame::AddComment(), GoGame::AddMove(), GoGame::AddResignNode(), AutoSave(), BlackWhiteArg(), BoardChanged(), GtpCommand::CheckNuArg(), GenMove(), GoGame::GetPlayerName(), m_debugToComment, m_game, Player(), SG_RESIGN, and GoGame::UpdatePlayerName().
Referenced by CmdGenMoveCleanup(), and GoGtpEngine().
void GoGtpEngine::CmdGenMoveCleanup | ( | GtpCommand & | cmd | ) | [virtual] |
Generate cleanup move.
As defined in the kgsGtp interface to the KGS Go server. Should not return pass, before all enemy dead stones are captured.
Arguments: color
final_status_list
dead command. See also http://sourceforge.net/apps/trac/fuego/ticket/15 Definition at line 479 of file GoGtpEngine.cpp.
References Board(), GoRules::CaptureDead(), CmdGenMove(), m_game, GoBoard::Rules(), RulesChanged(), GoRules::SetCaptureDead(), and GoGame::SetRulesGlobal().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdGetKomi | ( | GtpCommand & | cmd | ) | [virtual] |
Get the komi.
Compatible to GNU Go's get_komi.
Definition at line 504 of file GoGtpEngine.cpp.
References Board(), GtpCommand::CheckArgNone(), GoRules::Komi(), and GoBoard::Rules().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdGGUndo | ( | GtpCommand & | cmd | ) | [virtual] |
Undo multiple moves.
Extension command introduced by GNU Go to undo multiple moves.
Arguments: optional int
Fails: if move history is too short
Returns: nothing
Definition at line 515 of file GoGtpEngine.cpp.
References GtpCommand::ArgMin(), BoardChanged(), GtpCommand::CheckNuArgLessEqual(), GtpCommand::NuArg(), and Undo().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdInterrupt | ( | GtpCommand & | cmd | ) | [virtual] |
This command indicates that commands can be interrupted using the GoGui convention.
The command does nothing but indicate the ability to handle the special comment line # interrupt
used by GoGui. It is registered as a handler for gogui-interrupt
.
Definition at line 583 of file GoGtpEngine.cpp.
References GtpCommand::CheckArgNone().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdIsLegal | ( | GtpCommand & | cmd | ) | [virtual] |
Check if move is legal.
Compatible with GNU Go's is_legal. Arguments: color move
Returns: 0/1
Definition at line 592 of file GoGtpEngine.cpp.
References BlackWhiteArg(), Board(), GtpCommand::CheckNuArg(), and MoveArg().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdKgsTimeSettings | ( | GtpCommand & | cmd | ) | [virtual] |
Sets time settings on kgs.
Handles the four different kinds of time control on kgs, "none", "absolute", "byoyomi" (which is not currently fully supported), and "canadian".
Definition at line 526 of file GoGtpEngine.cpp.
References ApplyTimeSettings(), GtpCommand::Arg(), GtpCommand::ArgMin(), Board(), GtpCommand::CheckNuArg(), m_timeSettings, GoBoard::MoveNumber(), and GtpCommand::NuArg().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdKomi | ( | GtpCommand & | cmd | ) | [virtual] |
Set the komi.
GTP standard command.
Definition at line 602 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), m_defaultRules, m_game, RulesChanged(), GoRules::SetKomi(), GoGame::SetKomiGlobal(), and SgException::what().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdListStones | ( | GtpCommand & | cmd | ) | [virtual] |
List stones on board.
Mainly useful for regression tests to verify the board position. For compatibility with GNU Go's list_stones command, the points are returned in a single line in the same order that is used by GNU Go 3.6 (A19, B19, ..., A18, B18, ...)
Arguments: color
Returns: List of stones
Definition at line 625 of file GoGtpEngine.cpp.
References GoBoard::All(), BlackWhiteArg(), Board(), GtpCommand::CheckNuArg(), SgPointSet::Contains(), Pt(), and GoBoard::Size().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdLoadSgf | ( | GtpCommand & | cmd | ) | [virtual] |
Load a position from a SGF file.
Definition at line 647 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::ArgMin(), Board(), BoardChanged(), GtpCommand::CheckNuArgLessEqual(), GoGame::CurrentNode(), GameFinished(), GoNodeUtil::GetHandicap(), GoNodeUtil::GetKomi(), SgGameReader::GetWarnings(), GoGameUtil::GotoBeforeMove(), GoGame::Init(), m_defaultRules, m_game, m_player, GtpCommand::NuArg(), GoPlayer::OnNewGame(), SgGameReader::PrintWarnings(), SgGameReader::ReadGame(), RulesChanged(), GoRules::SetHandicap(), GoRules::SetKomi(), GoGame::SetRulesGlobal(), SgDebug(), and SgWarning().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdName | ( | GtpCommand & | cmd | ) | [virtual] |
Return name of player, if set, GtpEngine::Name otherwise.
Reimplemented from GtpEngine.
Definition at line 682 of file GoGtpEngine.cpp.
References GtpCommand::CheckArgNone(), m_player, and GoPlayer::Name().
void GoGtpEngine::CmdParam | ( | GtpCommand & | cmd | ) | [virtual] |
Get and set GoGtpEngine parameters.
Parameters:
auto_save
See SetAutoSave() accept_illegal
Accept illegal ko or suicide moves in CmdPlay() debug_to_comment
See SetDebugToComment() overhead
See SgTimeRecord::SetOverhead() statistics_file
See SetStatisticsFile() timelimit
See TimeLimit() Definition at line 699 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::CheckNuArgLessEqual(), m_acceptIllegal, m_autoSave, m_autoSavePrefix, m_debugToComment, m_game, m_overhead, m_statisticsFile, m_timeLimit, m_useBook, GtpCommand::NuArg(), GtpCommand::RemainingLine(), SetAutoSave(), SgTimeRecord::SetOverhead(), SetStatisticsFile(), and GoGame::Time().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdParamRules | ( | GtpCommand & | cmd | ) | [virtual] |
Get and set detailed rule parameters.
Changes the rules in the current game as well as the default rule.
Parameters:
allow_suicde
See GoRules:AllowSuicide() capture_dead
See GoRules:CaptureDead() extra_handicap_komi
See GoRules:ExtraHandicapKomi() japanese_scoring
See GoRules:JapaneseScoring() two_passes_end_game
See GoRules:TwoPassesEndGame() ko_rule
(simple, superko, pos_superko) See GoRules:KoRule() Definition at line 756 of file GoGtpEngine.cpp.
References GoRules::AllowSuicide(), GtpCommand::Arg(), Board(), GoRules::CaptureDead(), GtpCommand::CheckNuArgLessEqual(), GoRules::ExtraHandicapKomi(), GoRules::GetKoRule(), GoRules::JapaneseScoring(), m_defaultRules, m_game, GtpCommand::NuArg(), GoBoard::Rules(), RulesChanged(), GoRules::SetAllowSuicide(), GoRules::SetCaptureDead(), GoRules::SetExtraHandicapKomi(), GoRules::SetJapaneseScoring(), GoRules::SetKoRule(), GoGame::SetRulesGlobal(), GoRules::SetTwoPassesEndGame(), and GoRules::TwoPassesEndGame().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdParamTimecontrol | ( | GtpCommand & | cmd | ) | [virtual] |
Get and set time control parameters.
Fails if the current player is not a SgObjectWithDefaultTimeControl or the time control is not a GoTimeControl.
Parameters:
fast_open_factor
See SgDefaultTimeControl::FastOpenFactor() fast_open_moves
See SgDefaultTimeControl::FastOpenMoves() final_space
See GoTimeControl::FinalSpace() remaining_constant
See SgDefaultTimeControl::RemainingConstant() Definition at line 827 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::ArgMin(), GtpCommand::CheckNuArgLessEqual(), SgDefaultTimeControl::FastOpenFactor(), SgDefaultTimeControl::FastOpenMoves(), GoTimeControl::FinalSpace(), GtpCommand::NuArg(), Player(), SgDefaultTimeControl::RemainingConstant(), SgDefaultTimeControl::SetFastOpenFactor(), SgDefaultTimeControl::SetFastOpenMoves(), GoTimeControl::SetFinalSpace(), and SgDefaultTimeControl::SetRemainingConstant().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdPlaceFreeHandicap | ( | GtpCommand & | cmd | ) | [virtual] |
Standard GTP command place_free_handicap.
The current implementation uses the same locations as for fixed_handicap, if defined, and generates additional handicap locations by making the player play moves.
Arguments: number of handicap stones
Effect: Places handicap stones at chosen locations
Returns: Handicap stone locations
Definition at line 871 of file GoGtpEngine.cpp.
References GoSetup::AddBlack(), GtpCommand::ArgMin(), GoPlayer::Board(), Board(), CheckBoardEmpty(), GenMove(), GoGtpCommandUtil::GetHandicapStones(), GoBoard::Init(), SgVector< T >::Length(), m_player, PlaceHandicap(), GoBoard::Play(), SgVector< T >::PushBack(), SG_ASSERT, SG_BLACK, SG_PASS, SgDebug(), and GoBoard::Size().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdPlay | ( | GtpCommand & | cmd | ) | [virtual] |
Play a move.
Definition at line 916 of file GoGtpEngine.cpp.
References BlackWhiteArg(), BoardChanged(), GtpCommand::CheckNuArg(), MoveArg(), and Play().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdPlayerBoard | ( | GtpCommand & | cmd | ) | [virtual] |
Print some information about player board.
See WriteBoardInfo for optional arguments.
Definition at line 1003 of file GoGtpEngine.cpp.
References Board(), Player(), and WriteBoardInfo().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdPlaySequence | ( | GtpCommand & | cmd | ) | [virtual] |
Play a sequence of moves.
Extension to standard play command used by GoGui. This command is registered with the command name gogui-play_sequence
as used in newer versions of GoGui and for a transition period also with play_sequence
as used by older versions of GoGui
Definition at line 930 of file GoGtpEngine.cpp.
References BlackWhiteArg(), BoardChanged(), GoGame::CurrentNode(), GoGame::GoToNode(), m_game, MoveArg(), GtpCommand::NuArg(), and Play().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdPointInfo | ( | GtpCommand & | cmd | ) | [virtual] |
Print some information about point.
Definition at line 951 of file GoGtpEngine.cpp.
References GoBoardUtil::AdjacentBlocks(), GoBoard::Anchor(), Board(), GoBoard::GetColor(), GoBoard::InAtari(), GoBoard::InCenter(), GoBoard::InCorner(), GoBoard::IsFirst(), GoBoard::IsLegal(), GoEyeUtil::IsPossibleEye(), GoEyeUtil::IsSimpleEye(), GoEyeUtil::IsSinglePointEye(), GoBoard::IsSingleStone(), GoBoard::IsSuicide(), GoBoard::Line(), GoEyeUtil::MakesNakadeShape(), GoBoard::Num8EmptyNeighbors(), GoBoard::NumEmptyNeighbors(), GoBoard::NumLiberties(), GoBoard::NumStones(), GoBoard::Occupied(), GoBoard::OnEdge(), PointArg(), GoBoard::Pos(), SG_BLACK, SG_MAXPOINT, SG_WHITE, and SgEBW().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdPointNumbers | ( | GtpCommand & | cmd | ) | [virtual] |
Show point numbers used in GoBoard.
Definition at line 1009 of file GoGtpEngine.cpp.
References Board(), GtpCommand::CheckArgNone(), and GoBoard::Size().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdQuit | ( | GtpCommand & | cmd | ) | [virtual] |
Reimplemented from GtpEngine.
Definition at line 1018 of file GoGtpEngine.cpp.
References Board(), GtpCommand::CheckArgNone(), and GameFinished().
void GoGtpEngine::CmdRegGenMove | ( | GtpCommand & | cmd | ) | [virtual] |
Generate a move, but do not play it.
Like in GNU Go, if there was a random seed set, it is initialized before each reg_genmove to avoid a dependency of the random numbers on previous move generations.
Definition at line 1030 of file GoGtpEngine.cpp.
References BlackWhiteArg(), GtpCommand::CheckNuArg(), GenMove(), SgRandom::Seed(), SgRandom::SetSeed(), and SG_RESIGN.
Referenced by GoGtpEngine().
void GoGtpEngine::CmdRegGenMoveToPlay | ( | GtpCommand & | cmd | ) | [virtual] |
Version of CmdRegGenMove() without color argument.
This is a non-standard version of reg_genmove without color argument. It generates a move for the color to play.
Definition at line 1045 of file GoGtpEngine.cpp.
References Board(), GtpCommand::CheckArgNone(), GenMove(), SgRandom::Seed(), and SgRandom::SetSeed().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdRules | ( | GtpCommand & | cmd | ) | [virtual] |
Set named rules.
Definition at line 1055 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::CheckNuArg(), and SetNamedRules().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdSaveSgf | ( | GtpCommand & | cmd | ) | [virtual] |
Save current game to file.
Saves the complete game tree, including any trees from searches if storing searches is enabled with global flags.
Argument: filename
Definition at line 1073 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::CheckNuArg(), and SaveGame().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdSentinelFile | ( | GtpCommand & | cmd | ) | [virtual] |
Define a file that makes future clear_board commands fail.
Defining a sentinel file can be used, for example, to abort playing on KGS, because kgsGtp.jar quits, if a clear_board command fails. This command will remove the sentinel file, if it currently exists. Future invocations of clear_board will fail, if the sentinel file exists at that time.
Argument: filename
Definition at line 1086 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::CheckNuArg(), and m_sentinelFile.
Referenced by GoGtpEngine().
void GoGtpEngine::CmdSetFreeHandicap | ( | GtpCommand & | cmd | ) | [virtual] |
Standard GTP command for explicit placement of handicap stones.
Arguments: list of points
Definition at line 1105 of file GoGtpEngine.cpp.
References PlaceHandicap(), PointListArg(), and SgVector< T >::RemoveDuplicates().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdSetInfo | ( | GtpCommand & | cmd | ) | [virtual] |
Set game info property in root node of internal SGF tree.
Arguments: info value (value is remaining line after gameinfo)
Supported infos:
Definition at line 1120 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), AutoSave(), m_game, m_isPonderPosition, GtpCommand::RemainingLine(), SG_BLACK, SG_WHITE, GoGame::UpdateGameName(), GoGame::UpdatePlayerName(), and GoGame::UpdateResult().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdSetup | ( | GtpCommand & | cmd | ) | [virtual] |
Place setup stones.
GTP extension command used by GoGui.
Argument: color point [color point ...]
With color: b, black, w, white
Definition at line 1142 of file GoGtpEngine.cpp.
References BlackWhiteArg(), Board(), BoardChanged(), m_game, GoBoard::MoveNumber(), GtpCommand::NuArg(), PointArg(), and GoGame::SetupPosition().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdSetupPlayer | ( | GtpCommand & | cmd | ) | [virtual] |
Set color to play.
GTP extension command used by GoGui.
Argument: color
Definition at line 1165 of file GoGtpEngine.cpp.
References BlackWhiteArg(), BoardChanged(), GtpCommand::CheckNuArg(), m_game, and GoGame::SetToPlay().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdShowBoard | ( | GtpCommand & | cmd | ) | [virtual] |
Show current position.
Definition at line 1173 of file GoGtpEngine.cpp.
References Board(), and GtpCommand::CheckArgNone().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdTimeLastMove | ( | GtpCommand & | cmd | ) | [virtual] |
Time of last ganmove command.
Definition at line 1180 of file GoGtpEngine.cpp.
References GtpCommand::CheckArgNone(), and m_timeLastMove.
Referenced by GoGtpEngine().
void GoGtpEngine::CmdTimeLeft | ( | GtpCommand & | cmd | ) | [virtual] |
Standard GTP command.
Definition at line 1187 of file GoGtpEngine.cpp.
References GtpCommand::Arg(), GtpCommand::ArgMin(), BlackWhiteArg(), GtpCommand::CheckNuArg(), m_game, SgTimeRecord::SetTimeLeft(), and GoGame::Time().
Referenced by GoGtpEngine().
void GoGtpEngine::CmdTimeSettings | ( | GtpCommand & | cmd | ) | [virtual] |
Standard GTP command.
Definition at line 1202 of file GoGtpEngine.cpp.
References ApplyTimeSettings(), GtpCommand::ArgMin(), Board(), GtpCommand::CheckNuArg(), and m_timeSettings.
Referenced by GoGtpEngine().
void GoGtpEngine::CmdUndo | ( | GtpCommand & | cmd | ) | [virtual] |
Undo a move.
Definition at line 1218 of file GoGtpEngine.cpp.
References BoardChanged(), GtpCommand::CheckArgNone(), and Undo().
Referenced by GoGtpEngine().
void GoGtpEngine::CreateAutoSaveFileName | ( | ) | [private] |
Definition at line 1245 of file GoGtpEngine.cpp.
References m_autoSaveFileName, and m_autoSavePrefix.
Referenced by Init(), and SetAutoSave().
std::vector< std::string > GoGtpEngine::CreateStatisticsSlots | ( | ) | [protected, virtual] |
Create additional slots for the statistics file.
This function will be called whenever a new player is set in GoGtpEngine. The default implementation returns an empty list.
Definition at line 1234 of file GoGtpEngine.cpp.
Referenced by InitStatistics().
void GoGtpEngine::DumpState | ( | std::ostream & | out | ) | const |
Write game and player boards.
Definition at line 1256 of file GoGtpEngine.cpp.
References GoPlayer::Board(), Board(), GoBoardUtil::DumpBoard(), and m_player.
Referenced by GoGtpAssertionHandler::Run().
SgEmptyBlackWhite GoGtpEngine::EmptyBlackWhiteArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1267 of file GoGtpEngine.cpp.
SgPoint GoGtpEngine::EmptyPointArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1273 of file GoGtpEngine.cpp.
References Board().
const GoGame & GoGtpEngine::Game | ( | ) | const |
Definition at line 451 of file GoGtpEngine.h.
References m_game.
void GoGtpEngine::GameFinished | ( | ) | [private] |
Do what is necessary when a game is finished.
Note that since GTP allows arbitrary state changes, it is not always clearly defined, if a game is played and when it is finished, but this function should at least be ensured to be called at the end of a game in the use case of playing a game or a series of games.
Definition at line 1284 of file GoGtpEngine.cpp.
References m_player, and GoPlayer::OnGameFinished().
Referenced by CmdBoardSize(), CmdClearBoard(), CmdLoadSgf(), and CmdQuit().
SgPoint GoGtpEngine::GenBookMove | ( | SgBlackWhite | toPlay | ) | [private] |
Definition at line 1290 of file GoGtpEngine.cpp.
References Board(), GoBook::LookupMove(), m_autoBook, m_book, m_useBook, and SG_NULLMOVE.
Referenced by BoardChanged(), and GenMove().
SgPoint GoGtpEngine::GenMove | ( | SgBlackWhite | color, | |
bool | ignoreClock | |||
) | [protected] |
Definition at line 1299 of file GoGtpEngine.cpp.
References AddPlayStatistics(), AddStatistics(), GoGame::AppendChild(), CheckLegal(), CheckMoveStackOverflow(), GoPlayer::ClearSearchTraces(), GoGame::CurrentMoveNumber(), GenBookMove(), GoPlayer::GenMove(), SgTime::Get(), GoTimeSettings::IsUnknown(), m_autoSaveFileName, m_game, m_isPonderPosition, m_mpiSynchronizer, m_timeLastMove, m_timeLimit, m_timeSettings, GoPlayer::Name(), Player(), SaveStatistics(), SG_ASSERT_BW, SG_NULLMOVE, SG_RESIGN, SgDebug(), StartStatistics(), GoGame::Time(), and GoPlayer::TransferSearchTraces().
Referenced by CmdGenMove(), CmdPlaceFreeHandicap(), CmdRegGenMove(), and CmdRegGenMoveToPlay().
void GoGtpEngine::Init | ( | int | size | ) | [protected] |
Definition at line 1345 of file GoGtpEngine.cpp.
References ApplyTimeSettings(), BoardChanged(), CreateAutoSaveFileName(), GoGame::Init(), m_defaultRules, m_game, SgTime::TodaysDate(), and GoGame::UpdateDate().
Referenced by CmdBoardSize(), CmdClearBoard(), and GoGtpEngine().
void GoGtpEngine::InitStatistics | ( | ) | [private] |
Definition at line 1354 of file GoGtpEngine.cpp.
References CreateStatisticsSlots(), m_statisticsFile, m_statisticsSlots, and MpiSynchronizer().
Referenced by SetPlayer(), and SetStatisticsFile().
SgPoint GoGtpEngine::MoveArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1393 of file GoGtpEngine.cpp.
References Board().
Referenced by CmdIsLegal(), CmdPlay(), and CmdPlaySequence().
SgMpiSynchronizerHandle GoGtpEngine::MpiSynchronizer | ( | ) |
Definition at line 1658 of file GoGtpEngine.cpp.
References m_mpiSynchronizer.
Referenced by GoBookCommands::CmdSave(), GoBookCommands::CmdSaveAs(), InitStatistics(), SaveGame(), and SaveStatistics().
const SgMpiSynchronizerHandle GoGtpEngine::MpiSynchronizer | ( | ) | const |
Definition at line 1663 of file GoGtpEngine.cpp.
References m_mpiSynchronizer.
Definition at line 1398 of file GoGtpEngine.cpp.
References BoardChanged(), CheckBoardEmpty(), m_game, GoGame::PlaceHandicap(), and RulesChanged().
Referenced by CmdFixedHandicap(), CmdPlaceFreeHandicap(), and CmdSetFreeHandicap().
void GoGtpEngine::Play | ( | SgBlackWhite | color, | |
SgPoint | move | |||
) | [protected] |
Play a move in game and goto new node.
GtpFailure | If move stack overflow or illegal move. |
Definition at line 1406 of file GoGtpEngine.cpp.
References GoGame::AddMove(), CheckLegal(), CheckMoveStackOverflow(), m_acceptIllegal, m_game, m_isPonderPosition, and SG_RESIGN.
Referenced by CmdPlay(), and CmdPlaySequence().
GoPlayer & GoGtpEngine::Player | ( | ) | const |
Throws GtpFailure if no player set.
Definition at line 1422 of file GoGtpEngine.cpp.
References m_player.
Referenced by CmdAllMoveValues(), CmdGenMove(), CmdParamTimecontrol(), CmdPlayerBoard(), and GenMove().
SgPoint GoGtpEngine::PointArg | ( | const GtpCommand & | cmd | ) | const [protected] |
Check that number of arguments is one and get point argument.
Definition at line 1429 of file GoGtpEngine.cpp.
References Board().
Referenced by CmdPointInfo(), CmdSetup(), and PointArg().
SgPoint GoGtpEngine::PointArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1434 of file GoGtpEngine.cpp.
References Board(), and PointArg().
SgVector< SgPoint > GoGtpEngine::PointListArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1439 of file GoGtpEngine.cpp.
References Board().
Referenced by CmdSetFreeHandicap(), and PointListArg().
SgVector< SgPoint > GoGtpEngine::PointListArg | ( | const GtpCommand & | cmd | ) | const [protected] |
Definition at line 1445 of file GoGtpEngine.cpp.
References Board(), and PointListArg().
void GoGtpEngine::RespondNumberArray | ( | GtpCommand & | cmd, | |
const SgPointArray< int > & | array, | |||
int | scale | |||
) | [protected] |
Write integer array response to command.
Elements with the value numeric_limits<int>::min() are considered to have no defined value and are written as "" for compatibility with GoGui.
Definition at line 1450 of file GoGtpEngine.cpp.
References Board().
void GoGtpEngine::RulesChanged | ( | ) | [protected] |
Definition at line 1457 of file GoGtpEngine.cpp.
References m_player, and GoBoardSynchronizer::UpdateSubscriber().
Referenced by CmdGenMoveCleanup(), CmdKomi(), CmdLoadSgf(), CmdParamRules(), PlaceHandicap(), and SetNamedRules().
void GoGtpEngine::SaveGame | ( | const std::string & | fileName | ) | const [private] |
Definition at line 1463 of file GoGtpEngine.cpp.
References m_game, MpiSynchronizer(), GoGame::Root(), and SgException::what().
Referenced by AutoSave(), and CmdSaveSgf().
void GoGtpEngine::SaveStatistics | ( | ) | [private] |
Definition at line 1480 of file GoGtpEngine.cpp.
References m_statisticsFile, m_statisticsSlots, m_statisticsValues, MpiSynchronizer(), and SG_ASSERT.
Referenced by GenMove().
void GoGtpEngine::SetAutoSave | ( | const std::string & | prefix | ) |
Automatically save game after each move.
prefix | Filename prefix; game number and file extension sgf will be added. |
Definition at line 1499 of file GoGtpEngine.cpp.
References CreateAutoSaveFileName(), m_autoSave, and m_autoSavePrefix.
Referenced by CmdParam().
void GoGtpEngine::SetAutoShowBoard | ( | bool | showBoard | ) |
Automatically write board to SgDebug() after changes.
Default is false.
Definition at line 1506 of file GoGtpEngine.cpp.
References Board(), m_autoShowBoard, and SgDebug().
void GoGtpEngine::SetDebugToComment | ( | bool | debugToComment | ) |
Write everything written to SgDebug() during a genmove command to the comment in the new game node.
During a genmove command, SgDebug() will be redirected to a string stream. After the move generation, SgDebug() will be reset to its old value and the string will be written to SgDebug(), as well as added as a comment to the new game node. Default is false.
Definition at line 456 of file GoGtpEngine.h.
References m_debugToComment.
void GoGtpEngine::SetMaxClearBoard | ( | int | n | ) |
Set maximum number of clear_board commands.
-1 means no limit (default). After the limit is reached, the clear_board command will fail. This limit can be used to limit the game loop of the Computer bot interface to the Kiseido Go server http://kgs.kiseido.com.
Definition at line 461 of file GoGtpEngine.h.
References m_maxClearBoard.
void GoGtpEngine::SetMpiSynchronizer | ( | const SgMpiSynchronizerHandle & | m_handle | ) |
Definition at line 1653 of file GoGtpEngine.cpp.
References m_mpiSynchronizer.
void GoGtpEngine::SetNamedRules | ( | const std::string & | namedRules | ) |
Set named rules.
namedRules | Named rules. |
SgException | on unknown rules. |
Definition at line 1534 of file GoGtpEngine.cpp.
References m_defaultRules, m_game, RulesChanged(), GoRules::SetNamedRules(), and GoGame::SetRulesGlobal().
Referenced by CmdRules().
void GoGtpEngine::SetPlayer | ( | GoPlayer * | player | ) |
Set player.
Takes ownership of player.
Definition at line 1519 of file GoGtpEngine.cpp.
References InitStatistics(), m_player, GoPlayer::OnNewGame(), and GoBoardSynchronizer::UpdateSubscriber().
void GoGtpEngine::SetStatisticsFile | ( | const std::string & | fileName | ) |
File to save statistics.
An empty string means that the statistics will not be saved (default behavior).
Definition at line 1513 of file GoGtpEngine.cpp.
References InitStatistics(), and m_statisticsFile.
Referenced by CmdParam().
void GoGtpEngine::SetTimeLimit | ( | double | timeLimit | ) |
void GoGtpEngine::StartStatistics | ( | ) | [private] |
Definition at line 1541 of file GoGtpEngine.cpp.
References m_statisticsSlots, and m_statisticsValues.
Referenced by GenMove().
SgPoint GoGtpEngine::StoneArg | ( | const GtpCommand & | cmd, | |
std::size_t | number | |||
) | const [protected] |
Definition at line 1547 of file GoGtpEngine.cpp.
References Board().
double GoGtpEngine::TimeLimit | ( | ) |
Time limit in seconds for move generation and other commands.
Definition at line 471 of file GoGtpEngine.h.
References m_timeLimit.
void GoGtpEngine::Undo | ( | int | n | ) | [private] |
Definition at line 1552 of file GoGtpEngine.cpp.
References GoGame::CurrentNode(), SgNode::Father(), GoGame::GoToNode(), SgNode::HasFather(), SgNode::HasNodeMove(), m_game, and SG_ASSERT.
Referenced by CmdGGUndo(), and CmdUndo().
void GoGtpEngine::WriteBoardInfo | ( | GtpCommand & | cmd, | |
const GoBoard & | bd | |||
) | [static, private] |
Write board info.
Optional arguments:
Definition at line 1568 of file GoGtpEngine.cpp.
References GoBoard::All(), GoBoard::AllEmpty(), GoBoard::AllPoints(), GtpCommand::Arg(), GoBoard::Centers(), GtpCommand::CheckNuArgLessEqual(), GoBoard::Corners(), GoBoard::CountPlay(), GoBoard::Edges(), GoBoard::GetHashCode(), GoBoard::GetHashCodeInclToPlay(), GoBoard::KoColor(), GoBoard::MoveNumber(), GtpCommand::NuArg(), GoBoard::Occupied(), SG_BLACK, SG_WHITE, SgBW(), SgEBW(), GoBoard::SideExtensions(), GoBoard::ToPlay(), GoBoard::TotalNumEmpty(), and GoBoard::TotalNumStones().
Referenced by CmdBoard(), and CmdPlayerBoard().
bool GoGtpEngine::m_acceptIllegal [private] |
Accept illegal ko or suicide moves in CmdPlay().
Definition at line 333 of file GoGtpEngine.h.
Referenced by CmdParam(), and Play().
boost::scoped_ptr<GoAutoBook> GoGtpEngine::m_autoBook [protected] |
Definition at line 238 of file GoGtpEngine.h.
Referenced by GenBookMove().
bool GoGtpEngine::m_autoSave [private] |
See SetAutoSave().
Definition at line 336 of file GoGtpEngine.h.
Referenced by AutoSave(), CmdParam(), and SetAutoSave().
std::string GoGtpEngine::m_autoSaveFileName [private] |
Definition at line 389 of file GoGtpEngine.h.
Referenced by AutoSave(), CreateAutoSaveFileName(), and GenMove().
std::string GoGtpEngine::m_autoSavePrefix [private] |
Definition at line 391 of file GoGtpEngine.h.
Referenced by CmdParam(), CreateAutoSaveFileName(), and SetAutoSave().
bool GoGtpEngine::m_autoShowBoard [private] |
See SetAutoShowBoard().
Definition at line 339 of file GoGtpEngine.h.
Referenced by BoardChanged(), and SetAutoShowBoard().
GoBook GoGtpEngine::m_book [private] |
Definition at line 385 of file GoGtpEngine.h.
Referenced by Book(), and GenBookMove().
GoBookCommands GoGtpEngine::m_bookCommands [private] |
Definition at line 387 of file GoGtpEngine.h.
Referenced by CmdAnalyzeCommands(), and GoGtpEngine().
bool GoGtpEngine::m_debugToComment [private] |
See SetDebugToComment().
Definition at line 342 of file GoGtpEngine.h.
Referenced by CmdGenMove(), CmdParam(), and SetDebugToComment().
GoRules GoGtpEngine::m_defaultRules [private] |
Default rules.
Will be used whenever a new game is started.
Definition at line 378 of file GoGtpEngine.h.
Referenced by CmdKomi(), CmdLoadSgf(), CmdParamRules(), Init(), and SetNamedRules().
int GoGtpEngine::m_fixedBoardSize [private] |
Definition at line 354 of file GoGtpEngine.h.
Referenced by CmdBoardSize().
GoGame GoGtpEngine::m_game [private] |
Order dependency: destruct m_game before m_board.
Definition at line 381 of file GoGtpEngine.h.
Referenced by ApplyTimeSettings(), Board(), CheckLegal(), CmdClock(), CmdGameOver(), CmdGenMove(), CmdGenMoveCleanup(), CmdKomi(), CmdLoadSgf(), CmdParam(), CmdParamRules(), CmdPlaySequence(), CmdSetInfo(), CmdSetup(), CmdSetupPlayer(), CmdTimeLeft(), Game(), GenMove(), Init(), PlaceHandicap(), Play(), SaveGame(), SetNamedRules(), and Undo().
bool GoGtpEngine::m_isPonderPosition [private] |
Flag set to false if pondering in current position would be a waste of CPU time.
This flag is set to false if the game has not really started yet (current position is an empty board or still in the opening book) or is already finished (two passes, resign or the game result was just set with go_set_info result
).
Definition at line 352 of file GoGtpEngine.h.
Referenced by BoardChanged(), CmdGameOver(), CmdSetInfo(), GenMove(), and Play().
int GoGtpEngine::m_maxClearBoard [private] |
Maximum number of clear_board commands.
-1, if no limit.
Definition at line 359 of file GoGtpEngine.h.
Referenced by CheckMaxClearBoard(), and SetMaxClearBoard().
Definition at line 404 of file GoGtpEngine.h.
Referenced by GenMove(), MpiSynchronizer(), and SetMpiSynchronizer().
bool GoGtpEngine::m_noPlayer [private] |
Definition at line 330 of file GoGtpEngine.h.
Referenced by CmdAnalyzeCommands().
int GoGtpEngine::m_numberClearBoard [private] |
Number of clear_board commands.
Definition at line 363 of file GoGtpEngine.h.
Referenced by CheckMaxClearBoard().
double GoGtpEngine::m_overhead [private] |
Operator overhead time for time settings.
Definition at line 371 of file GoGtpEngine.h.
Referenced by CmdParam().
GoPlayer* GoGtpEngine::m_player [protected] |
Current player.
The player can be exchanged at runtime. It is null, if no player is set. This member is accessible by subclasses of GoGtpEngine to allow them to register external classes, which handle player specific GTP commands. These external classes can be constructed with a reference to this pointer, such that they can access the player they need. They have to check first, that the current player is the expected one.
Definition at line 236 of file GoGtpEngine.h.
Referenced by BoardChanged(), CmdClearBoard(), CmdLoadSgf(), CmdName(), CmdPlaceFreeHandicap(), DumpState(), GameFinished(), Player(), RulesChanged(), SetPlayer(), and ~GoGtpEngine().
boost::filesystem::path GoGtpEngine::m_sentinelFile [private] |
See CmdSentinelFile().
Definition at line 394 of file GoGtpEngine.h.
Referenced by CmdClearBoard(), and CmdSentinelFile().
SgGtpCommands GoGtpEngine::m_sgCommands [private] |
Definition at line 383 of file GoGtpEngine.h.
Referenced by CmdAnalyzeCommands(), and GoGtpEngine().
std::string GoGtpEngine::m_statisticsFile [private] |
Definition at line 396 of file GoGtpEngine.h.
Referenced by CmdParam(), InitStatistics(), SaveStatistics(), and SetStatisticsFile().
std::vector<std::string> GoGtpEngine::m_statisticsSlots [private] |
Definition at line 399 of file GoGtpEngine.h.
Referenced by AddStatistics(), InitStatistics(), SaveStatistics(), and StartStatistics().
std::vector<std::string> GoGtpEngine::m_statisticsValues [private] |
Definition at line 402 of file GoGtpEngine.h.
Referenced by AddStatistics(), SaveStatistics(), and StartStatistics().
double GoGtpEngine::m_timeLastMove [private] |
Definition at line 365 of file GoGtpEngine.h.
Referenced by CmdTimeLastMove(), and GenMove().
double GoGtpEngine::m_timeLimit [private] |
See GoGtpEngine::CmdTimeLimit.
Definition at line 368 of file GoGtpEngine.h.
Referenced by CmdParam(), GenMove(), SetTimeLimit(), and TimeLimit().
GoTimeSettings GoGtpEngine::m_timeSettings [private] |
Time settings for game.
Definition at line 374 of file GoGtpEngine.h.
Referenced by ApplyTimeSettings(), CmdKgsTimeSettings(), CmdTimeSettings(), and GenMove().
bool GoGtpEngine::m_useBook [private] |
Definition at line 344 of file GoGtpEngine.h.
Referenced by CmdParam(), and GenBookMove().