A simple random player is already implemented as the class PlayRand in the file playrand.cpp. PlayRand is derived from the class PlayerProxy. Look at this example which is described below. You can also look at pwally.c which is the OpenGo interface to the wally program.
To create a player: subclass PlayerProxy.
To construct a player, it must be supplied with:
At this point, the player is ready to play, so it tells the Referee
by
calling:
To make a move:Post_SetupRsp( TRUE ); // Post a setup response message to the referee: I'm ready to play!
It tells you what the opponents move is and what the board looks like. Class Move will tell you if it was a move, pass or resignation, by whom, and where. The DataBoard will tell you what the board now looks like. It also lets you enquire about blocks or strings, the history of moves, ko information and more.ErrId PlayRand::cbGetMove( Move &OppMv, const DataBoard *pBd )
Once the move is in your hands, you call you Go Engine code and obtain your response move. You create a move to send back to the Referee using the following api:
Move PlayRandMv;
PlayRandMv.Set( MT_Resign, _id, 0, 0); // to resign
PlayRandMv.Set( MT_Pass, _id, 0, 0); // to pass
PlayRandMv.Set( MT_Move, _id, r, c); // to move to r(ow, c(olumnAnd send it back to the referee with:
You could also display something:Post_MoveRsp( PlayRandMv ); // post results back...
Which will be displayed in the status box._pIO->Info( "My move is a killer.");
The way it works is:
The Referee sits in the middle between the players.