| www.delorie.com/gnu/docs/gnugo/gnugo_89.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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();
}
|
Here the komaster is only set if a conditional ko capture has been made
at an earlier move. This feature of the tactical and owl reading code in GNU
Go is used to prevent redundant reading when there is a ko on the board
(see section 14.3 Ko Handling).
void play_move(int pos, int color)
Play a move at(pos). If you want to test for legality you should first callis_legal(). This function strictly follows the algorithm:
- Place a stone of given color on the board.
- If there are any adjacent opponent strings without liberties, remove them and increase the prisoner count.
- If the newly placed stone is part of a string without liberties, remove it and increase the prisoner count.
int trymove(int pos, int color, const char *message, int str, int komaster, int kom_pos)
Returns true if(pos)is a legal move forcolor. In that case, it pushes the board on the stack and makes the move, incrementingstackp. If the reading code is recording reading variations (as with `--decide-string' or with `-o'), the string*messagewill be inserted in the SGF file as a comment. The comment will also refer to the string atstrif this is not0. The komaster and ko position variables are described elsewhere (see section 14.3 Ko Handling)
int TRY_MOVE()
Wrapper around trymove which suppresses*messageand(k,l). Used in `helpers.c'
int tryko(int pos, int color, const char *message, int komaster, int kom_pos)
tryko()pushes the position onto the stack, and makes a moveposofcolor. The move is allowed even if it is an illegal ko capture. It is to be imagined thatcolorhas made an intervening ko threat which was answered and now the continuation is to be explored. Return 1 if the move is legal with the above caveat. Returns zero if it is not legal because of suicide.
void popgo()
Pops the move stack. This function must (eventually) be called after a succesfultrymoveortrykoto restore the board position. It undoes all the changes done by the call totrymove/trykoand leaves the board in the same state as it was before the call.NOTE: If
trymove/trykoreturns0, i.e. the tried move was not legal, you must not callpopgo.
int komaster_trymove(int pos, int color, const char *message, int str, int komaster, int kom_pos, int *new_komaster, int *new_kom_pos, int *is_conditional_ko, int consider_conditional_ko)
Variation oftrymove/trykowhere ko captures (both conditional and unconditional) must follow a komaster scheme (see section 14.3 Ko Handling).
int move_in_stack(int pos, int cutoff)
Returns true if at least one move been played at (pos)
at deeper than level 'cutoff' in the reading tree.
void void get_move_from_stack(int k, int *move, int *color)
Retrieve the move numberkfrom the move stack. The move location is returned in(*move), and the color that made the move is returned in*color.
void dump_stack(void)
Handy for debugging the reading code under GDB. Prints the move stack.
Usage: (gdb) set dump_stack().
void reset_trymove_counter()
Reset the trymove counter. This counter is incremented every time that a variant oftrymoveortrykois called.
int get_trymove_counter()
Retrieve the trymove counter.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |