Ticket #145: board.texi.patch

File board.texi.patch, 3.5 kB (added by draqo, 2 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 
     
    219219A loop over multiple directions is straightforwardly written: 
    220220 
    221221@example 
    222   for (k = 0; k < 4; k++) @{ 
     222  for (k = 0; k < 4; ++k) @{ 
    223223    int d = delta[k]; 
    224224    do_something(pos + d); 
    225225  @} 
     
    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: 
     243at every vertex. There is a macro for doing this: 
    244244 
    245245@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     @} 
     246#define scan_board(_pos_var, _code) 
    251247@end example 
    252248 
    253 Or: 
     249The @code{_code} parameter is code to be run for each vertex and 
     250@code{_pos_var} is name of the variable, which will hold the 1D position 
     251on the board, to be used inside @code{_code}. @code{break} and 
     252@code{continue} can be used inside @code{_code} like inside @code{for} 
     253loop. @strong{Warning:} every variable 
     254declared inside @code{_code} must be declared separately or there will be 
     255compilation errors (eg. @code{int x; int y;} instead of @code{int x, y;}). 
     256Example: 
    254257 
    255258@example 
    256   int pos; 
    257   for (pos = BOARDMIN; pos < BOARDMAX; pos++) @{ 
    258     if (ON_BOARD(pos)) 
    259       do_something(pos); 
    260   @} 
     259 
     260int pos; 
     261 
     262scan_board(pos, 
     263  int x; 
     264  int y; 
     265  x = do_something_with(pos); 
     266  y = do_something_else_with(pos); 
     267) 
     268 
    261269@end example 
    262270 
    263271