Ticket #148: doc.diff

File doc.diff, 40.2 KB (added by draqo, 5 years ago)
  • gnugo/doc/board.texi

    RCS file: /sources/gnugo/gnugo/doc/board.texi,v
    retrieving revision 1.15
    diff -u -r1.15 board.texi
     
    7171@group 
    7272 
    7373int           board_size; 
    74 Intersection  board[MAXSIZE]; 
     74Intersection  board[BOARDSIZE]; 
    7575int           board_ko_pos; 
    7676 
    7777float         komi; 
    7878int           white_captured; 
    7979int           black_captured; 
    8080 
    81 Hash_data     hashdata; 
     81Hash_data     board_hash; 
    8282@end group 
    8383@end example 
    8484 
    85 The description of the @code{Position} struct is applicable to these 
     85The description of the @code{board_state} struct is applicable to these 
    8686variables also, so we won't duplicate it here.  All these variables are 
    8787globals for performance reasons.  Behind these variables, there are a 
    8888number of other private data structures.  These implement incremental 
    8989handling of strings, liberties and other properties  
    90 (@pxref{Incremental Board}). The variable @code{hashdata} contains information 
     90(@pxref{Incremental Board}). The variable @code{board_hash} contains information 
    9191about the hash value for the current position (@pxref{Hashing}). 
    9292 
    9393These variables should never be manipulated directly, since they are 
     
    181181#define NS           (MAX_BOARD + 1) 
    182182#define WE           1 
    183183#define SOUTH(pos)   ((pos) + NS) 
    184 #define WEST(pos)    ((pos) - 1) 
     184#define WEST(pos)    ((pos) - WE) 
    185185#define NORTH(pos)   ((pos) - NS) 
    186 #define EAST(pos)    ((pos) + 1) 
     186#define EAST(pos)    ((pos) + WE) 
    187187@end example 
    188188 
    189189There are also shorthand macros @code{SW}, @code{NW}, @code{NE}, 
     
    209209often one computation is sufficient for 1D-coordinate where we would need 
    210210two with two 2D-coordinates: If we, for example, want to have the 
    211211coordinate of the upper right of @code{pos}, we can do this with 
    212 @code{NORTH(EAST(pos))} instead of @code{(i+1, j-1)}. 
     212@code{NE(pos)} instead of @code{(i+1, j-1)}. 
    213213 
    214214@strong{Important}: The 2D coordinate @code{(-1,-1)}, which is used for 
    215215pass and sometimes to indicate no point, maps to the 1D coordinate 
     
    240240a point on the board.  
    241241 
    242242Often one wants to traverse the board, carrying out some function 
    243 at every vertex. Here are two possible ways of doing this: 
    244  
    245 @example 
    246   int m, n; 
    247   for (m = 0; m < board_size; m++) 
    248     for (n = 0; n < board_size; n++) @{ 
    249       do_something(POS(m, n)); 
    250     @} 
    251 @end example 
    252  
    253 Or: 
     243at every vertex. Here are the best way of doing this (other 
     244implemantations were tested and are slower on 19x19 board): 
    254245 
    255246@example 
    256247  int pos; 
     
    273264@item Number of stones in the string. 
    274265@item Origin of the string, i.e. a canonical reference point, defined 
    275266to be the stone with smallest 1D board coordinate. 
    276 @item A list of the stones in the string. 
     267@item A list of the stones in the string (linked in a cycle). 
    277268@item Number of liberties. 
    278269@item A list of the liberties. If there are too many liberties the list is 
    279270truncated. 
     
    281272@item A list of the neighbor strings. 
    282273@end itemize 
    283274 
    284 The basic data structure is 
     275The basic data structures are 
    285276 
    286277@example 
    287278struct string_data @{ 
     
    290281  int origin;                      /* Coordinates of "origin", i.e. */ 
    291282                                   /* "upper left" stone. */ 
    292283  int liberties;                   /* Number of liberties. */ 
    293   int libs[MAX_LIBERTIES];         /* Coordinates of liberties. */ 
    294284  int neighbors;                   /* Number of neighbor strings */ 
    295   int neighborlist[MAXCHAIN];      /* List of neighbor string numbers. */ 
    296285  int mark;                        /* General purpose mark. */ 
    297286@}; 
    298287 
    299 struct string_data string[MAX_STRINGS]; 
     288struct string_liberties_data @{ 
     289  int list[MAX_LIBERTIES];         /* Coordinates of liberties. */ 
     290@}; 
     291 
     292struct string_neighbors_data @{ 
     293  int list[MAXCHAIN];              /* List of neighbor string numbers. */ 
     294@}; 
     295 
     296static struct string_data string[MAX_STRINGS]; 
     297static struct string_liberties_data string_libs[MAX_STRINGS]; 
     298static struct string_neighbors_data string_neighbors[MAX_STRINGS]; 
    300299@end example 
    301300 
    302 It should be clear that almost all information is stored in the 
    303 @code{string} array. To get a mapping from the board coordinates to the 
    304 @code{string} array we have 
     301It should be clear that almost all information is stored in these 
     302arrays. They are splitted because of caching purposes - if one doesn't 
     303need libs or neighbors, accessing string_data is faster, because @code{list} 
     304arrays are quite big. 
     305 
     306To get a mapping from the board coordinates to these arrays we have 
    305307 
    306308@example 
    307309static int string_number[BOARDMAX]; 
    308310@end example 
    309311 
    310312@noindent 
    311 which contains indices into the @code{string} array. This information is only 
     313which contains indices into these arrays. This information is only 
    312314valid at nonempty vertices, however, so it is necessary to first 
    313315verify that @code{board[pos] != EMPTY}. 
    314316 
    315 The @code{string_data} structure does not include an array of the stone 
    316 coordinates. This information is stored in a separate array: 
     317A string stones coordinates are stored in a separate array: 
    317318 
    318319@example 
    319320static int next_stone[BOARDMAX]; 
     
    335336static int liberty_mark; 
    336337static int string_mark; 
    337338static int next_string; 
    338 static int strings_initialized = 0; 
    339339@end example 
    340340 
    341341The @code{ml} array and @code{liberty_mark} are used to "mark" liberties on 
     
    349349individual strings. 
    350350 
    351351@code{next_string} gives the number of the next available entry in the 
    352 @code{string} array. Then @code{strings_initialized} is set to one when 
    353 all data structures are known to be up to date. Given an arbitrary board 
    354 position in the @samp{board} array, this is done by calling 
    355 @code{incremental_board_init()}. It is not necessary to call this 
    356 function explicitly since any other function that needs the information 
    357 does this if it has not been done. 
     352@code{string} array. 
     353 
     354To initialize all the structures of the incremental board one need to 
     355call @code{new_position} function, which builds all information based 
     356on the actual state of the board (in @code{board} variable). 
    358357 
    359358The interesting part of the code is the incremental update of the data 
    360359structures when a stone is played and subsequently removed. To 
    361360understand the strategies involved in adding a stone it is necessary 
    362361to first know how undoing a move works. The idea is that as soon as 
    363 some piece of information is about to be changed, the old value is 
    364 pushed onto a stack which stores the value and its address. The stack 
    365 is built from the following structures: 
     362some piece of information is about to be changed, the old value (or 
     363an intersection state) is pushed onto a stack which stores the value 
     364and its address. The stack is built from the following structures (we 
     365have two stacks really, because Intersection can have different type 
     366than int): 
    366367 
    367368@example 
    368369struct change_stack_entry @{ 
     
    370371  int value; 
    371372@}; 
    372373 
    373 struct change_stack_entry change_stack[STACK_SIZE]; 
    374 int change_stack_index; 
     374struct vertex_stack_entry @{ 
     375  Intersection *address; 
     376  int value; 
     377@}; 
     378 
     379static struct change_stack_entry change_stack[STACK_SIZE]; 
     380static struct change_stack_entry *change_stack_pointer; 
     381 
     382static struct vertex_stack_entry vertex_stack[STACK_SIZE]; 
     383static struct vertex_stack_entry *vertex_stack_pointer; 
    375384@end example 
    376385 
    377386@noindent 
    378387and manipulated with the macros 
    379388 
    380389@example 
     390CLEAR_STACKS() 
    381391BEGIN_CHANGE_RECORD() 
    382392PUSH_VALUE(v) 
     393PUSH_VERTEX(v) 
    383394POP_MOVE() 
    384395@end example 
    385396 
    386397Calling @code{BEGIN_CHANGE_RECORD()} stores a null pointer in the address 
    387398field to indicate the start of changes for a new move. As mentioned 
    388 earlier @code{PUSH_VALUE()} stores a value and its corresponding address. 
     399earlier @code{PUSH_VALUE()} and @code{PUSH_VERTEX()} stores a value and its 
     400corresponding address. 
    389401Assuming that all changed information has been duly pushed onto the 
    390402stack, undoing the move is only a matter of calling @code{POP_MOVE()}, 
    391403which simply assigns the values to the addresses in the reverse order 
    392 until the null pointer is reached. This description is slightly 
    393 simplified because this stack can only store 'int' values and we need 
    394 to also store changes to the board. Thus we have two parallel stacks 
    395 where one stores @code{int} values and the other one stores 
    396 @code{Intersection} values. 
     404until the null pointer is reached. 
    397405 
    398406When a new stone is played on the board, first captured opponent 
    399407strings, if any, are removed. In this step we have to push the board 
     
    438446The often used construction 
    439447 
    440448@example 
    441     pos = FIRST_STONE(s); 
     449    first_stone = FIRST_STONE(s); 
     450    pos = first_stone; 
    442451    do @{ 
    443452        ... 
    444453        pos = NEXT_STONE(pos); 
    445     @} while (!BACK_TO_FIRST_STONE(s, pos)); 
     454    @} while (pos != first_stone); 
    446455@end example 
    447456 
    448457@noindent 
    449458traverses the stones of the string with number @samp{s} exactly once, 
    450459with @code{pos} holding the coordinates. In general @code{pos} is 
    451460used as board coordinate and @samp{s} as an index into the 
    452 @code{string} array or sometimes a pointer to an entry in the 
    453 @code{string} array. 
     461@code{string}, @code{string_libs} or @code{string_neighbors} array. 
    454462 
    455463@node Some Board Functions 
    456464@section Some Board Functions 
     
    489497the komaster scheme (@pxref{Ko}). 
    490498 
    491499@itemize @bullet 
    492 @item @code{int trymove(int pos, int color, const char *message)} 
     500@item @code{int trymove(int pos, int color, const char *message, int str)} 
    493501@findex trymove 
    494502@quotation 
    495503Returns true if @code{(pos)} is a legal move for @code{color}. In that 
     
    498506with @option{--decide-string} or with @option{-o}), the string 
    499507@code{*message} will be inserted in the SGF file as a comment. The 
    500508comment will also refer to the string at @code{str} if this is not 
    501 @code{0}. The value of @code{str} can be NO_MOVE if it is not needed but 
    502 otherwise the location of @code{str} is included in the comment. 
     509@code{NO_MOVE}. The value of @code{str} can be @code{NO_MOVE} if it is 
     510not needed but otherwise the location of @code{str} is included in the 
     511comment. @strong{NOTE}: including str in comment isn't implemented for 
     512now 
    503513@end quotation 
    504514@item @code{int tryko(int pos, int color, const char *message)} 
    505515@findex tryko 
  • gnugo/doc/install.texi

    RCS file: /sources/gnugo/gnugo/doc/install.texi,v
    retrieving revision 1.25
    diff -u -r1.25 install.texi
     
    130130@node Default Level 
    131131@subsection Default Level 
    132132 
    133 GNU Go can play at different levels. Up to level 10 is 
    134 supported. At level 10 GNU Go is much more accurate but takes 
    135 an average of about 1.6 times longer to play than at level 8. 
     133GNU Go can play at different levels. Level may be as high as you wish 
     134but it will make GNU Go play slower (up to level 12 is recommended). At 
     135level 10 GNU Go is much more accurate but takes an average of about 1.6 
     136times longer to play than at level 8. 
    136137 
    137138The level can be set at run time using the @option{--level} option. 
    138139If you don't set this, the default level will be used. You 
     
    146147@noindent 
    147148sets the default level to 9. If you omit this parameter, 
    148149the compiler sets the default level to 10. We recommend 
    149 using level 10 unless you find it too slow. If you decide 
     150using level 12 unless you find it too slow. If you decide 
    150151you want to change the default you may rerun configure 
    151152and recompile the program. 
    152153 
     
    235236This is on by default. 
    236237@end itemize 
    237238 
     239There is one more option, which allows disabling of all unneeded 
     240things in code - like stats, asserts, etc. It should be used only 
     241to generate final release of the program and can be changed only 
     242as configure option. 
     243 
     244@itemize @bullet 
     245@item @code{final-release} Disable unneeded things. 
     246@end itemize 
     247 
    238248@node Windows and MS-DOS, Macintosh, Configure Options, Installation 
    239249@section Compiling GNU Go on Microsoft platforms 
    240250 
  • gnugo/doc/reading.texi

    RCS file: /sources/gnugo/gnugo/doc/reading.texi,v
    retrieving revision 1.20
    diff -u -r1.20 reading.texi
     
    225225option @pxref{Invoking GNU Go}. 
    226226 
    227227The hash table is created once and for all at the beginning of 
    228 the game by the function @code{hashtable_new()}. Although hash 
     228the game by the function @code{reading_cache_init()}. Although hash 
    229229memory is thus allocated only once in the game, the table is 
    230230reinitialized at the beginning of each move by a call to 
    231 @code{hashtable_clear()} from @code{genmove()}. 
     231@code{reading_cache_clear()} from @code{genmove()}. 
    232232 
    233233@menu 
    234234* Hash Calculation::            Calculation of the hash value 
    235235* Hash Organization::           Organization of the hash table 
    236 * Hash Structures::             Structures in @file{hash.h} 
    237236@end menu 
    238237 
    239238@node Hash Calculation 
     
    249248@enumerate 
    250249@item First we define a @dfn{go position}.  This positions consists of 
    251250@itemize @bullet 
    252 @item the actual board, i.e. the locations and colors of the stones 
    253 @item A @dfn{ko point}, if a ko is going on.  The ko point is defined as 
     251@item the actual board, i.e. the locations and colors of the stones; 
     252@item a @dfn{ko point}, if a ko is going on; the ko point is defined as 
    254253the empty point where the last single stone was situated before 
    255254it was captured. 
    256255@end itemize 
    257256 
     257In addition to that we include some more information into the hash code, 
     258that describes stored analisys results: 
     259@itemize @bullet 
     260@item a @dfn{komaster} and @dfn{kom_pos}, @xref{Ko}, 
     261@item an ID (an int between 0 and 255) of a function used to calculate 
     262the results; 
     263@item a target of analisys (up to two positions on a board); 
     264@item sometimes some extra information used by various functions. 
     265@end itemize 
     266 
    258267It is not necessary to specify the color to move (white or black) 
    259268as part of the position. The reason for this is that read results 
    260269are stored separately for the various reading functions such as 
    261270@code{attack3}, and it is implicit in the calling function which 
    262271player is to move. 
    263272 
    264 @item For each location on the board we generate random numbers: 
    265 @itemize @bullet 
    266 @item A number which is used if there is a white stone on this location 
    267 @item A number which is used if there is a black stone on this location 
    268 @item A number which is used if there is a ko on this location 
    269 @end itemize 
    270  
     273@item For each of the above information (excluding extra information) 
     274we generate tables with random numbers for each: function, komaster 
     275status or position on a board. 
    271276These random numbers are generated once at initialization time and 
    272277then used throughout the life time of the hash table. 
    273278 
    274279@item The hash key for a position is the XOR of all the random numbers 
    275 which are applicable for the position (white stones, black stones, and 
    276 ko position). 
     280which are applicable for the position. If extra information is needed 
     281it is passed by a function as a hash code which is XORed into the 
     282resulting hash key. 
    277283@end enumerate 
    278284 
    279285@node Hash Organization 
    280286@subsection Organization of the hash table 
    281287 
    282 The hash table consists of 3 parts: 
    283  
    284 @cindex Hash node 
    285 @cindex Read result 
    286  
    287 @itemize @bullet 
    288 @item An area which contains so called @dfn{Hash Nodes}. Each hash node 
    289 contains: 
    290 @itemize @minus 
    291 @item A go position as defined above. 
    292 @item A computed hash value for the position 
    293 @item A pointer to Read Results (see below) 
    294 @item A pointer to another hash node. 
    295 @end itemize 
    296  
    297 @item An area with so called Read Results.  These are used to store 
    298 which function was called in the go position, which string was 
    299 under attack or to be defended, and the result of the reading. 
    300  
    301 Each Read Result contains:  
    302 @itemize @minus 
    303 @item the function ID (an int between 0 and 255), the position of the 
    304 string under attack and a depth value, which is used to 
    305 determine how deep the search was when it was made, packed into 
    306 one 32 bit integer.  
    307 @item The result of the search (a numeric value) and a position to 
    308 play to get the result packed into one 32 bit integer.  
    309 @item A pointer to another Read Result. 
    310 @end itemize 
    311  
    312 @item An array of pointers to hash nodes.  This is the hash table 
    313 proper. 
    314  
    315 @end itemize 
    316  
    317 When the hash table is created, these 3 areas are allocated using 
    318 @code{malloc()}.  When the hash table is populated, all contents are taken 
    319 from the Hash nodes and the Read results. No further allocation is 
    320 done and when all nodes or results are used, the hash table is full. 
    321 Nothing is deleted from the hash table except when it is totally 
    322 emptied, at which point it can be used again as if newly initialized. 
    323  
    324 @findex hashtable_search 
    325 When a function wants to use the hash table, it looks up the current 
    326 position using @code{hashtable_search()}. If the position doesn't already 
    327 exist there, it can be entered using 
    328  
    329 @findex hashtable_enter_position 
    330 @code{hashtable_enter_position()}.   
    331  
    332 @findex hashtable_enter_position 
    333 Once the function has a pointer to the hash node containing a 
    334 function, it can search for a result of a previous search using 
    335 @code{hashnode_search()}.  If a result is found, it can be used, and 
    336 if not, a new result can be entered after a search using  
    337 @findex hashnode_new_result 
    338 @code{hashnode_new_result()}. 
    339  
    340 Hash nodes which hash to the same position in the hash table 
    341 (collisions) form a simple linked list.  Read results for the same 
    342 position, created by different functions and different attacked or 
    343 defended strings also form a linked list. 
    344  
    345 This is deemed sufficiently efficient for now, but the representation 
    346 of collisions could be changed in the future.  It is also not 
    347 determined what the optimum sizes for the hash table, the number of 
    348 positions and the number of results are. 
    349  
    350 @node Hash Structures 
    351 @subsection Hash Structures 
    352  
    353288The basic hash structures are declared in @file{engine/hash.h} and 
    354 @file{engine/cache.c} 
     289@file{engine/cache.h} 
    355290 
    356 @example 
    357 typedef struct hashposition_t @{ 
    358   Compacttype  board[COMPACT_BOARD_SIZE]; 
    359   int          ko_pos; 
    360 @} Hashposition; 
    361 @end example 
    362  
    363 Represents the board and optionally the location of a ko, 
    364 which is an illegal move. The player whose move is next 
    365 is not recorded. 
     291The hash table consists of an array of pointers to hash entries and 
     292variable that defines number of the entries. 
    366293 
    367294@example 
    368295typedef struct @{ 
    369   Hashvalue     hashval; 
    370   Hashposition  hashpos; 
    371 @} Hash_data; 
    372 @end example 
     296  unsigned int num_entries; 
     297  Hashentry *entries; 
     298@} Transposition_table; 
    373299 
    374 Represents the return value of a function (@code{hashval}) and 
    375 the board state (@code{hashpos}). 
    376  
    377 @example 
    378 typedef struct read_result_t @{ 
    379   unsigned int data1;    
    380   unsigned int data2; 
    381  
    382   struct read_result_t *next; 
    383 @} Read_result; 
     300Transposition_table ttable; 
    384301@end example 
    385302 
    386 The data1 field packs into 32 bits the following fields: 
    387  
    388 @example 
     303@cindex Hash entry 
    389304 
    390 komaster:  2 bits (EMPTY, BLACK, WHITE, or GRAY) 
    391 kom_pos : 10 bits (allows MAX_BOARD up to 31) 
    392 routine :  4 bits (currently 10 different choices) 
    393 str1    : 10 bits 
    394 stackp  :  5 bits 
    395  
    396 @end example 
    397  
    398 The data2 field packs into 32 bits the following fields: 
     305The @dfn{Hash Entry} consists of two @dfn{Hash Nodes}. One is the 
     306most reliable node and the second is the newest. The reliability is 
     307computed based on cost of the function, which created a node and 
     308depth of analysis for that node (the lower depth the more reliable 
     309results). 
    399310 
    400311@example 
    401  
    402 status :   2 bits (0 free, 1 open, 2 closed) 
    403 result1:   4 bits 
    404 result2:   4 bits 
    405 move   :  10 bits 
    406 str2   :  10 bits 
    407  
     312typedef struct @{ 
     313  Hashnode most_reliable; 
     314  Hashnode newest; 
     315@} Hashentry; 
    408316@end example 
    409317 
    410 The @code{komaster} and @code{(kom_pos)} field are 
    411 documented in @xref{Ko}. 
     318@cindex Hash node 
    412319 
    413 When a new result node is created, 'status' is set to 1 'open'. 
    414 This is then set to 2 'closed' when the result is entered. The main 
    415 use for this is to identify open result nodes when the hashtable is 
    416 partially cleared. Another potential use for this field is to 
    417 identify repeated positions in the reading, in particular local 
    418 double or triple kos. 
     320Each hash node contains a computed hash value (as defined above) 
     321and @dfn{Read Results}. 
    419322 
    420323@example 
    421 typedef struct hashnode_t @{ 
    422   Hash_data            key; 
    423   Read_result        * results; 
    424   struct hashnode_t  * next; 
     324typedef struct @{ 
     325  Hash_data key; 
     326  HASHNODE_DATATYPE data; /* 32-bit value */ 
    425327@} Hashnode; 
    426328@end example 
    427329 
    428 The hash table consists of hash nodes.  Each hash node consists of 
    429 The hash value for the position it holds, the position itself and 
    430 the actual information which is purpose of the table from the start. 
     330@cindex Read result 
    431331 
    432 There is also a pointer to another hash node which is used when 
    433 the nodes are sorted into hash buckets (see below). 
     332Read Results are used to store which function was called in the go 
     333position, which string was under attack or to be defended, and the 
     334result of the reading. The result is packed into one 32 bit integer. 
     335Each Read Result contains:  
     336@itemize @minus 
     337@item a remaining (to the max depth) depth value, which is used to 
     338determine how deep the search was when node was stored (5 bits);  
     339@item the results of the search (two numeric values - 2 x 4 bits); 
     340@item a cost of a function which stored the result (an arbitrary 
     341numeric value) (4 bits); 
     342@item a move to play to get the result (10 bits). 
     343@end itemize 
    434344 
    435345@example 
    436 typedef struct hashtable @{ 
    437   size_t         hashtablesize; /* Number of hash buckets */ 
    438   Hashnode    ** hashtable;     /* Pointer to array of hashnode lists */ 
     346#define hn_create_data(remaining_depth, value1, value2, move, cost) \ 
     347    ((((value1)         & 0x0f)  << 23) \ 
     348   | (((value2)         & 0x0f)  << 19) \ 
     349   | (((move)           & 0x3ff) <<  9) \ 
     350   | (((cost)           & 0x0f)  <<  5) \ 
     351   | (((remaining_depth & 0x1f)/*<<  0*/))) 
     352@end example 
    439353 
    440   int            num_nodes;     /* Total number of hash nodes */ 
    441   Hashnode     * all_nodes;     /* Pointer to all allocated hash nodes. */ 
    442   int            free_node;     /* Index to next free node. */ 
     354When the hash table is created, the hash entries are allocated using 
     355@code{malloc()}. After that, no further allocation is 
     356done and when all nodes or results are used, the hash table is full. 
     357Nothing is deleted, instead nodes are replaced by newer or more 
     358reliable nodes (when collision occurs). 
    443359 
    444   int            num_results;   /* Total number of results */ 
    445   Read_result  * all_results;   /* Pointer to all allocated results. */ 
    446   int            free_result;   /* Index to next free result. */ 
    447 @} Hashtable; 
    448 @end example 
     360@findex tt_get 
     361When a function wants to use the hash table, it looks up the current 
     362position using @code{tt_get()}. If the position doesn't already 
     363exist there, it can be entered using 
    449364 
    450 The hash table consists of three parts: 
     365@findex tt_update 
     366@code{tt_update()}.   
    451367 
    452 @itemize @bullet 
    453 @item The hash table proper: a number of hash buckets with collisions 
    454 being handled by a linked list. 
    455 @item The hash nodes.  These are allocated at creation time and are  
    456 never removed or reallocated in the current implementation. 
    457 @item The results of the searches.  Since many different searches can 
    458 be done in the same position, there should be more of these than 
    459 hash nodes. 
    460 @end itemize 
     368@findex tt_update 
     369There are several macros which store the result and return it from 
     370a searching functions. They are named @code{READ_RETURN0}, 
     371@code{READ_RETURN}, @code{READ_RETURN_SEMEAI}, @code{READ_RETURN_CONN}, 
     372@code{READ_RETURN_HASH} and @code{READ_RETURN2} and can be found in 
     373@file{engine/cache.h}. 
    461374 
    462375@node Persistent Cache 
    463376@section Persistent Reading Cache 
     
    610523 
    611524The rationale behind this rule is that in the case where there are 
    612525two kos on the board, the komaster cannot win both, and by becoming 
    613 komaster he has already chosen which ko he wants to win. But in the 
    614 case of a nested ko, taking one ko is a precondition to taking the 
    615 other one, so we allow this. 
     526komaster he has already chosen which ko he wants to win (the same reasoning 
     527applies to WEAK_KO rule). But in the case of a nested ko, taking one ko is 
     528a precondition to taking the other one, so we allow this. 
    616529 
    617530If the komaster's opponent takes a ko, then both players have taken one ko. In 
    618531this case @code{komaster} is set to @code{GRAY_BLACK} or @code{GRAY_WHITE} and 
     
    628541@itemize @bullet 
    629542@item 1. Komaster is EMPTY. 
    630543@itemize @minus 
    631 @item 1a. Unconditional ko capture is allowed. 
     544@item 1a) Unconditional ko capture is allowed. 
    632545@quotation 
    633546Komaster remains EMPTY if previous move was not a ko capture. 
    634547Komaster is set to WEAK_KO if previous move was a ko capture 
     
    642555@end itemize 
    643556@item 2. Komaster is O: 
    644557@itemize @minus 
    645 @item 2a) Only nested ko captures are allowed. Kom_pos is moved to the 
    646 new removed stone. 
    647 @item 2b) If komaster fills the ko at kom_pos then komaster reverts to 
    648 EMPTY. 
     558@item 2a) Only nested ko captures are allowed. 
     559@quotation 
     560Kom_pos is moved to the new removed stone. 
     561@end quotation 
     562@item 2b) If the ko has been resolved in favor of the komaster (when the ko 
     563is filled or kom_pos is no longer a ko because of some capture) then the 
     564komaster reverts to EMPTY. 
    649565@end itemize 
    650566@item 3. Komaster is X: 
     567@itemize @minus 
     568@item 
     569Play at kom_pos is not allowed if it is the ko recapture. Any other ko capture 
     570is allowed. 
    651571@quotation 
    652 Play at kom_pos is not allowed. Any other ko capture 
    653 is allowed. If O takes another ko, komaster becomes GRAY_X. 
     572If O takes another ko, komaster becomes GRAY_X. 
    654573@end quotation 
     574@end itemize 
    655575@item  4. Komaster is GRAY_O or GRAY_X: 
    656 @quotation 
    657 Ko captures are not allowed. If the ko at kom_pos is 
    658 filled then the komaster reverts to EMPTY. 
    659 @end quotation 
     576@itemize @minus 
     577@item 
     578Ko captures are not allowed. If the ko has been resolved in favor of 
     579the komaster (when the ko is filled or kom_pos is no longer a ko because 
     580of some capture) then the komaster reverts to EMPTY. 
     581@end itemize 
    660582@item 5. Komaster is WEAK_KO: 
    661583@itemize @minus 
    662584@item 5a) After a non-ko move komaster reverts to EMPTY. 
    663585@item 5b) Unconditional ko capture is only allowed if it is nested ko capture. 
    664586@quotation 
    665 Komaster is changed to WEAK_X and kom_pos to the old value of 
    666 board_ko_pos. 
     587Kom_pos is moved to the old value of board_ko_pos. 
    667588@end quotation 
    668589@item 5c) Conditional ko capture is allowed according to the rules of 1b. 
    669590@end itemize 
     
    801722The correct resolution is that H1 attacks L1 unconditionally while K2 
    802723defends it with ko (code @code{KO_A}). 
    803724 
    804 After Black (X) takes the ko at K3, white can do nothing 
     725After Black (X) takes the ko at K2, white can do nothing 
    805726but retake the ko conditionally, becoming komaster. B cannot 
    806727do much, but in one variation he plays at K4 and W takes 
    807728at H1. The following position results: 
     
    821742@end example 
    822743 
    823744Now it is important the @samp{O} is no longer komaster. Were @samp{O} 
    824 still komaster, he could capture the ko at N3 and there would be 
     745still komaster, he couldn't capture the ko at N3 and there would be 
    825746no way to finish off B. 
    826747 
    827748 
  • gnugo/doc/using.texi

    RCS file: /sources/gnugo/gnugo/doc/using.texi,v
    retrieving revision 1.31
    diff -u -r1.31 using.texi
     
    496496Use Japanese Rules. This is the default unless you specify 
    497497@option{--enable-chinese-rules} as a configure option. 
    498498@end quotation 
     499@item @option{--autolevel} 
     500@quotation 
     501Turns on level adjusting according to the left time. It doesn't apply to 
     502GTP mode (which is turned on by GTP commands). 
     503@end quotation 
     504@item @option{--min-level @var{amount}} 
     505@quotation 
     506If the time is running out, sets the minimum level with which GNU Go 
     507will play. If lower level is set with --level option, it sets 
     508--min-level to that lower value too. Used only when --autolevel is 
     509turned on. 
     510@end quotation 
     511@item @option{--max-level @var{amount}} 
     512@quotation 
     513If much time is left, sets the maximum level with which GNU Go will 
     514play. If higher level is set with --level option, it sets --max-level 
     515to that higher value too. Used only when --autolevel is turned on. 
     516@end quotation 
    499517@item @option{--forbid-suicide}  
    500518@quotation 
    501519Do not allow suicide moves (playing a stone so that it ends up without 
     
    582600accuracy. For completeness, here they are. 
    583601 
    584602@itemize @bullet 
     603@item @option{--print-levels} 
     604@quotation 
     605Prints info about each level of play of GNU Go. 
     606@end quotation 
     607@end itemize 
     608 
     609@itemize @bullet 
    585610@item @option{-D}, @option{--depth @var{depth}} 
    586611@cindex depth 
    587612@quotation 
     
    621646depth (default 13), GNU Go still tries to attack strings with only 
    6226473 liberties, but only tries one move at each node. 
    623648@end quotation 
    624 @item @option{--break_chain-cutoff @var{depth}} 
     649@item @option{--break_chain-depth @var{depth}} 
    625650@quotation 
    626651Set the @code{break_chain_depth}. Beyond this depth, GNU Go abandons 
    627652some attempts to defend groups by trying to capture part of the surrounding 
     
    643668Such tactics are tried below @code{superstring_depth} and this 
    644669command line option allows this parameter to be set. 
    645670@end quotation 
     671@item @option{--semeai-node-limit @var{n}} 
     672@quotation 
     673If the number of variations exceeds this limit, Owl stops analyzing 
     674semeai moves. Default 500. 
     675@end quotation 
    646676@end itemize 
    647677 
    648678The preceeding options are documented with the reading code 
     
    724754GNU Go. It causes both the traces and the output file (@option{-o}) to 
    725755be more informative. 
    726756@end quotation 
     757@item @option{--limit-search @var{location}} 
     758@quotation 
     759Limits the area of allowed moves to a diamond with radius 6 with center 
     760at @var{location}. 
     761@end quotation 
    727762@item @option{-T}, @option{--printboard}: colored display of dragons. 
    728763@quotation 
    729764Use rxvt, xterm or Linux Console. (@pxref{Colored Display}) 
     
    732767@quotation 
    733768Print timing information to stderr. 
    734769@end quotation 
     770@item @option{--showscore} 
     771@quotation 
     772Print scoring information to stderr. 
     773@end quotation 
    735774@item @option{-E}, @option{--printeyes}: colored display of eye spaces 
    736775@quotation 
    737776Use rxvt, xterm or Linux Console. (@pxref{Colored Display}) 
     
    799838@quotation 
    800839Print statistics (for debugging purposes). 
    801840@end quotation 
     841@item @option{--profile-patterns} 
     842@quotation 
     843Print statistics for pattern usage. 
     844@end quotation 
    802845@item @option{-t}, @option{--trace} 
    803846@quotation 
    804847Print debugging information. Use twice for more detail. 
     
    919962The option @option{--capture-all-dead} requires the aftermath 
    920963code to finish capturing all dead stones. 
    921964@end quotation 
     965@item @option{--play-out-aftermath} 
     966@quotation 
     967Forces playing of aftermath (see --score). 
     968@end quotation 
    922969@end itemize 
    923970 
    924971@subsection Experimental options 
  • gnugo/doc/utils.texi

    RCS file: /sources/gnugo/gnugo/doc/utils.texi,v
    retrieving revision 1.19
    diff -u -r1.19 utils.texi
     
    514514@item @code{void dump_stack(void)} 
    515515@findex dump_stack 
    516516@quotation 
    517 for use under GDB prints the move stack. 
     517For use under GDB prints the move stack. 
     518@end quotation 
     519@item @code{void dump_incremental_board(void)} 
     520@findex dump_incremental_board 
     521@quotation 
     522Debug function. Dump all incremental board information. 
    518523@end quotation 
    519524@item @code{void add_stone(int pos, int color)} 
    520525@findex add_stone 
     
    588593different functions in this family. 
    589594 
    590595@itemize @bullet 
    591 @item @code{int countlib(int str)} 
     596@item @code{int countlib(int str_pos)} 
    592597@findex countlib 
    593598@quotation 
    594 Count the number of liberties of the string at @code{pos}. There 
    595 must be a stone at this location. 
     599Count the number of liberties of the string at @code{str_pos}. @code{str_pos} 
     600must not be empty. 
    596601@end quotation 
    597 @item @code{int findlib(int str, int maxlib, int *libs)} 
     602@item @code{int findlib(int str_pos, int maxlib, int *libs)} 
    598603@findex findlib 
    599604@quotation 
    600 Find the liberties of the string at @code{str}. This location must not be 
    601 empty. The locations of up to maxlib liberties are written into 
    602 @code{libs[]}. The full number of liberties is returned.  If you want the 
    603 locations of all liberties, whatever their number, you should pass 
    604 @code{MAXLIBS} as the value for @code{maxlib} and allocate space for 
    605 @code{libs[]} accordingly. 
     605Find the liberties of the string at @code{str_pos}. @code{str_pos} must not be 
     606empty. The locations of up to maxlib liberties are written into @code{libs[]}. 
     607The full number of liberties is returned.  If you want the locations of all 
     608liberties, whatever their number, you should pass @code{MAXLIBS} as the value 
     609for @code{maxlib} and allocate space for @code{libs[]} accordingly. 
    606610@end quotation 
    607611@item @code{int fastlib(int pos, int color, int ignore_captures)} 
    608612@findex fastlib 
     
    652656Next we have some general utility functions. 
    653657 
    654658@itemize @bullet 
    655 @item @code{int count_common_libs(int str1, int str2)} 
     659@item @code{int count_common_libs(int str1_pos, int str2_pos)} 
    656660@findex count_common_libs 
    657661@quotation 
    658662Find the number of common liberties of the two strings. 
    659663@end quotation 
    660 @item @code{int find_common_libs(int str1, int str2, int maxlib, int *libs)} 
     664@item @code{int find_common_libs(int str1_pos, int str2_pos, int maxlib, int *libs)} 
    661665@findex find_common_libs 
    662666@quotation 
    663667Find the common liberties of the two strings. The locations of up to 
     
    666670common liberties, whatever their number, you should pass @code{MAXLIBS} as the 
    667671value for @code{maxlib} and allocate space for @code{libs[]} accordingly. 
    668672@end quotation 
    669 @item @code{int have_common_lib(int str1, int str2, int *lib)} 
     673@item @code{int have_common_lib(int str1_pos, int str2_pos, int *lib)} 
    670674@findex have_common_lib 
    671675@quotation 
    672676Determine whether two strings have at least one common liberty. 
    673677If they do and @code{lib != NULL}, one common liberty is returned in  
    674678@code{*lib}. 
    675679@end quotation 
    676 @item @code{int countstones(int str)} 
     680@item @code{int countstones(int str_pos)} 
    677681@findex countstones 
    678682@quotation 
    679683Report the number of stones in a string. 
    680684@end quotation 
    681 @item @code{int findstones(int str, int maxstones, int *stones)} 
     685@item @code{int count_adjacent_stones(int str1_pos, int str2_pos, int maxstones)} 
     686@findex count_adjacent_stones 
     687@quotation 
     688Counts how many stones in one string are directly adjacent to the second 
     689string. A limit can be given in the @code{maxstones} parameter so that the 
     690function returns immediately. 
     691@end quotation 
     692@item @code{int findstones(int str_pos, int maxstones, int *stones)} 
    682693@findex findstones 
    683694@quotation 
    684 Find the stones of the string at @code{str}. The location must not be 
    685 empty. The locations of up to maxstones stones are written into 
    686 @code{stones[]}. The full number of stones is returned. 
     695Find the stones of the string at @code{str_pos}. The locations of up 
     696to maxstones stones are written into @code{stones[]}. The full number of 
     697stones is returned. 
    687698@end quotation 
    688 @item @code{int  chainlinks(int str, int adj[MAXCHAIN])} 
     699@item @code{int chainlinks(int str_pos, int adj[MAXCHAIN])} 
    689700@findex chainlinks 
    690701@quotation 
    691702This very useful function returns (in the @code{adj} array) the chains 
    692 surrounding the string at @code{str}. The number of chains is returned. 
     703surrounding the string at @code{str_pos}. The number of chains is returned. 
    693704@end quotation 
    694 @item @code{int chainlinks2(int str, int adj[MAXCHAIN], int lib)} 
     705@item @code{int chainlinks2(int str_pos, int adj[MAXCHAIN], int lib)} 
    695706@findex chainlinks2 
    696707@quotation 
    697708Returns (in @code{adj} array) those chains surrounding the string at 
    698 @code{str}, which has exactly @code{lib} liberties. The number of such chains 
     709@code{str_pos}, which has exactly @code{lib} liberties. The number of such chains 
    699710is returned. 
    700711@end quotation 
    701 @item @code{int chainlinks3(int str, int adj[MAXCHAIN], int lib)} 
     712@item @code{int chainlinks3(int str_pos, int adj[MAXCHAIN], int lib)} 
    702713@findex chainlinks3 
    703714@quotation 
    704715Returns (in @code{adj} array) the chains surrounding 
    705 the string at @code{str}, which have less or equal @code{lib} liberties. 
     716the string at @code{str_pos}, which have less or equal @code{lib} liberties. 
    706717The number of such chains is returned. 
    707718@end quotation 
    708 @item @code{int extended_chainlinks(int str, int adj[MAXCHAIN], int both_colors)} 
     719@item @code{int extended_chainlinks(int str_pos, int adj[MAXCHAIN], int both_colors)} 
    709720@findex extended_chainlinks 
    710721@quotation 
    711722Returns (in the @code{adj} array) the opponent strings being directly adjacent 
    712 to @code{str} or having a common liberty with @code{str}. The number of such 
    713 strings is returned.  If the both_colors parameter is true, also own strings 
     723to string at @code{str_pos} or having a common liberty with @code{str_nr}. The number 
     724of such strings is returned.  If the both_colors parameter is true, also own strings 
    714725sharing a liberty are returned. 
    715726@end quotation 
    716 @item @code{int find_origin(int str)} 
     727@item @code{int find_origin(int str_pos)} 
    717728@findex find_origin 
    718729@quotation 
    719730Find the origin of a string, i.e. the point with the smallest 1D board 
     
    727738i.e. whether it would get more than one liberty. This function 
    728739returns true also for the case of a suicide move. 
    729740@end quotation 
    730 @item @code{int liberty_of_string(int pos, int str)} 
     741@item @code{int liberty_of_string(int pos, int str_pos)} 
    731742@findex liberty_of_string 
    732743@quotation 
    733 Returns true if @code{pos} is a liberty of the string at @code{str}. 
     744Returns true if @code{pos} is a liberty of the string at @code{str_pos}. Checks 
     745whether pos is a liberty. 
     746@end quotation 
     747@item @code{int liberty_of_string2(int pos, int str_pos)} 
     748@findex liberty_of_string2 
     749@quotation 
     750Returns true if @code{pos} is a liberty of the string at @code{str_pos}. 
     751@code{str_pos} must be a liberty. 
    734752@end quotation 
    735 @item @code{int second_order_liberty_of_string(int pos, int str)} 
     753@item @code{int second_order_liberty_of_string(int pos, int str_pos)} 
    736754@findex second_order_liberty_of_string 
    737755@quotation 
    738 Returns true if @code{pos} is a second order liberty of the string at str. 
     756Returns true if @code{pos} is a second order liberty of the string at 
     757@code{str_pos}. 
    739758@end quotation 
    740 @item @code{int neighbor_of_string(int pos, int str)} 
     759@item @code{int are_neighbors(int pos1, int pos2)} 
     760@findex are_neighbors 
     761@quotation 
     762Returns true if the empty vertex or the string at @code{pos1} is 
     763adjacent to the empty vertex or the string at @code{pos2}. 
     764@end quotation 
     765@item @code{int neighbor_of_string(int pos, int str_pos)} 
    741766@findex neighbor_of_string 
    742767@quotation 
    743 Returns true if @code{pos} is adjacent to the string at @code{str}. 
     768Returns true if @code{pos} is adjacent to the string at @code{str_pos}. 
    744769@end quotation 
    745770@item @code{int has_neighbor(int pos, int color)} 
    746771@findex has_neighbor 
    747772@quotation 
    748773Returns true if @code{pos} has a neighbor of @code{color}. 
    749774@end quotation 
    750 @item @code{int same_string(int str1, int str2)} 
     775@item @code{int same_string(int str1_pos, int str2_pos)} 
    751776@findex same_string 
    752777@quotation 
    753 Returns true if @code{str1} and @code{str2} belong to the same string. 
     778Returns true if @code{str1_pos} and @code{str2_pos} belong to the same string. 
    754779@end quotation 
    755 @item @code{int adjacent_strings(int str1, int str2)} 
     780@item @code{int adjacent_strings(int str1_pos, int str2_pos)} 
    756781@findex adjacent_strings 
    757782@quotation 
    758 Returns true if the strings at @code{str1} and @code{str2} are adjacent. 
     783Returns true if the strings at @code{str1_pos} and @code{str2_pos} are adjacent. 
    759784@end quotation 
    760785@item @code{int is_ko(int pos, int color, int *ko_pos)} 
    761786@findex is_ko 
     
    777802Return true if @code{pos} is either a stone, which if captured would give 
    778803ko, or if @code{pos} is an empty intersection adjacent to a ko stone. 
    779804@end quotation 
     805@item @code{int is_superko_violation(int pos, int color, enum ko_rules type)} 
     806@findex is_superko_violation 
     807@quotation 
     808Return true if a move by @code{color} at @code{pos} is a superko violation 
     809according to the specified type of ko rules. This function does not 
     810detect simple ko unless it's also a superko violation. 
     811@end quotation 
    780812@item @code{int does_capture_something(int pos, int color)} 
    781813@findex does_capture_something 
    782814@quotation 
     
    797829Returns true if at least one move has been played at pos 
    798830at deeper than level @code{cutoff} in the reading tree. 
    799831@end quotation 
     832@item @code{void get_move_from_stack(int k, int *move, int *color)} 
     833@findex get_move_from_stack 
     834@quotation 
     835Retrieve a move from the move stack. 
     836@end quotation 
    800837@item @code{int stones_on_board(int color)} 
    801838@findex stones_on_board 
    802839@quotation