[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to create a Player OpenGo



How to Create a Player in OpenGo

A simple random player is already implemented as the class PlayRand in the file
playrand.cpp.  PlayRand is a PlayerProxy.

To create an opponent, subclass PlayerProxy.  When it is constructed it is
supplied with:
    * means to communicate with the user = Class IOBase
    * pointer to the Referee so that it can play the game
    * which color you're playing
    * other information.
It uses this to initialize the base class, PlayerProxy.
At this point, the random player is ready to play, so it tells the Referee by
calling:
     Post_SetupRsp( TRUE );    // I'm ready to play

When it is your turn to move, this function will be called:
    ErrId PlayRand::cbGetMove( Move &OppMv, const DataBoard *pBd )
It tells you what the opponents move is and what the board looks like.  You then

decide on your response:
   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(olumn
and send it back to the referee with:
   Post_MoveRsp( PlayRandMv );  // post results back...

You could also display something:
  _pIO->Info( "My killer move\n");


The way it works is:
    * The Referee sits in the middle between the players.
    * Each player submits a move to Referee.
    * If the Referee thinks the move is legal, then it updates it's board and
passes the
        move onto the opposing player.
    * If the move is illegal, the move is rejected and the player's cbGetMove
function again.
The Referee will reject the move if it:
    * isn't the players turn
    * violate the rules:
        - violates ko
        - off the board
        - etc.

Since the Referee only allows proper moves, the random player can keep
generating moves until it gets it right.  It also keeps a count of how many
attempts it has tried, and after a while will pass.

jeffrey

Gen wrote:

>  Hi all !I got the OpenGo code a week ago, and I've tried a bit to find which
> functions were essential - but my skills at C++ are somewhat limited, and I
> haven't made it to grasp every aspect of the code  :)Could someone tell me
> what functions are required in order to implement a random computer player,
> respecting the rules (...) ?If anyone wants to know, my compiler is Metrowerks
> CodeWarrior. Thanks in advance ! Gen



--
Jeffrey Greenberg
Mgr. Aegis Adv. Dev.
Acuson Corp.
www.ultrasound.com
www.acuson.com
650-694-5422