Previous: Incremental Board, Up: Libboard


15.4 Some Board Functions

Reading, often called search in computer game theory, is a fundamental process in GNU Go. This is the process of generating hypothetical future boards in order to determine the answer to some question, for example "can these stones live." Since these are hypothetical future positions, it is important to be able to undo them, ultimately returning to the present board. Thus a move stack is maintained during reading. When a move is tried, by the function trymove, or its variant tryko. This function pushes the current board on the stack and plays a move. The stack pointer stackp, which keeps track of the position, is incremented. The function popgo() pops the move stack, decrementing stackp and undoing the last move made.

Every successful trymove() must be matched with a popgo(). Thus the correct way of using this function is:

     
       if (trymove(pos, color, ... )) {
            ...    [potentially lots of code here]
            popgo();
       }

In case the move is a ko capture, the legality of the capture is subject to the komaster scheme (see Ko).

As you see, trymove() plays a move which can be easily retracted (with popgo()) and it is call thousands of times per actual game move as GNU Go analyzes the board position. By contrast the function play_move() plays a move which is intended to be permanent, though it is still possible to undo it if, for example, the opponent retracts a move.

Other board functions are documented in See Board Utilities.