Ticket #148: changes2.diff

File changes2.diff, 97.1 kB (added by draqo, 20 months ago)
  • gnugo/engine/board.h

    RCS file: /sources/gnugo/gnugo/engine/board.h,v
    retrieving revision 1.34
    diff -u -r1.34 board.h
     
    3636 * character access is very slow. 
    3737 */ 
    3838 
     39/* simple test for old machines */ 
     40#if SIZEOF_INT >= 4 
     41#define INT_INTERSECTION 
     42typedef int Intersection; 
     43#else 
    3944typedef unsigned char Intersection; 
     45#endif 
    4046 
    4147/* FIXME: This is very ugly but we can't include hash.h until we have 
    4248 * defined Intersection. And we do need to include it before using 
     
    135141 
    136142/* Note that POS(-1, -1) == 0 
    137143 * DELTA() is defined so that POS(i+di, j+dj) = POS(i, j) + DELTA(di, dj). 
     144 * For details look in the documentation. 
    138145 */ 
    139146#define BOARDSIZE     ((MAX_BOARD + 2) * (MAX_BOARD + 1) + 1) 
    140147#define BOARDMIN      (MAX_BOARD + 2) 
     
    148155#define NS            (MAX_BOARD + 1) 
    149156#define WE            1 
    150157#define SOUTH(pos)    ((pos) + NS) 
    151 #define WEST(pos)     ((pos) - 1) 
     158#define WEST(pos)     ((pos) - WE) 
    152159#define NORTH(pos)    ((pos) - NS) 
    153 #define EAST(pos)     ((pos) + 1) 
    154 #define SW(pos)       ((pos) + NS - 1) 
    155 #define NW(pos)       ((pos) - NS - 1) 
    156 #define NE(pos)       ((pos) - NS + 1) 
    157 #define SE(pos)       ((pos) + NS + 1) 
     160#define EAST(pos)     ((pos) + WE) 
     161#define SW(pos)       ((pos) + NS - WE) 
     162#define NW(pos)       ((pos) - NS - WE) 
     163#define NE(pos)       ((pos) - NS + WE) 
     164#define SE(pos)       ((pos) + NS + WE) 
    158165#define SS(pos)       ((pos) + 2 * NS) 
    159 #define WW(pos)       ((pos) - 2) 
     166#define WW(pos)       ((pos) - 2 * WE) 
    160167#define NN(pos)       ((pos) - 2 * NS) 
    161 #define EE(pos)       ((pos) + 2) 
     168#define EE(pos)       ((pos) + 2 * WE) 
    162169 
    163170#define DIRECT_NEIGHBORS(pos1, pos2)            \ 
    164171  ((pos1) == SOUTH(pos2)                        \ 
     
    260267/* Functions handling the permanent board state. */ 
    261268void clear_board(void); 
    262269int test_gray_border(void); 
    263 void setup_board(Intersection new_board[MAX_BOARD][MAX_BOARD], int ko_pos, 
    264                  int *last, float new_komi, int w_captured, int b_captured); 
    265270void add_stone(int pos, int color); 
    266271void remove_stone(int pos); 
    267272void play_move(int pos, int color); 
     
    271276void restore_board(struct board_state *state); 
    272277 
    273278/* Information about the permanent board. */ 
    274 int get_last_move(void); 
    275 int get_last_player(void); 
     279inline int get_last_move(void); 
     280inline int get_last_player(void); 
    276281int get_last_opponent_move(int color); 
    277282int stones_on_board(int color); 
    278283 
    279284/* Functions handling the variable board state. */ 
    280 int trymove(int pos, int color, const char *message, int str); 
     285int trymove(int pos, int color, const char *message, int str_pos); 
    281286int tryko(int pos, int color, const char *message); 
    282287void popgo(void); 
    283288int komaster_trymove(int pos, int color, 
    284289                     const char *message, int str, 
    285290                     int *is_conditional_ko, int consider_conditional_ko); 
    286 int get_komaster(void); 
    287 int get_kom_pos(void); 
     291inline int get_komaster(void); 
     292inline int get_kom_pos(void); 
    288293 
    289294int move_in_stack(int pos, int cutoff); 
    290 void get_move_from_stack(int k, int *move, int *color); 
     295inline void get_move_from_stack(int k, int *move, int *color); 
    291296void dump_stack(void); 
    292297void do_dump_stack(void); 
    293298 
    294 void reset_trymove_counter(void); 
    295 int get_trymove_counter(void); 
     299void dump_incremental_board(void); 
     300 
     301inline void reset_trymove_counter(void); 
     302inline int get_trymove_counter(void); 
    296303 
    297304/* move properties */ 
    298 int is_pass(int pos); 
     305inline int is_pass(int pos); 
    299306int is_legal(int pos, int color); 
    300307int is_suicide(int pos, int color); 
    301 int is_illegal_ko_capture(int pos, int color); 
     308inline int is_illegal_ko_capture(int pos, int color); 
    302309int is_allowed_move(int pos, int color); 
    303310int is_ko(int pos, int color, int *ko_pos); 
    304311int is_ko_point(int pos); 
     
    306313int is_self_atari(int pos, int color); 
    307314 
    308315/* Purely gemoetric functions */ 
    309 int is_edge_vertex(int pos); 
    310 int is_corner_vertex(int pos); 
    311 int edge_distance(int pos); 
    312 int square_dist(int pos1, int pos2); 
     316inline int is_edge_vertex(int pos); 
     317inline int is_corner_vertex(int pos); 
     318inline int edge_distance(int pos); 
     319inline int square_dist(int pos1, int pos2); 
    313320 
    314321/* Basic string information. */ 
    315 int find_origin(int str); 
    316 int chainlinks(int str, int adj[MAXCHAIN]); 
    317 int chainlinks2(int str, int adj[MAXCHAIN], int lib); 
    318 int chainlinks3(int str, int adj[MAXCHAIN], int lib); 
    319 int extended_chainlinks(int str, int adj[MAXCHAIN], int both_colors); 
    320  
    321 int liberty_of_string(int pos, int str); 
    322 int second_order_liberty_of_string(int pos, int str); 
    323 int neighbor_of_string(int pos, int str); 
    324 int has_neighbor(int pos, int color); 
    325 int same_string(int str1, int str2); 
    326 int adjacent_strings(int str1, int str2); 
     322inline int find_origin(int str_pos); 
     323int chainlinks(int str_pos, int adj[MAXCHAIN]); 
     324int chainlinks2(int str_pos, int adj[MAXCHAIN], int lib); 
     325int chainlinks3(int str_pos, int adj[MAXCHAIN], int lib); 
     326int extended_chainlinks(int str_pos, int adj[MAXCHAIN], int both_colors); 
     327 
     328int liberty_of_string(int pos, int str_pos); 
     329int liberty_of_string2(int pos, int str_pos); 
     330int second_order_liberty_of_string(int pos, int str_pos); 
     331int neighbor_of_string(int pos, int str_pos); 
     332inline int has_neighbor(int pos, int color); 
     333inline int same_string(int str1_pos, int str2_pos); 
     334int adjacent_strings(int str1_pos, int str2_pos); 
    327335void mark_string(int str, signed char mx[BOARDMAX], signed char mark); 
    328336int are_neighbors(int pos1, int pos2); 
    329337 
    330 /* Count and/or find liberties at (pos). */ 
    331 int countlib(int str); 
    332 int findlib(int str, int maxlib, int *libs); 
     338/* Count and/or find liberties at (pos) */ 
     339inline int countlib(int str_pos); 
     340int findlib(int str_pos, int maxlib, int *libs); 
    333341int fastlib(int pos, int color, int ignore_captures); 
    334342int approxlib(int pos, int color, int maxlib, int *libs); 
    335343int accuratelib(int pos, int color, int maxlib, int *libs); 
    336 int count_common_libs(int str1, int str2); 
    337 int find_common_libs(int str1, int str2, int maxlib, int *libs); 
    338 int have_common_lib(int str1, int str2, int *lib); 
     344int count_common_libs(int str1_pos, int str2_pos); 
     345int find_common_libs(int str1_pos, int str2_pos, int maxlib, int *libs); 
     346int have_common_lib(int str1_pos, int str2_pos, int *lib); 
    339347 
    340348/* Count the number of stones in a string. */ 
    341 int countstones(int str); 
    342 int findstones(int str, int maxstones, int *stones); 
    343 int count_adjacent_stones(int str1, int str2, int maxstones); 
     349inline int countstones(int str_pos); 
     350int findstones(int str_pos, int maxstones, int *stones); 
     351int count_adjacent_stones(int str1_pos, int str2_pos, int maxstones); 
    344352 
    345353/* Special function for reading.c */ 
    346 void incremental_order_moves(int move, int color, int string, 
     354void incremental_order_moves(int move, int color, int target_pos, 
    347355                             int *number_edges, int *number_same_string, 
    348356                             int *number_own, int *number_opponent, 
    349357                             int *captured_stones, int *threatened_stones, 
    350358                             int *saved_stones, int *number_open); 
    351359 
    352360/* Board caches initialization functions. */ 
    353 void clear_approxlib_cache(void); 
    354 void clear_accuratelib_cache(void); 
     361inline void clear_approxlib_cache(void); 
     362inline void clear_accuratelib_cache(void); 
    355363   
    356364 
    357365/* Is this point inside the board? */ 
     
    381389 * south, west, north, east, southwest, northwest, northeast, southeast. 
    382390 * Defined in board.c. 
    383391 */ 
    384 extern int deltai[8]; /* = { 1,  0, -1,  0,  1, -1, -1, 1}; */ 
    385 extern int deltaj[8]; /* = { 0, -1,  0,  1, -1, -1,  1, 1}; */ 
    386 extern int delta[8];  /* = { NS, -1, -NS, 1, NS-1, -NS-1, -NS+1, NS+1}; */ 
     392extern const int deltai[8]; /* = { 1,  0, -1,  0,  1, -1, -1, 1}; */ 
     393extern const int deltaj[8]; /* = { 0, -1,  0,  1, -1, -1,  1, 1}; */ 
     394extern const int delta[8];  /* = { NS, -WE, -NS, WE, NS-WE, -NS-WE, -NS+WE, NS+WE}; */ 
    387395 
    388396 
    389397 
  • gnugo/engine/boardlib.c

    RCS file: /sources/gnugo/gnugo/engine/boardlib.c,v
    retrieving revision 1.12
    diff -u -r1.12 boardlib.c
     
    2929/* The board state itself. */ 
    3030int          board_size = DEFAULT_BOARD_SIZE; /* board size */ 
    3131Intersection board[BOARDSIZE]; 
    32 int          board_ko_pos; 
     32int          board_ko_pos;      /* Position of a ko (captured stone). */ 
    3333int          white_captured;    /* number of black and white stones captured */ 
    3434int          black_captured; 
    3535 
     
    5454/* Hashing of positions. */ 
    5555Hash_data board_hash; 
    5656 
    57 int stackp;             /* stack pointer */ 
     57int stackp;             /* moves stack depth */ 
    5858int position_number;    /* position number */ 
    5959 
    6060/* Some statistics gathered partly in board.c and hash.c */ 
  • gnugo/engine/breakin.c

    RCS file: /sources/gnugo/gnugo/engine/breakin.c,v
    retrieving revision 1.26
    diff -u -r1.26 breakin.c
     
    367367 
    368368        if (used[pos2]) 
    369369          break; 
    370       } 
     370          } 
    371371 
    372372      used[pos] = 1; 
    373373      if (ON_BOARD(pos2)) 
     
    440440  } 
    441441} 
    442442 
    443 void 
     443inline void 
    444444clear_break_in_list() 
    445445{ 
    446446  num_break_ins = 0; 
  • gnugo/engine/cache.c

    RCS file: /sources/gnugo/gnugo/engine/cache.c,v
    retrieving revision 1.50
    diff -u -r1.50 cache.c
     
    3939/* ---------------------------------------------------------------- */ 
    4040 
    4141static void tt_init(Transposition_table *table, int memsize); 
    42 static void tt_clear(Transposition_table *table); 
     42inline static void tt_clear(Transposition_table *table); 
    4343 
    4444/* The transposition table itself. */ 
    4545Transposition_table ttable; 
     
    7272calculate_hashval_for_tt(Hash_data *hashdata, int routine, int target1, 
    7373                         int target2, Hash_data *extra_hash) 
    7474{  
    75   *hashdata = board_hash;                /* from globals.c */ 
     75  *hashdata = board_hash;                /* from boardlib.c */ 
    7676  hashdata_xor(*hashdata, routine_hash[routine]); 
    7777  hashdata_xor(*hashdata, target1_hash[target1]); 
    7878  if (target2 != NO_MOVE) 
     
    9797  keyhash_init(); 
    9898 
    9999  if (memsize > 0) 
    100     num_entries = memsize / sizeof(table->entries[0]); 
     100    num_entries = memsize / sizeof(Hashentry); 
    101101  else 
    102102    num_entries = DEFAULT_NUMBER_OF_CACHE_ENTRIES; 
    103103 
    104104  table->num_entries = num_entries; 
    105   table->entries     = malloc(num_entries * sizeof(table->entries[0])); 
     105  table->entries     = malloc(num_entries * sizeof(Hashentry)); 
    106106 
    107107  if (table->entries == NULL) { 
    108108    perror("Couldn't allocate memory for transposition table. \n"); 
    109109    exit(1); 
    110110  } 
    111111 
    112   table->is_clean = 0; 
    113112  tt_clear(table); 
    114113} 
    115114 
    116115 
    117116/* Clear the transposition table. */ 
    118117 
    119 static void 
     118inline static void 
    120119tt_clear(Transposition_table *table) 
    121120{ 
    122   if (!table->is_clean) { 
    123     memset(table->entries, 0, table->num_entries * sizeof(table->entries[0])); 
    124     table->is_clean = 1; 
    125   } 
     121  memset(table->entries, 0, table->num_entries * sizeof(Hashentry)); 
    126122} 
    127   
    128   
     123 
     124 
    129125/* Free the transposition table. */ 
    130126 
    131 void 
     127inline void 
    132128tt_free(Transposition_table *table) 
    133129{ 
    134130  free(table->entries); 
    135131} 
    136132 
    137133 
    138 /* Get result and move. Return value: 
     134/* Get result and move (the bigger remaining depth the lower depth). 
     135 * Return value: 
    139136 *   0 if not found 
    140  *   1 if found, but depth too small to be trusted.  In this case the move 
     137 *   1 if found, but depth too big to be trusted.  In this case the move 
    141138 *     can be used for move ordering. 
    142  *   2 if found and depth is enough so that the result can be trusted. 
     139 *   2 if found and depth is small enough so that the result can be trusted. 
    143140 */ 
    144141  
    145142int 
     
    162159 
    163160  /* Get the correct entry and node. */ 
    164161  entry = &table->entries[hashdata_remainder(hashval, table->num_entries)]; 
    165   if (hashdata_is_equal(hashval, entry->deepest.key)) 
    166     node = &entry->deepest; 
     162 
     163  if (hashdata_is_equal(hashval, entry->most_reliable.key)) 
     164    node = &entry->most_reliable; 
    167165  else if (hashdata_is_equal(hashval, entry->newest.key)) 
    168166    node = &entry->newest; 
    169167  else 
    170168    return 0; 
    171169 
    172   stats.read_result_hits++; 
     170#ifndef GG_TURN_OFF_STATS 
     171  ++stats.read_result_hits; 
     172#endif 
    173173 
    174174  /* Return data.  Only set the result if remaining depth in the table 
    175175   * is big enough to be trusted.  The move can always be used for move 
     
    177177   */ 
    178178  if (move) 
    179179    *move = hn_get_move(node->data); 
     180 
    180181  if (remaining_depth <= (int) hn_get_remaining_depth(node->data)) { 
    181182    if (value1) 
    182183      *value1 = hn_get_value1(node->data); 
    183184    if (value2) 
    184185      *value2 = hn_get_value2(node->data); 
    185     stats.trusted_read_result_hits++; 
     186 
     187#ifndef GG_TURN_OFF_STATS 
     188    ++stats.trusted_read_result_hits; 
     189#endif 
     190 
    186191    return 2; 
    187192  } 
    188193 
     
    201206{ 
    202207  Hash_data hashval; 
    203208  Hashentry *entry; 
    204   Hashnode *deepest; 
     209  Hashnode *most_reliable; 
    205210  Hashnode *newest; 
    206211  unsigned int data; 
    207212  /* Get routine costs definitions from liberty.h. */ 
     
    220225 
    221226  /* Get the entry and nodes. */  
    222227  entry = &table->entries[hashdata_remainder(hashval, table->num_entries)]; 
    223   deepest = &entry->deepest; 
     228  most_reliable = &entry->most_reliable; 
    224229  newest  = &entry->newest; 
    225230  
    226231  /* See if we found an already existing node. */ 
    227   if (hashdata_is_equal(hashval, deepest->key) 
    228       && remaining_depth >= (int) hn_get_remaining_depth(deepest->data)) { 
    229  
    230     /* Found deepest */ 
    231     deepest->data = data; 
    232  
     232  if (hashdata_is_equal(hashval, most_reliable->key)) 
     233  { 
     234    /* Found shallower node (can be trusted more likely) */ 
     235    if (remaining_depth > (int) hn_get_remaining_depth(most_reliable->data)) 
     236      most_reliable->data = data; 
    233237  } 
    234   else if (hashdata_is_equal(hashval, newest->key) 
    235            && remaining_depth >= (int) hn_get_remaining_depth(newest->data)) { 
    236  
     238  else if (hashdata_is_equal(hashval, newest->key)) 
     239  { 
    237240    /* Found newest */ 
    238     newest->data = data; 
    239  
    240     /* If newest has become deeper than deepest, then switch them. */ 
    241     if (hn_get_remaining_depth(newest->data) 
    242         > hn_get_remaining_depth(deepest->data)) { 
    243       Hashnode temp; 
    244  
    245       temp = *deepest; 
    246       *deepest = *newest; 
    247       *newest = temp; 
     241    if (remaining_depth > (int) hn_get_remaining_depth(newest->data)) 
     242    { 
     243      newest->data = data; 
     244 
     245      /* If newest reliability is bigger than most_reliable, switch them. */ 
     246      if (hn_get_reliability(newest->data) > 
     247          hn_get_reliability(most_reliable->data)) 
     248      { 
     249        Hashnode temp; 
     250 
     251        temp = *most_reliable; 
     252        *most_reliable = *newest; 
     253        *newest = temp; 
     254      } 
    248255    } 
    249  
    250256  } 
    251   else if (hn_get_total_cost(data) > hn_get_total_cost(deepest->data)) { 
    252     if (hn_get_total_cost(newest->data) < hn_get_total_cost(deepest->data)) 
    253       *newest = *deepest; 
    254     deepest->key  = hashval; 
    255     deepest->data = data; 
    256   }  
    257   else { 
     257  /* Have new node. */ 
     258  else if (hn_get_reliability(data) > 
     259           hn_get_reliability(most_reliable->data)) 
     260  { 
     261    /* Replace most_reliable. */ 
     262    most_reliable->key  = hashval; 
     263    most_reliable->data = data; 
     264  } 
     265  else 
     266  { 
    258267    /* Replace newest. */ 
    259268    newest->key  = hashval; 
    260269    newest->data = data; 
    261270  } 
    262271 
    263   stats.read_result_entered++; 
    264   table->is_clean = 0; 
     272#ifndef GG_TURN_OFF_STATS 
     273  ++stats.read_result_entered; 
     274#endif 
    265275} 
    266276 
    267277 
     
    270280}; 
    271281 
    272282/* Convert a routine as used in the cache table to a string. */ 
    273 const char * 
     283inline const char * 
    274284routine_id_to_string(enum routine_id routine) 
    275285{ 
    276286  return routine_names[(int) routine]; 
     
    282292 * allocate a single node or if the allocation fails, the caching is 
    283293 * disabled. 
    284294 */ 
    285 void 
     295inline void 
    286296reading_cache_init(int bytes) 
    287297{ 
    288298  tt_init(&ttable, bytes); 
     
    290300 
    291301 
    292302/* Clear the cache for read results. */ 
    293 void 
     303inline void 
    294304reading_cache_clear() 
    295305{ 
    296306  tt_clear(&ttable); 
    297307} 
    298308 
    299 float 
     309inline float 
    300310reading_cache_default_size() 
    301311{ 
    302312  return DEFAULT_NUMBER_OF_CACHE_ENTRIES * sizeof(Hashentry) / 1024.0 / 1024.0; 
  • gnugo/engine/cache.h

    RCS file: /sources/gnugo/gnugo/engine/cache.h,v
    retrieving revision 1.54
    diff -u -r1.54 cache.h
     
    3232 * (Reading/Hashing) for more information.   
    3333 */ 
    3434 
     35#if SIZEOF_INT == 4 
     36  typedef unsigned int HASHNODE_DATATYPE; 
     37#elif SIZEOF_LONG == 4 
     38  typedef unsigned long HASHNODE_DATATYPE; 
     39#elif SIZEOF_INT > 4 
     40  typedef unsigned short HASHNODE_DATATYPE; 
     41#elif 
     42  #error Long type size has to be at least 4 bytes. 
     43#endif 
    3544 
    3645/* Hashnode: a node stored in the transposition table. 
    3746 * 
    3847 * In addition to the position, the hash lock encodes the following data, 
    3948 * all hashed: 
    40  *   komaster 
    41  *   kom_pos 
     49 *   ko 
     50 *   komaster (look in doc) 
     51 *   kom_pos (look in doc) 
    4252 *   routine 
    43  *   str1 
    44  *   str2 
     53 *   target1 
     54 *   target2 
    4555 *   extra hashvalue, optional (e.g. encoding a goal array) 
    4656 * 
    4757 * The data field packs into 32 bits the following 
     
    5464 *   cost           :  4 bits 
    5565 *   remaining_depth:  5 bits (depth - stackp)  NOTE: HN_MAX_REMAINING_DEPTH 
    5666 * 
    57  *   The last 9 bits together give an index for the total costs. 
     67 *   The last 9 bits together give a reliability index (bigger index means 
     68 *   more reliable result). 
     69 *   Values are results of analyzed position (WIN, LOSE, etc.) 
    5870 */ 
    5971typedef struct { 
    6072  Hash_data key; 
    61   unsigned int data; /* Should be 32 bits, but only wastes 25% if 64 bits. */ 
     73  HASHNODE_DATATYPE data; /* 32-bit value */ 
    6274} Hashnode; 
    6375 
    6476#define HN_MAX_REMAINING_DEPTH 31 
     
    6779/* Hashentry: an entry, with two nodes of the hash_table 
    6880 */ 
    6981typedef struct { 
    70   Hashnode deepest; 
     82  Hashnode most_reliable; 
    7183  Hashnode newest; 
    7284} Hashentry; 
    7385 
     
    7688#define hn_get_value2(hn)           ((hn >> 19) & 0x0f) 
    7789#define hn_get_move(hn)             ((hn >>  9) & 0x3ff) 
    7890#define hn_get_cost(hn)             ((hn >>  5) & 0x0f) 
    79 #define hn_get_remaining_depth(hn)  ((hn >>  0) & 0x1f) 
    80 #define hn_get_total_cost(hn)       ((hn >>  0) & 0x1ff) 
     91#define hn_get_remaining_depth(hn)  ((hn/*>>  0*/) & 0x1f) 
     92#define hn_get_reliability(hn)      ((hn/*>>  0*/) & 0x1ff) 
    8193 
    8294#define hn_create_data(remaining_depth, value1, value2, move, cost) \ 
    8395    ((((value1)         & 0x0f)  << 23) \ 
    8496   | (((value2)         & 0x0f)  << 19) \ 
    8597   | (((move)           & 0x3ff) <<  9) \ 
    8698   | (((cost)           & 0x0f)  <<  5) \ 
    87    | (((remaining_depth & 0x1f)  <<  0))) 
     99   | (((remaining_depth & 0x1f)/*<<  0*/))) 
    88100 
    89101 
    90102/* Transposition_table: transposition table used for caching. */ 
    91103typedef struct { 
    92104  unsigned int num_entries; 
    93105  Hashentry *entries; 
    94   int is_clean; 
    95106} Transposition_table; 
    96107 
    97108extern Transposition_table ttable; 
     
    101112 */ 
    102113#define DEFAULT_NUMBER_OF_CACHE_ENTRIES 350000 
    103114 
    104 void tt_free(Transposition_table *table); 
     115inline void tt_free(Transposition_table *table); 
    105116int  tt_get(Transposition_table *table, enum routine_id routine, 
    106117            int target1, int target2, int remaining_depth, 
    107118            Hash_data *extra_hash, 
     
    141152  int q1 = board[str1] == EMPTY ? str1 : find_origin(str1); \ 
    142153  int q2 = board[str2] == EMPTY ? str2 : find_origin(str2); 
    143154 
     155#define READ_FUNCTION_NAME read_function_name 
     156 
    144157#else 
    145158 
    146159#define TRACE_CACHED_RESULT(result, move) 
    147160#define TRACE_CACHED_RESULT2(result1, result2, move) 
    148161 
     162#ifndef GG_TURN_OFF_TRACES 
     163 
    149164#define SETUP_TRACE_INFO(name, str) \ 
    150165  const char *read_function_name = name; \ 
    151166  int q = str; 
     
    155170  int q1 = str1; \ 
    156171  int q2 = str2; 
    157172 
    158 #endif 
    159  
    160 /* Trace messages in decidestring/decidedragon sgf file. */ 
    161 void sgf_trace(const char *func, int str, int move, int result, 
    162                const char *message); 
    163 /* Trace messages in decideconnection sgf file. */ 
    164 void sgf_trace2(const char *func, int str1, int str2, int move,  
    165                 const char *result, const char *message); 
    166 /* Trace messages in decidesemeai sgf file. */ 
    167 void sgf_trace_semeai(const char *func, int str1, int str2, int move,  
    168                       int result1, int result2, const char *message); 
    169  
    170173/* Macro to hide the call to sgf_trace(). Notice that a little black 
    171174 * magic is going on here. Before using this macro, SETUP_TRACE_INFO 
    172175 * must have been called to provide the variables read_function_name 
     
    190193    sgf_trace_semeai(read_function_name, q1, q2, move, \ 
    191194                     result1, result2, message) 
    192195 
     196#define READ_FUNCTION_NAME read_function_name 
     197 
     198#else // #ifndef GG_TURN_OFF_TRACES 
     199 
     200#define SETUP_TRACE_INFO(name, str) 
     201#define SETUP_TRACE_INFO2(name, str1, str2) 
     202#define SGFTRACE(move, result, message) (void)0 
     203#define SGFTRACE2(move, result, message) (void)0 
     204#define SGFTRACE_SEMEAI(move, result1, result2, message) (void)0 
     205#define READ_FUNCTION_NAME NULL 
     206 
     207#endif // #ifndef GG_TURN_OFF_TRACES 
     208 
     209#endif // #if TRACE_READ_RESULTS 
     210 
     211/* Trace messages in decidestring/decidedragon sgf file. */ 
     212void sgf_trace(const char *func, int str, int move, int result, 
     213               const char *message); 
     214/* Trace messages in decideconnection sgf file. */ 
     215void sgf_trace2(const char *func, int str1, int str2, int move,  
     216                const char *result, const char *message); 
     217/* Trace messages in decidesemeai sgf file. */ 
     218void sgf_trace_semeai(const char *func, int str1, int str2, int move,  
     219                      int result1, int result2, const char *message); 
     220 
    193221 
    194222/* ================================================================ */ 
    195223 
     
    212240  do { \ 
    213241    tt_update(&ttable, routine, str, NO_MOVE, remaining_depth, NULL,\ 
    214242              value, 0, move);\ 
    215     if ((value) != 0 && (point) != 0) *(point) = (move); \ 
     243    if ((point) != NULL && (value) != 0) \ 
     244      *(point) = (move); \ 
    216245    return (value); \ 
    217246  } while (0) 
    218247 
     
    220249  do { \ 
    221250    tt_update(&ttable, routine, str1, str2, remaining_depth, NULL, \ 
    222251              value1, value2, move); \ 
    223     if ((value1) != 0 && (point) != 0) *(point) = (move); \ 
     252    if ((point) != NULL && (value1) != 0) \ 
     253      *(point) = (move); \ 
    224254    return; \ 
    225255  } while (0) 
    226256 
     
    228258  do { \ 
    229259    tt_update(&ttable, routine, str1, str2, remaining_depth, NULL,\ 
    230260              value, 0, move);\ 
    231     if ((value) != 0 && (point) != 0) *(point) = (move); \ 
     261    if ((point) != NULL && (value) != 0) \ 
     262      *(point) = (move); \ 
    232263    return (value); \ 
    233264  } while (0) 
    234265 
     
    236267  do { \ 
    237268    tt_update(&ttable, routine, str, NO_MOVE, remaining_depth, hash,\ 
    238269              value, 0, move);\ 
    239     if ((value) != 0 && (point) != 0) *(point) = (move); \ 
     270    if ((point) != NULL && (value) != 0) \ 
     271      *(point) = (move); \ 
    240272    return (value); \ 
    241273  } while (0) 
    242274 
     
    244276  do { \ 
    245277    tt_update(&ttable, routine, str, NO_MOVE, remaining_depth, NULL,\ 
    246278              value1, value2, move);\ 
    247     if ((value1) != 0 && (point) != 0) *(point) = (move); \ 
     279    if ((point) != NULL && (value1) != 0) \ 
     280      *(point) = (move); \ 
    248281    return (value1); \ 
    249282  } while (0) 
    250283 
  • gnugo/engine/clock.c

    RCS file: /sources/gnugo/gnugo/engine/clock.c,v
    retrieving revision 1.26
    diff -u -r1.26 clock.c