Index: engine/aftermath.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/aftermath.c,v retrieving revision 1.38 diff -u -r1.38 aftermath.c --- engine/aftermath.c 30 Dec 2002 20:11:09 -0000 1.38 +++ engine/aftermath.c 1 Jan 2003 12:33:38 -0000 @@ -27,7 +27,7 @@ #include #include "liberty.h" -SGFTree *aftermath_sgftree; +static SGFTree *aftermath_sgftree; /* Generate a move to definitely settle the position after the game * has been finished. The purpose of this is to robustly determine Index: engine/board.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/board.c,v retrieving revision 1.61 diff -u -r1.61 board.c --- engine/board.c 31 Dec 2002 15:33:48 -0000 1.61 +++ engine/board.c 1 Jan 2003 12:33:40 -0000 @@ -42,7 +42,7 @@ #define KOMASTER_SCHEME 5 #define KOMASTER_TRACE 0 -int tracing_inside_komaster = 0; +static int tracing_inside_komaster = 0; /* This can be used for internal checks w/in board.c that should @@ -430,7 +430,7 @@ /* KOMASTER_SCHEME 4 handles empty case differently from other schemes */ -int +static int komaster_is_empty(int komaster, int kom_pos) { if (KOMASTER_SCHEME == 4) @@ -441,7 +441,7 @@ /* KOMASTER_SCHEME 4 handles komaster interpretation differently from * other schemes */ -const char * +static const char * komaster_to_string(int komaster, int kom_pos) { #if KOMASTER_SCHEME == 4 @@ -956,6 +956,9 @@ play_move(int pos, int color) { ASSERT1(stackp == 0, pos); + ASSERT1(color == WHITE || color == BLACK, pos); + ASSERT1(pos == PASS_MOVE || ON_BOARD1(pos), pos); + ASSERT1(pos == PASS_MOVE || board[pos] == EMPTY, pos); if (move_history_pointer >= MAX_MOVE_HISTORY) { /* The move history is full. We resolve this by collapsing the @@ -4400,61 +4403,6 @@ code1(NORTH(move)); code1(EAST(move)); #endif -} - - -/* Reorientation of point (i, j) into (*ri, *rj). */ -void -rotate2(int i, int j, int *ri, int *rj, int rot) -{ - ASSERT2(rot >= 0 && rot < 8, i, j); - if (is_pass(POS(i, j))) { - *ri = i; - *rj = j; - return; - } - ASSERT_ON_BOARD2(i, j); - rotate(i, j, ri, rj, board_size, rot); -} - -/* Inverse reorientation of reorientation rot. */ -void -inv_rotate2(int i, int j, int *ri, int *rj, int rot) -{ - ASSERT2(rot >= 0 && rot < 8, i, j); - if (is_pass(POS(i, j))) { - *ri = i; - *rj = j; - return; - } - ASSERT_ON_BOARD2(i, j); - inv_rotate(i, j, ri, rj, board_size, rot); -} - -/* 1D board: return reorientation of point pos */ -int -rotate1(int pos, int rot) -{ - int i, j; - ASSERT1(rot >= 0 && rot < 8, pos); - if (is_pass(pos)) - return PASS_MOVE; - ASSERT_ON_BOARD1(pos); - rotate2(I(pos), J(pos), &i, &j, rot); - return POS(i, j); -} - -/* 1D board: return inverse reorientation of point pos */ -int -inv_rotate1(int pos, int rot) -{ - int i, j; - ASSERT1(rot >= 0 && rot < 8, pos); - if (is_pass(pos)) - return PASS_MOVE; - ASSERT_ON_BOARD1(pos); - inv_rotate2(I(pos), J(pos), &i, &j, rot); - return POS(i, j); } Index: engine/cache.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/cache.c,v retrieving revision 1.17 diff -u -r1.17 cache.c --- engine/cache.c 31 Dec 2002 12:41:08 -0000 1.17 +++ engine/cache.c 1 Jan 2003 12:33:40 -0000 @@ -31,7 +31,7 @@ #include "cache.h" #include "sgftree.h" -Hashtable *movehash; +static Hashtable *movehash; static int hashtable_init(Hashtable *table, int tablesize, int num_nodes, int num_results); Index: engine/cache.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/cache.h,v retrieving revision 1.21 diff -u -r1.21 cache.h --- engine/cache.h 30 Dec 2002 20:11:09 -0000 1.21 +++ engine/cache.h 1 Jan 2003 12:33:41 -0000 @@ -203,8 +203,8 @@ #define SETUP_TRACE_INFO2(name, str1, str2) \ const char *read_function_name = name; \ - int q1 = find_origin(str1); \ - int q2 = find_origin(str2); + int q1 = board[str1] == EMPTY ? str1 : find_origin(str1); \ + int q2 = board[str2] == EMPTY ? str2 : find_origin(str2); #else @@ -314,7 +314,7 @@ if (read_result) { \ rr_set_result_move(*(read_result), 0, 0); \ } \ - gprintf("%o%s %1m %d 0 0 0 ", read_function_name, q, stackp); \ + gprintf("%o%s %1m %d 0 0 ", read_function_name, q, stackp); \ dump_stack(); \ return 0; \ } while (0) @@ -325,7 +325,7 @@ if (read_result) { \ rr_set_result_move(*(read_result), (value), (move)); \ } \ - gprintf("%o%s %1m %d %d %d ", read_function_name, q, stackp, \ + gprintf("%o%s %1m %d %d %1m ", read_function_name, q, stackp, \ (value), (move)); \ dump_stack(); \ return (value); \ @@ -337,7 +337,7 @@ if (read_result) { \ rr_set_result_move2(*(read_result), (value_a), (value_b), (move)); \ } \ - gprintf("%o%s %1m %1m %d %d %d %d ", read_function_name, q1, q2, stackp, \ + gprintf("%o%s %1m %1m %d %d %d %1m ", read_function_name, q1, q2, stackp, \ (value_a), (value_b), (move)); \ dump_stack(); \ return; \ @@ -349,7 +349,7 @@ if (read_result) { \ rr_set_result_move(*(read_result), (value), (move)); \ } \ - gprintf("%o%s %1m %1m %d %d %d ", read_function_name, q1, q2, stackp, \ + gprintf("%o%s %1m %1m %d %d %1m ", read_function_name, q1, q2, stackp, \ (value), (move)); \ dump_stack(); \ return (value); \ Index: engine/clock.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/clock.c,v retrieving revision 1.13 diff -u -r1.13 clock.c --- engine/clock.c 16 Sep 2002 08:37:08 -0000 1.13 +++ engine/clock.c 1 Jan 2003 12:33:41 -0000 @@ -64,30 +64,30 @@ typedef struct { /* clock parameters */ - int clock_on; - int ready; - double main_time; - double byoyomi_time; /* zero if no byo-yomi */ - int byoyomi_stones; + int clock_on; + int ready; + double main_time; + double byoyomi_time; /* zero if no byo-yomi */ + int byoyomi_stones; /* clock status */ - double timer[3]; - double btimer[3]; - int byoyomi[3]; - int dead[3]; + double timer[3]; + double btimer[3]; + int byoyomi[3]; + int dead[3]; /* dates of each move */ - int moveno; /* invariant: COLOR(clk.moveno) = color of last move */ - double date[CLOCK_MAX_MOVES]; + int moveno; /* invariant: COLOR(clk.moveno) = color of last move */ + double date[CLOCK_MAX_MOVES]; /* adapative system parameters */ - int autolevel_on; - double min_level; - double level; - double levels[CLOCK_MAX_MOVES]; - double expected[CLOCK_MAX_MOVES]; - double max_level; - double error; /* time/move estimation error */ + int autolevel_on; + double min_level; + double level; + double levels[CLOCK_MAX_MOVES]; + double expected[CLOCK_MAX_MOVES]; + double max_level; + double error; /* time/move estimation error */ } gnugo_clock; static gnugo_clock clk; @@ -112,7 +112,7 @@ /* Echo a time value in STANDARD format */ static void -timeval_print(FILE* outfile, double tv) +timeval_print(FILE *outfile, double tv) { int min; double sec; @@ -136,7 +136,7 @@ void clock_init(int time, int byo_time, int byo_stones) { - int color; + int color; if (time > 0) { clk.main_time = time; @@ -398,7 +398,7 @@ /* * Check if a player is time over. */ -int +int clock_is_time_over(int color) { return clock_is_byoyomi(color) && clock_get_btime_left(color, NULL) <= 0; Index: engine/dragon.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/dragon.c,v retrieving revision 1.95 diff -u -r1.95 dragon.c --- engine/dragon.c 31 Dec 2002 15:33:48 -0000 1.95 +++ engine/dragon.c 1 Jan 2003 12:33:42 -0000 @@ -501,7 +501,7 @@ dragon[str].owl_second_defense_point = second_defense_point; } else - dragon[str].owl_threat_status = DEAD;; + dragon[str].owl_threat_status = DEAD; } else if (!acode) { int attack_point, second_attack_point; @@ -1380,7 +1380,7 @@ show_dragons(void) { static const char *snames[] = - {"dead", "alive", "critical", "unknown", "unchecked"}; + {"dead", "alive", "critical", "unknown", "unchecked"}; static const char *safety_names[] = {"dead", "alive", "critical", "inessential", "tactically dead", "weak", @@ -2035,11 +2035,11 @@ } -struct interpolation_data moyo_value2weakness = +static struct interpolation_data moyo_value2weakness = { 5, 0.0, 15.0, {1.0, 0.65, 0.3, 0.15, 0.05, 0.0}}; -struct interpolation_data escape_route2weakness = +static struct interpolation_data escape_route2weakness = { 5, 0.0, 25.0, {1.0, 0.6, 0.3, 0.1, 0.05, 0.0}}; -struct interpolation_data genus2weakness = +static struct interpolation_data genus2weakness = { 6, 0.0, 3.0, {1.0, 0.95, 0.8, 0.5, 0.2, 0.1, 0.0}}; float Index: engine/fuseki.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/fuseki.c,v retrieving revision 1.17 diff -u -r1.17 fuseki.c --- engine/fuseki.c 6 Dec 2002 23:31:42 -0000 1.17 +++ engine/fuseki.c 1 Jan 2003 12:33:42 -0000 @@ -47,9 +47,9 @@ #define LOWER_RIGHT 3 /* Global variables remembering which symmetries the position has. */ -int horizontally_symmetric; /* symmetry with respect to K column */ -int vertically_symmetric; /* symmetry with respect to 10 row */ -int diagonally_symmetric; /* ... with respect to diagonal from UR to LL */ +static int horizontally_symmetric; /* symmetry with respect to K column */ +static int vertically_symmetric; /* symmetry with respect to 10 row */ +static int diagonally_symmetric; /* with respect to diagonal from UR to LL */ /* This value must be lower than the value for an ongoing joseki. * (Gets multiplied with board_size / 19.) Index: engine/globals.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/globals.c,v retrieving revision 1.37 diff -u -r1.37 globals.c --- engine/globals.c 16 Nov 2002 00:30:25 -0000 1.37 +++ engine/globals.c 1 Jan 2003 12:33:42 -0000 @@ -72,7 +72,6 @@ int ko_depth; /* deep reading cut off */ int branch_depth; /* deep reading cut off */ int aa_depth; -int aa_threat_depth; int owl_distrust_depth; /* below this owl trusts the optics code */ int owl_branch_depth; /* below this owl tries only one variation */ int owl_reading_depth; /* owl does not read below this depth */ @@ -85,7 +84,6 @@ int mandated_ko_depth; /* deep reading cut off, mandated value */ int mandated_branch_depth; /* deep reading cut off, mandated value */ int mandated_aa_depth; -int mandated_aa_threat_depth = -1; int mandated_owl_distrust_depth; int mandated_owl_branch_depth; int mandated_owl_reading_depth; Index: engine/gnugo.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/gnugo.h,v retrieving revision 1.84 diff -u -r1.84 gnugo.h --- engine/gnugo.h 26 Dec 2002 04:33:48 -0000 1.84 +++ engine/gnugo.h 1 Jan 2003 12:33:42 -0000 @@ -77,12 +77,8 @@ #define KO_B 1 #define LOSE 0 -/* FIXME: should this be changed too or not ? */ -#if 1 -#define CUT 4 -#else +/* Used by break_through(). Must be different from 0 and WIN. */ #define CUT 2 -#endif /* Group statuses */ #define DEAD 0 @@ -304,7 +300,6 @@ extern int mandated_ko_depth; extern int mandated_branch_depth; extern int mandated_aa_depth; -extern int mandated_aa_threat_depth; extern int mandated_owl_distrust_depth; extern int mandated_owl_branch_depth; extern int mandated_owl_reading_depth; @@ -446,7 +441,7 @@ /* utils.c */ void change_dragon_status(int dr, int status); -void who_wins(int color, FILE* outfile); +void who_wins(int color, FILE *outfile); /* high-level routine to generate the best move for the given color */ int genmove(int *i, int *j, int color); Index: engine/influence.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v retrieving revision 1.72 diff -u -r1.72 influence.c --- engine/influence.c 21 Dec 2002 18:25:51 -0000 1.72 +++ engine/influence.c 1 Jan 2003 12:33:43 -0000 @@ -1128,13 +1128,13 @@ * sufficient to claim territory. The center values are more arbitrary * suspect to tuning. */ -struct interpolation_data min_infl_for_territory = +static struct interpolation_data min_infl_for_territory = { 6, 0.0, 24.0, { 6.0, 15.0, 26.0, 36.0, 45.0, 50.0, 55.0 }}; /* Determines the territory correction factor in dependence of the ratio * ( influence of stronger color / min_infl_for_territory(intersection)) */ -struct interpolation_data territory_correction = +static struct interpolation_data territory_correction = { 5, (float) 0.0, 1.0, {0.0, 0.25, 0.45, 0.65, 0.85, 1.0}}; static void @@ -1645,7 +1645,8 @@ if (move != -1 && (this_delta > 0.02 || -this_delta > 0.02)) - DEBUG(DEBUG_TERRITORY, " %1m: - %1m territory change %f (%f -> %f)\n", + DEBUG(DEBUG_TERRITORY, + " %1m: - %1m territory change %f (%f -> %f)\n", move, ii, this_delta, old_value, new_value); total_delta += this_delta; } Index: engine/liberty.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v retrieving revision 1.146 diff -u -r1.146 liberty.h --- engine/liberty.h 31 Dec 2002 12:41:09 -0000 1.146 +++ engine/liberty.h 1 Jan 2003 12:33:44 -0000 @@ -318,7 +318,7 @@ int *move); void store_persistent_reading_cache(int routine, int str, int result, int move, int nodes); -void delete_persistent_reading_entry(int index); +void delete_persistent_reading_cache_entry(int routine, int str); void reading_hotspots(float values[BOARDMAX]); void purge_persistent_owl_cache(void); void clear_persistent_owl_cache(void); @@ -350,8 +350,6 @@ int komaster, int kom_pos, int *new_komaster, int *new_kom_pos, int *is_conditional_ko, int consider_conditional_ko); -int komaster_is_empty(int komaster, int kom_pos); -const char *komaster_to_string(int komaster, int kom_pos); int does_capture_something(int pos, int color); void mark_string(int str, char mx[BOARDMAX], char mark); int move_in_stack(int pos, int cutoff); @@ -739,7 +737,6 @@ extern int fourlib_depth; /* deep reading cutoff */ extern int ko_depth; /* deep ko reading cutoff */ extern int aa_depth; /* deep global reading cutoff */ -extern int aa_threat_depth; extern int owl_distrust_depth; /* below this owl trusts the optics code */ extern int owl_branch_depth; /* below this owl tries only one variation */ extern int owl_reading_depth; /* owl does not read below this depth */ @@ -814,12 +811,12 @@ struct half_eye_data { - float value; /* Topological eye value. */ - char type; /* HALF_EYE or FALSE_EYE; */ - int num_attacks; /* number of attacking points */ - int attack_point[4]; /* the move to attack a topological halfeye */ + float value; /* Topological eye value. */ + char type; /* HALF_EYE or FALSE_EYE; */ + int num_attacks; /* number of attacking points */ + int attack_point[4]; /* the moves to attack a topological halfeye */ int num_defends; /* number of defending points */ - int defense_point[4]; /* the move to defend a topological halfeye */ + int defense_point[4]; /* the moves to defend a topological halfeye */ }; /* array of half-eye data */ Index: engine/matchpat.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/matchpat.c,v retrieving revision 1.47 diff -u -r1.47 matchpat.c --- engine/matchpat.c 31 Dec 2002 15:33:48 -0000 1.47 +++ engine/matchpat.c 1 Jan 2003 12:33:45 -0000 @@ -49,7 +49,6 @@ static void clear_profile(struct pattern *pattern) { - for (; pattern->patn; ++pattern) { pattern->hits = 0; pattern->reading_nodes = 0; @@ -225,7 +224,6 @@ static void fixup_patterns_for_board_size(struct pattern *pattern) { - for (; pattern->patn; ++pattern) if (pattern->edge_constraints != 0) { @@ -269,7 +267,6 @@ if (pattern->minj > pattern->maxj - (board_size-1)) pattern->minj = pattern->maxj - (board_size-1); } - } @@ -325,7 +322,8 @@ char goal[BOARDMAX]) { const int anchor_test = board[anchor] ^ color; /* see below */ - int m = I(anchor), n = J(anchor); + int m = I(anchor); + int n = J(anchor); int merged_val; /* Basic sanity checks. */ @@ -506,7 +504,7 @@ /* Make sure the grid optimisation wouldn't have rejected this pattern */ ASSERT2((merged_val & pattern->and_mask[ll]) - == pattern->val_mask[ll], m, n); + == pattern->val_mask[ll], m, n); #endif /* we don't trust the grid optimisation */ @@ -630,7 +628,7 @@ } -/* possibly cheeper to pass a little less recursively. +/* Possibly cheaper to pass a little less recursively. * Note: This could even just be static data, unless the * tree pattern matcher is itself used recursively.*/ struct rec_data { @@ -656,7 +654,7 @@ while (tnl) { struct tree_node *node = &(tnl->node); int x = m + node->x; - int y = n + node->y;; + int y = n + node->y; if (ON_BOARD2(x,y)) { int att = node->att; int point_color = BOARD(x,y); @@ -682,11 +680,11 @@ else { if (0) { gprintf(" P[%s, %d] matches at %m)\n", - pattern->name, - match->orientation, x, y); + pattern->name, match->orientation, x, y); } /* A match! */ - pdata->callback(POS(m, n), color, pattern, ll, pdata->callback_data); + pdata->callback(POS(m, n), color, pattern, ll, + pdata->callback_data); } match = match->next; @@ -768,7 +766,6 @@ #endif -# /**************************************************************************/ /* DFA matcher: */ @@ -871,8 +868,7 @@ /* copy the board */ for (i = 0; i < dfa_board_size; i++) for (j = 0; j < dfa_board_size; j++) - dfa_p[DFA_POS(i, j) + DFA_OFFSET] = - EXPECTED_COLOR(color, BOARD(i, j)); + dfa_p[DFA_POS(i, j) + DFA_OFFSET] = EXPECTED_COLOR(color, BOARD(i, j)); prepare_for_match(color); } @@ -1009,8 +1005,8 @@ static void check_pattern_light(int anchor, matchpat_callback_fn_ptr callback, int color, - struct pattern *pattern, int ll, void *callback_data, - char goal[BOARDMAX], int anchor_in_goal) + struct pattern *pattern, int ll, void *callback_data, + char goal[BOARDMAX], int anchor_in_goal) { int k; /* Iterate over elements of pattern */ int found_goal = 0; @@ -1061,8 +1057,7 @@ /* class check */ ASSERT1(dragon[pos].status < 4, anchor); - if ((pattern->class - & class_mask[dragon[pos].status][board[pos]]) != 0) + if ((pattern->class & class_mask[dragon[pos].status][board[pos]]) != 0) goto match_failed; } /* loop over elements */ @@ -1218,19 +1213,12 @@ int k; /* Iterate over elements of pattern */ /* We transform around the center point. */ int mid = POS((board_size-1)/2, (board_size-1)/2); - int pos; - int number_of_stones_on_board = 0; + int number_of_stones_on_board = stones_on_board(BLACK | WHITE); /* Basic sanity check. */ gg_assert(color != EMPTY); - gg_assert(board_size%2 == 1); + gg_assert(board_size % 2 == 1); - /* Count the number of stones on the board. */ - for (pos = BOARDMIN; pos < BOARDMAX; pos++) { - if (IS_STONE(board[pos])) - number_of_stones_on_board++; - } - /* Try each pattern - NULL pattern marks end of list. */ for (; pattern->patn; pattern++) { /* The number of stones on the board must be right. This is not Index: engine/move_reasons.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/move_reasons.c,v retrieving revision 1.106 diff -u -r1.106 move_reasons.c --- engine/move_reasons.c 30 Dec 2002 20:11:09 -0000 1.106 +++ engine/move_reasons.c 1 Jan 2003 12:33:46 -0000 @@ -45,9 +45,9 @@ /* Unordered sets (currently pairs) of move reasons / targets */ Reason_set either_data[MAX_EITHER]; -int next_either; +int next_either; Reason_set all_data[MAX_ALL]; -int next_all; +int next_all; /* Eye shapes */ int eyes[MAX_EYES]; @@ -77,9 +77,7 @@ void clear_move_reasons(void) { - int i; - int j; - int ii; + int pos; int k; next_reason = 0; next_connection = 0; @@ -88,43 +86,42 @@ next_eye = 0; next_lunch = 0; - for (i = 0; i < board_size; i++) - for (j = 0; j < board_size; j++) { - ii = POS(i, j); - - move[ii].value = 0.0; - move[ii].final_value = 0.0; - move[ii].additional_ko_value = 0.0; - move[ii].territorial_value = 0.0; - move[ii].strategical_value = 0.0; - move[ii].maxpos_shape = 0.0; - move[ii].numpos_shape = 0; - move[ii].maxneg_shape = 0.0; - move[ii].numneg_shape = 0; - move[ii].followup_value = 0.0; - move[ii].influence_followup_value = 0.0; - move[ii].reverse_followup_value = 0.0; - move[ii].secondary_value = 0.0; - move[ii].min_value = 0.0; - move[ii].max_value = HUGE_MOVE_VALUE; - move[ii].min_territory = 0.0; - move[ii].max_territory = HUGE_MOVE_VALUE; + for (pos = BOARDMIN; pos < BOARDMAX; pos++) { + if (ON_BOARD(pos)) { + move[pos].value = 0.0; + move[pos].final_value = 0.0; + move[pos].additional_ko_value = 0.0; + move[pos].territorial_value = 0.0; + move[pos].strategical_value = 0.0; + move[pos].maxpos_shape = 0.0; + move[pos].numpos_shape = 0; + move[pos].maxneg_shape = 0.0; + move[pos].numneg_shape = 0; + move[pos].followup_value = 0.0; + move[pos].influence_followup_value = 0.0; + move[pos].reverse_followup_value = 0.0; + move[pos].secondary_value = 0.0; + move[pos].min_value = 0.0; + move[pos].max_value = HUGE_MOVE_VALUE; + move[pos].min_territory = 0.0; + move[pos].max_territory = HUGE_MOVE_VALUE; for (k = 0; k < MAX_REASONS; k++) - move[ii].reason[k] = -1; - move[ii].move_safety = 0; - move[ii].worthwhile_threat = 0; - move[ii].randomness_scaling = 1.; + move[pos].reason[k] = -1; + move[pos].move_safety = 0; + move[pos].worthwhile_threat = 0; + move[pos].randomness_scaling = 1.0; /* The reason we assign a random number to each move immediately * is to avoid dependence on which moves are evaluated when it * comes to choosing between multiple moves of the same value. * In this way we can get consistent results for use in the * regression tests. */ - move[ii].random_number = gg_drand(); + move[pos].random_number = gg_drand(); /* Do not send away the points (yet). */ - replacement_map[ii] = NO_MOVE; + replacement_map[pos] = NO_MOVE; } + } } @@ -921,9 +918,9 @@ void add_either_move(int pos, int reason1, int target1, int reason2, int target2) { - int what1 = 0; - int what2 = 0; - int index; + int what1 = 0; + int what2 = 0; + int index; ASSERT_ON_BOARD1(target1); ASSERT_ON_BOARD1(target2); @@ -992,9 +989,9 @@ void add_all_move(int pos, int reason1, int target1, int reason2, int target2) { - int what1 = 0; - int what2 = 0; - int index; + int what1 = 0; + int what2 = 0; + int index; ASSERT_ON_BOARD1(target1); ASSERT_ON_BOARD1(target2); @@ -1830,7 +1827,7 @@ gprintf("Move at %1m captures something\n", pos); case YOUR_ATARI_ATARI_MOVE: - gprintf("Move at %1m defends threat to capture something\n", pos); + gprintf("Move at %1m defends against combination attack\n", pos); } } if (k > 0 && move[pos].move_safety == 0) Index: engine/owl.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v retrieving revision 1.134 diff -u -r1.134 owl.c --- engine/owl.c 31 Dec 2002 15:33:48 -0000 1.134 +++ engine/owl.c 1 Jan 2003 12:33:48 -0000 @@ -2309,7 +2309,8 @@ gprintf("owl: eyemin=%d matches_found=%d\n", *eyemin, matches_found); if (*eyemin >= matches_found) *eyemin -= matches_found; - else *eyemin = 0; + else + *eyemin = 0; sgf_dumptree = save_sgf_dumptree; count_variations = save_count_variations; @@ -2498,6 +2499,7 @@ find_half_and_false_eyes(color, eye, owl->half_eye, mw); set_eyevalue(probable_eyes, 0, 0, 0, 0); + /* This test must be conditioned on (m, n) being its own origin, * because some origins get moved during the topological eye * code. @@ -2553,8 +2555,7 @@ * 1. Due to the vital attack moves being able to later reduce * the *eyemin, we can't say that a certain *eyemin is * sufficient. - * 2. This part of the code is in now way time critical. If - * the life code is enabled, this may change. + * 2. This part of the code is in no way time critical. */ #if 0 /* Found two certain eyes---look no further. */ Index: engine/persistent.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/persistent.c,v retrieving revision 1.6 diff -u -r1.6 persistent.c --- engine/persistent.c 21 Dec 2002 00:19:50 -0000 1.6 +++ engine/persistent.c 1 Jan 2003 12:33:48 -0000 @@ -117,6 +117,7 @@ static int verify_stored_board(char board[BOARDMAX]); /* Tactical reading functions. */ +static int find_persistent_reading_cache_entry(int routine, int str); static void print_persistent_reading_cache_entry(int k); static void mark_string_hotspot_values(float values[BOARDMAX], int m, int n, float contribution); @@ -271,11 +272,11 @@ } -/* Look for a valid read result in the persistent cache. - * Return index of the entry found if there is a match, -1 if no match. +/* Locate a matching entry in the persistent reading cache. Return the + * entry number or -1 if none found. */ -int -search_persistent_reading_cache(int routine, int str, int *result, int *move) +static int +find_persistent_reading_cache_entry(int routine, int str) { int k; int r; @@ -305,36 +306,53 @@ if (!verify_stored_board(entry->board)) continue; - /* Matched alright. Increase score, fill in the answer, and return. */ - entry->score += entry->nodes; - if (result) - *result = entry->result; - if (move) - *move = entry->move; - ASSERT1(entry->result == 0 - || entry->move == NO_MOVE - || ON_BOARD(entry->move), - entry->move); - - if ((debug & DEBUG_READING_PERFORMANCE) - && entry->nodes >= MIN_READING_NODES_TO_REPORT) { - if (entry->result != 0) - gprintf("%o%s %1m = %d %1m, cached (%d nodes) ", - routine == ATTACK ? "attack" : "defend", - str, entry->result, entry->move, entry->nodes); - else - gprintf("%o%s %1m = %d, cached (%d nodes) ", - routine == ATTACK ? "attack" : "defend", - str, entry->result, entry->nodes); - dump_stack(); - } - return k; } - + return -1; } +/* Look for a valid read result in the persistent cache. + * Return 1 if found, 0 otherwise. + */ +int +search_persistent_reading_cache(int routine, int str, int *result, int *move) +{ + int k; + struct reading_cache *entry; + + k = find_persistent_reading_cache_entry(routine, str); + if (k == -1) + return 0; + + /* Match found. Increase score and fill in the answer. */ + entry = &(persistent_reading_cache[k]); + entry->score += entry->nodes; + if (result) + *result = entry->result; + if (move) + *move = entry->move; + ASSERT1(entry->result == 0 + || entry->move == NO_MOVE + || ON_BOARD(entry->move), + entry->move); + + if ((debug & DEBUG_READING_PERFORMANCE) + && entry->nodes >= MIN_READING_NODES_TO_REPORT) { + if (entry->result != 0) + gprintf("%o%s %1m = %d %1m, cached (%d nodes) ", + routine == ATTACK ? "attack" : "defend", + str, entry->result, entry->move, entry->nodes); + else + gprintf("%o%s %1m = %d, cached (%d nodes) ", + routine == ATTACK ? "attack" : "defend", + str, entry->result, entry->nodes); + dump_stack(); + } + + return 1; +} + /* Store a new read result in the persistent cache. */ void @@ -484,13 +502,16 @@ persistent_reading_cache_size++; } -/*delete an entry from the cache, given its index*/ +/* Delete an entry from the cache, if it's there. */ void -delete_persistent_reading_entry(int index) +delete_persistent_reading_cache_entry(int routine, int str) { - gg_assert(index >= 0 && index < persistent_reading_cache_size); - persistent_reading_cache[index] - = persistent_reading_cache[--persistent_reading_cache_size]; + int k = find_persistent_reading_cache_entry(routine, find_origin(str)); + while (k != -1) { + persistent_reading_cache[k] + = persistent_reading_cache[--persistent_reading_cache_size]; + k = find_persistent_reading_cache_entry(routine, find_origin(str)); + } } Index: engine/printutils.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v retrieving revision 1.31 diff -u -r1.31 printutils.c --- engine/printutils.c 31 Dec 2002 15:33:48 -0000 1.31 +++ engine/printutils.c 1 Jan 2003 12:33:49 -0000 @@ -44,7 +44,7 @@ */ static void -vgprintf(FILE* outputfile, const char *fmt, va_list ap) +vgprintf(FILE *outputfile, const char *fmt, va_list ap) { if (fmt[0] == '%' && fmt[1] == 'o') fmt += 2; /* cancel indent */ Index: engine/reading.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v retrieving revision 1.94 diff -u -r1.94 reading.c --- engine/reading.c 22 Dec 2002 20:17:43 -0000 1.94 +++ engine/reading.c 1 Jan 2003 12:33:51 -0000 @@ -248,7 +248,7 @@ return 0; origin = find_origin(str); - if (search_persistent_reading_cache(ATTACK, origin, &result, &the_move) != -1) { + if (search_persistent_reading_cache(ATTACK, origin, &result, &the_move)) { if (move) *move = the_move; return result; @@ -311,7 +311,7 @@ origin = find_origin(str); if (search_persistent_reading_cache(FIND_DEFENSE, origin, - &result, &the_move) != -1) { + &result, &the_move)) { if (move) *move = the_move; return result; @@ -374,33 +374,20 @@ if (acode != 0) { dcode = find_defense(str, &dpos); - /* If find_defense() says the string is safe as is, we believe - * this in favor of attack()'s opinion. Actually this is probably - * incorrect, but we can't easily find a defense point to return. + /* If find_defense() says the string is safe as is, contradicting + * the opinion of attack(), we remove the corresponding entries + * from the persistent cache and try again. */ if (dcode == WIN && dpos == NO_MOVE) { - int ai, di; - ai = search_persistent_reading_cache(ATTACK, find_origin(str), - NULL, NULL); - di = search_persistent_reading_cache(FIND_DEFENSE, find_origin(str), - NULL, NULL); - while (ai != -1) { - delete_persistent_reading_entry(ai); - ai = search_persistent_reading_cache(ATTACK, find_origin(str), - NULL, NULL); - } - while (di != -1) { - delete_persistent_reading_entry(di); - di = search_persistent_reading_cache(FIND_DEFENSE, find_origin(str), - NULL, NULL); - } + delete_persistent_reading_cache_entry(ATTACK, str); + delete_persistent_reading_cache_entry(FIND_DEFENSE, str); acode = attack(str, &apos); if (acode != 0) dcode = find_defense(str, &dpos); } } - gg_assert(!((acode != 0) && (dcode == WIN && dpos == NO_MOVE))); + ASSERT1(!(acode != 0 && dcode == WIN && dpos == NO_MOVE), str); if (attack_code) *attack_code = acode; @@ -1172,7 +1159,7 @@ for (k = 0; k < liberties; k++) { int apos = libs2[k]; if ((liberties == 1 || !is_self_atari(apos, other)) - && trymove(apos, color, "attack1-C", str, komaster, kom_pos)) { + && trymove(apos, color, "defend1-C", str, komaster, kom_pos)) { int acode = do_attack(str, NULL, komaster, kom_pos); popgo(); CHECK_RESULT(savecode, savemove, acode, apos, move, "backfilling"); Index: engine/score.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/score.c,v retrieving revision 1.16 diff -u -r1.16 score.c --- engine/score.c 4 Sep 2002 07:23:46 -0000 1.16 +++ engine/score.c 1 Jan 2003 12:33:51 -0000 @@ -490,8 +490,10 @@ else l = u; - if (upper) *upper = u; - if (lower) *lower = l; + if (upper) + *upper = u; + if (lower) + *lower = l; return (u + l) / 2; } Index: engine/utils.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v retrieving revision 1.62 diff -u -r1.62 utils.c --- engine/utils.c 15 Nov 2002 11:15:42 -0000 1.62 +++ engine/utils.c 1 Jan 2003 12:33:52 -0000 @@ -556,7 +556,6 @@ #define AA_DEPTH 6 -#define AA_THREAT_DEPTH 3 /* Pattern based reading */ #define OWL_DISTRUST_DEPTH 6 @@ -615,14 +614,10 @@ urgent = 0; /* Atari-atari depth levels are unchanged only between levels 7/8: */ - if (level >= 8) { + if (level >= 8) aa_depth = gg_max(0, AA_DEPTH + (level - 10)); - aa_threat_depth = gg_max(0, AA_THREAT_DEPTH + (level - 10)); - } - else { + else aa_depth = gg_max(0, AA_DEPTH + (level - 9)); - aa_threat_depth = gg_max(0, AA_THREAT_DEPTH + (level - 9)); - } /* Exceptions: * fourlib_depth: This is constant from levels 7 to 10. @@ -671,8 +666,6 @@ branch_depth = mandated_branch_depth; if (mandated_aa_depth != -1) aa_depth = mandated_aa_depth; - if (mandated_aa_threat_depth != -1) - aa_threat_depth = mandated_aa_threat_depth; if (mandated_owl_distrust_depth != -1) owl_distrust_depth = mandated_owl_distrust_depth; if (mandated_owl_branch_depth != -1) @@ -880,6 +873,7 @@ int ii; int trouble = 0; int dragon_analyzed[4] = {0, 0, 0, 0}; + int current_verbose = verbose; for (k = 0; k < 4; k++) { int bpos = move + delta[k]; @@ -920,8 +914,7 @@ if (acode == 0) { verbose = save_verbose; TRACE("Dragon at %1m becomes attackable.\n", bpos); - if (verbose > 0) - verbose--; + verbose = current_verbose; *return_value += 2.0 * dragon[bpos].effective_size; if (safe_stones) for (ii = first_worm_in_dragon(bpos); ii != NO_MOVE; @@ -931,8 +924,7 @@ else if (acode == LOSS) { verbose = save_verbose; TRACE("Dragon at %1m becomes attackable.\n", bpos); - if (verbose > 0) - verbose--; + verbose = current_verbose; if (kworm == move) { int l; /* the worm origin was messed by our own move */ Index: engine/value_moves.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v retrieving revision 1.74 diff -u -r1.74 value_moves.c --- engine/value_moves.c 30 Dec 2002 20:11:09 -0000 1.74 +++ engine/value_moves.c 1 Jan 2003 12:33:54 -0000 @@ -1061,7 +1061,6 @@ if (return_value < 0.0) return_value = 0.0; - return return_value; } Index: engine/worm.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/worm.c,v retrieving revision 1.49 diff -u -r1.49 worm.c --- engine/worm.c 21 Dec 2002 18:25:52 -0000 1.49 +++ engine/worm.c 1 Jan 2003 12:33:54 -0000 @@ -751,7 +751,7 @@ for (k = 0; k < MAX_TACTICAL_POINTS; k++) { worm[str].attack_codes[k] = 0; worm[str].attack_points[k] = 0; - worm[str].defense_codes[k] = 0; + worm[str].defense_codes[k] = 0; worm[str].defense_points[k] = 0; } propagate_worm(str); @@ -1765,8 +1765,8 @@ void report_worm(int m, int n) { - int pos = POS(m, n); - int i; + int pos = POS(m, n); + int i; if (board[pos] == EMPTY) { gprintf("There is no worm at %1m\n", pos); Index: interface/play_gtp.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/play_gtp.c,v retrieving revision 1.108 diff -u -r1.108 play_gtp.c --- interface/play_gtp.c 31 Dec 2002 12:41:09 -0000 1.108 +++ interface/play_gtp.c 1 Jan 2003 12:33:55 -0000 @@ -29,7 +29,6 @@ #include "interface.h" #include "liberty.h" #include "gtp.h" -#include "random.h" #include "gg_utils.h" /* Internal state that's not part of the engine. */ Index: patterns/extract_fuseki.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/extract_fuseki.c,v retrieving revision 1.14 diff -u -r1.14 extract_fuseki.c --- patterns/extract_fuseki.c 6 Dec 2002 23:31:43 -0000 1.14 +++ patterns/extract_fuseki.c 1 Jan 2003 12:33:57 -0000 @@ -1210,9 +1210,11 @@ /* Tell the user everything worked out fine */ fprintf(stderr, "The pattern database was produced with no errors.\n"); - for (i = 0; i < number_of_games; i++) { - if (unused_games[i]) number_of_unused_games++; - } + + for (i = 0; i < number_of_games; i++) + if (unused_games[i]) + number_of_unused_games++; + fprintf(stderr, "Out of %d games, %d were not used.\n", number_of_games, number_of_unused_games); } Index: patterns/helpers.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/helpers.c,v retrieving revision 1.44 diff -u -r1.44 helpers.c --- patterns/helpers.c 22 Dec 2002 20:07:13 -0000 1.44 +++ patterns/helpers.c 1 Jan 2003 12:33:58 -0000 @@ -749,8 +749,7 @@ move, worma, wormb); return; } - if (trymove(move, color, "suggest_attack_either_move", worma, - EMPTY, NO_MOVE)) { + if (trymove(move, color, "test_attack_either_move", worma, EMPTY, NO_MOVE)) { if (board[worma] == OTHER_COLOR(color) && board[wormb] == OTHER_COLOR(color)) { if (!defend_both(worma, wormb)) Index: patterns/mkpat.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v retrieving revision 1.104 diff -u -r1.104 mkpat.c --- patterns/mkpat.c 31 Dec 2002 15:33:48 -0000 1.104 +++ patterns/mkpat.c 1 Jan 2003 12:33:59 -0000 @@ -1262,7 +1262,7 @@ */ sprintf(pattern, "(%s + %d)", prefix, patno); - switch(number_of_params) { + switch (number_of_params) { case 0: code_pos += sprintf(code_pos, autohelper_functions[funcno].code, pattern); Index: utils/gg_utils.h =================================================================== RCS file: /cvsroot/gnugo/gnugo/utils/gg_utils.h,v retrieving revision 1.12 diff -u -r1.12 gg_utils.h --- utils/gg_utils.h 19 Nov 2002 16:32:35 -0000 1.12 +++ utils/gg_utils.h 1 Jan 2003 12:34:04 -0000 @@ -83,8 +83,8 @@ /* prototypes for basic reorientation functions */ -void rotate(int i, int j, int *ri, int *rj, int bs, int rot); -void inv_rotate(int i, int j, int *ri, int *rj, int bs, int rot); +void rotate(int i, int j, int *ri, int *rj, int bs, int rot); +void inv_rotate(int i, int j, int *ri, int *rj, int bs, int rot); #endif /* _GG_UTILS_H_ */