Index: engine/genmove.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/genmove.c,v retrieving revision 1.29 diff -u -r1.29 genmove.c --- engine/genmove.c 11 Feb 2002 04:07:12 -0000 1.29 +++ engine/genmove.c 22 Feb 2002 08:18:22 -0000 @@ -557,13 +557,13 @@ if (spent > slowest_time) { slowest_time = spent; slowest_move = *move; - slowest_movenum = movenum+1; + slowest_movenum = movenum + 1; } if (*move == NO_MOVE) { gprintf("\nSLOWEST MOVE: %d at %1m ", slowest_movenum, slowest_move); fprintf(stderr, "(%.2f seconds)\n", slowest_time); fprintf(stderr, "\nAVERAGE TIME: %.2f seconds per move\n", - total_time/movenum); + total_time / movenum); fprintf(stderr, "\nTOTAL TIME: %.2f seconds\n", total_time); Index: engine/influence.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/influence.c,v retrieving revision 1.38 diff -u -r1.38 influence.c --- engine/influence.c 21 Feb 2002 16:52:42 -0000 1.38 +++ engine/influence.c 22 Feb 2002 08:18:23 -0000 @@ -720,7 +720,6 @@ || (color == BLACK && q->black_strength[x][y] == 0.0)) return; /* Match failed. */ } - } } } @@ -1888,10 +1887,10 @@ followup_value = -followup_value; } - if (( new_value - old_value > 0.02) - || ( old_value - new_value > 0.02)) + if (new_value - old_value > 0.02 + || old_value - new_value > 0.02) DEBUG(DEBUG_TERRITORY, " %1m: - %m territory change %f (%f -> %f)\n", - pos, i, j, new_value - old_value, old_value, new_value); + pos, i, j, new_value - old_value, old_value, new_value); delta += new_value - old_value; if (experimental_influence) followup_delta += followup_value - new_value; Index: engine/owl.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/owl.c,v retrieving revision 1.61 diff -u -r1.61 owl.c --- engine/owl.c 22 Feb 2002 02:20:48 -0000 1.61 +++ engine/owl.c 22 Feb 2002 08:18:23 -0000 @@ -650,7 +650,7 @@ owla, owlb, vital_defensive_moves[k].value); owl_add_move(moves, vital_defensive_moves[k].pos, - move_value,"vital defensive move", + move_value, "vital defensive move", vital_defensive_moves[k].same_dragon); } for (k = 0; @@ -1062,7 +1062,8 @@ EMPTY, NO_MOVE)) { if (safe_move(liberty, other)) result = fill; - else result = find_semeai_backfilling_move(worm, liberty); + else + result = find_semeai_backfilling_move(worm, liberty); popgo(); } } Index: engine/printutils.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/printutils.c,v retrieving revision 1.16 diff -u -r1.16 printutils.c --- engine/printutils.c 20 Feb 2002 18:03:55 -0000 1.16 +++ engine/printutils.c 22 Feb 2002 08:18:23 -0000 @@ -338,9 +338,8 @@ static char buf[BOARDSIZE][5]; if (!init) { int pos; - for (pos =0; pos < BOARDSIZE; pos++) { + for (pos = 0; pos < BOARDSIZE; pos++) location_to_buffer(pos, buf[pos]); - } init = 1; } ASSERT1(pos >= 0 && pos < BOARDSIZE, pos); @@ -441,7 +440,7 @@ { if (result == 0) return "0"; - else if (result== KO_A) + else if (result == KO_A) return "KO_A"; else if (result == KO_B) return "KO_B"; Index: engine/reading.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v retrieving revision 1.49 diff -u -r1.49 reading.c --- engine/reading.c 9 Feb 2002 16:11:29 -0000 1.49 +++ engine/reading.c 22 Feb 2002 08:18:24 -0000 @@ -49,7 +49,7 @@ scores[num_moves] = score;\ (num_moves)++;\ }\ - } while (0) \ + } while (0) #define REMOVE_CANDIDATE_MOVE(move, moves, scores, num_moves)\ do {\ @@ -64,7 +64,7 @@ break;\ }\ }\ - } while (0) \ + } while (0) /* @@ -1332,9 +1332,9 @@ if (moves[s] == 0) break; } - if (already_tried || s == MAX_MOVES) { + if (already_tried || s == MAX_MOVES) continue; - } + if (!is_self_atari(xpos, color) && trymove(xpos, color, "defend2-D", str, komaster, kom_pos)) { int acode = do_attack(str, NULL, komaster, kom_pos); @@ -2010,7 +2010,7 @@ break; } if (already_tried) - continue; + continue; /* Use approxlib() to test for trivial capture. */ if (approxlib(lib, other, 3, NULL) > 2) @@ -2691,7 +2691,7 @@ static void reading_attack_callback(int m, int n, int color, - struct pattern *pattern, int ll, void *data) + struct pattern *pattern, int ll, void *data) { int k; int move; @@ -2706,16 +2706,13 @@ pattern->name, move, count_variations); for (k = 0; k < MAX_READING_MOVES; k++) { - if (moves[k].pos) { - if (moves[k].pos == move) { - if (value <= moves[k].value) { - return; - } else { - break; - } - } - } else { + if (moves[k].pos == NO_MOVE) break; + if (moves[k].pos == move) { + if (value <= moves[k].value) + return; + else + break; } } @@ -2742,17 +2739,16 @@ return; for (k = 0; k < MAX_READING_MOVES; k++) { - if (moves[k].pos) { + if (moves[k].pos != NO_MOVE) { if (moves[k].pos == move) { - if (value <= moves[k].value) { + if (value <= moves[k].value) return; - } else { + else break; - } } - } else { - break; } + else + break; } for (k = 0; k < MAX_READING_MOVES; k++) { @@ -2760,14 +2756,16 @@ moves[k].pos = move; moves[k].value = value; moves[k].name = pattern->name; - moves[++k].pos = 0; + moves[++k].pos = NO_MOVE; break; } + if (moves[k].value < value) { int j = k; - while (moves[j].pos && moves[j].pos != move) + while (moves[j].pos != NO_MOVE && moves[j].pos != move) j++; - if (moves[j].pos) {j--;} + if (moves[j].pos != NO_MOVE) + j--; for (; j >= k; j--) { moves[j+1].pos = moves[j].pos; moves[j+1].value = moves[j].value; @@ -2783,13 +2781,16 @@ static void -set_goal_worm(int str, int value, char goal[BOARDMAX]) { +set_goal_worm(int str, int value, char goal[BOARDMAX]) +{ int k; int color = board[str]; - if (goal[str]) { return; } + if (goal[str]) + return; + goal[str] = value; for (k = 0; k < 4; k++) { - int pos = str+delta[k]; + int pos = str + delta[k]; if (board[pos] == color) { set_goal_worm(pos, value, goal); } @@ -2797,25 +2798,27 @@ } static void -set_larger_goal_worm(int str, char goal[BOARDMAX]) { +set_larger_goal_worm(int str, char goal[BOARDMAX]) +{ int k; int color = board[str]; /*Note: over-ride possible 3 values here.*/ - if (goal[str]==1) { return; } + if (goal[str] == 1) + return; + goal[str] = 1; for (k = 0; k < 4; k++) { - int pos = str+delta[k]; - if (board[pos] == color) { + int pos = str + delta[k]; + if (board[pos] == color) set_larger_goal_worm(pos, goal); - } else if (stackp < (depth+4) && board[pos] == OTHER_COLOR(color)) { + else if (stackp < (depth+4) && board[pos] == OTHER_COLOR(color)) set_goal_worm(pos, 2, goal); - } else if (stackp < (12+2) && board[pos] == EMPTY) { + else if (stackp < (12+2) && board[pos] == EMPTY) { int j; for (j = 0; j < 4; j++) { int jpos = pos + delta[j]; - if (board[jpos] == color) { - set_goal_worm(jpos,3,goal); - } + if (board[jpos] == color) + set_goal_worm(jpos, 3, goal); } } } @@ -2824,22 +2827,21 @@ static int do_attack_pat(int str, int *move, int komaster, int kom_pos) { - char goal[BOARDMAX]; struct reading_move_data moves[MAX_READING_MOVES]; int k; int color = board[str]; int other = OTHER_COLOR(color); int best_defense = WIN; - int best_move = 0; - int new_komaster = 0; - int new_kom_pos = 0; + int best_move = NO_MOVE; + int new_komaster = EMPTY; + int new_kom_pos = NO_MOVE; int ko_move = 0; int libs; SETUP_TRACE_INFO("attack_pat", str); - ASSERT1(move != 0, str); + ASSERT1(move != NULL, str); if (count_variations > 15000) { SGFTRACE(0,0, "Way too many variations"); @@ -2853,27 +2855,30 @@ return 0; } - if (libs == 1) { + if (libs == 1) return attack1(str, move, komaster, kom_pos); - } - if (libs == 4) { + if (libs == 4) return attack4(str, move, komaster, kom_pos); - } memset(goal, 0, BOARDMAX); reading_node_counter++; set_larger_goal_worm(str, goal); moves[0].pos = 0; - if (verbose > 1) {TRACE("Stack: "); dump_stack();} + if (verbose > 1) { + TRACE("Stack: "); + dump_stack(); + } rgoal = goal; goallib = libs; - matchpat_goal_anchor(reading_attack_callback, other, &read_attack_db, moves, goal, 1); + matchpat_goal_anchor(reading_attack_callback, other, &read_attack_db, + moves, goal, 1); if (verbose > 1) { TRACE("Moves (variation %d): ", count_variations); for (k = 0; k < MAX_READING_MOVES; k++) { - if (!moves[k].pos) { break; } + if (!moves[k].pos) + break; TRACE("%o%s@%1m ", moves[k].name, moves[k].pos); } TRACE("\n"); @@ -2886,9 +2891,12 @@ gg_snprintf(buf, 500, "Move order for %s: %n", read_function_name, &chars); pos = buf + chars; for (k = 0; k < MAX_READING_MOVES; k++) { - if (!moves[k].pos) { break; } - sprintf(pos, "%c%d (%s-%d) %n", J(moves[k].pos) + 'A' + (J(moves[k].pos) >= 8), - board_size - I(moves[k].pos), moves[k].name, moves[k].value, &chars); + if (!moves[k].pos) + break; + sprintf(pos, "%c%d (%s-%d) %n", + J(moves[k].pos) + 'A' + (J(moves[k].pos) >= 8), + board_size - I(moves[k].pos), moves[k].name, moves[k].value, + &chars); pos += chars; } sgftreeAddComment(sgf_dumptree, NULL, buf); @@ -2908,7 +2916,7 @@ TRACE("Attacking %1m at %1m (Pattern %s)\n", str, moves[k].pos, moves[k].name); if (stackp > board_size * 2 && ko_move) { - /* trying to avoid komaster problems - this shouldn't be necessary*/ + /* trying to avoid komaster problems - this shouldn't be necessary */ continue; } defense = do_find_defense(str, 0, new_komaster, new_kom_pos); @@ -2923,7 +2931,8 @@ "Attack successful - no defense, ko sub-attack"); return WIN; } - } else { + } + else { attack = 0; SGFTRACE(moves[k].pos, 0, "Too deep, aborting attack"); } @@ -2938,22 +2947,24 @@ best_move = moves[k].pos; best_defense = defense; } - } else { + } + else { popgo(); SGFTRACE(moves[k].pos, WIN, "Attack successful - no defense."); *move = moves[k].pos; return WIN; } - } else if (defense < best_defense) { + } + else if (defense < best_defense) { /* May need to check ko_move in this case, too */ best_move = moves[k].pos; best_defense = defense; } popgo(); } - } else { - break; } + else + break; } SGFTRACE(best_move, WIN - best_defense, "No good attack."); @@ -5205,7 +5216,7 @@ for (k = 0; k < num_moves; k++) { int ko_capture; - xpos= moves[k]; + xpos = moves[k]; if (in_list(xpos, num_forbidden_moves, forbidden_moves)) continue; /* To avoid loops with double ko, we do not allow any ko captures, Index: engine/semeai.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/semeai.c,v retrieving revision 1.36 diff -u -r1.36 semeai.c --- engine/semeai.c 20 Feb 2002 18:02:22 -0000 1.36 +++ engine/semeai.c 22 Feb 2002 08:18:24 -0000 @@ -226,22 +226,28 @@ } } /* loop over neighbor dragons */ if (pass == 0 && semeai_found) { + int a_matcher_status; + int b_matcher_status; + if (a_best_status != DEAD && a_worst_status == DEAD) a_status = CRITICAL; - else a_status = a_worst_status; + else + a_status = a_worst_status; + if (b_best_status != DEAD && b_worst_status == DEAD) b_status = CRITICAL; - else b_status = b_worst_status; - { - int a_matcher_status = a_status; - int b_matcher_status = b_status; - if (a_matcher_status == ALIVE_IN_SEKI) - a_matcher_status = ALIVE; - if (b_matcher_status == ALIVE_IN_SEKI) - b_matcher_status = ALIVE; - update_status(apos, a_matcher_status, a_status); - update_status(bpos, b_matcher_status, b_status); - } + else + b_status = b_worst_status; + + a_matcher_status = a_status; + b_matcher_status = b_status; + if (a_matcher_status == ALIVE_IN_SEKI) + a_matcher_status = ALIVE; + if (b_matcher_status == ALIVE_IN_SEKI) + b_matcher_status = ALIVE; + + update_status(apos, a_matcher_status, a_status); + update_status(bpos, b_matcher_status, b_status); } } } Index: engine/utils.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/utils.c,v retrieving revision 1.38 diff -u -r1.38 utils.c --- engine/utils.c 9 Feb 2002 16:11:29 -0000 1.38 +++ engine/utils.c 22 Feb 2002 08:18:24 -0000 @@ -421,18 +421,16 @@ /* FIXED: tm - returns ko results correctly (3.1.22) */ if (do_attack) { - if (board[ypos] == EMPTY || board[zpos] == EMPTY) { + if (board[ypos] == EMPTY || board[zpos] == EMPTY) success = WIN; - } else { + else success = attack_either(ypos, zpos); - } } else { - if (board[ypos] == EMPTY || board[zpos] == EMPTY) { + if (board[ypos] == EMPTY || board[zpos] == EMPTY) success = 0; - } else { + else success = defend_both(ypos, zpos); - } } #if 0 @@ -500,20 +498,16 @@ #endif if (do_connect) { - if (board[ypos] == EMPTY || board[zpos] == EMPTY) { + if (board[ypos] == EMPTY || board[zpos] == EMPTY) success = 0; - } else { - int move; - success = string_connect(ypos, zpos, &move); - } + else + success = string_connect(ypos, zpos, NULL); } else { - if (board[ypos] == EMPTY || board[zpos] == EMPTY) { + if (board[ypos] == EMPTY || board[zpos] == EMPTY) success = WIN; - } else { - int move; - success = disconnect(ypos, zpos, &move); - } + else + success = disconnect(ypos, zpos, NULL); } #if 0 Index: engine/value_moves.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/engine/value_moves.c,v retrieving revision 1.13 diff -u -r1.13 value_moves.c --- engine/value_moves.c 5 Feb 2002 18:41:30 -0000 1.13 +++ engine/value_moves.c 22 Feb 2002 08:18:25 -0000 @@ -970,8 +970,9 @@ impact = impact_values[safety1][safety2]; else if (margin > 20.0) impact = cautious_impact_values[safety1][safety2]; - else impact = 0.05*margin*cautious_impact_values[safety1][safety2] - + (1-0.05*margin)*impact_values[safety1][safety2]; + else + impact = (0.05 * margin * cautious_impact_values[safety1][safety2] + + (1 - 0.05 * margin) * impact_values[safety1][safety2]); /* Trying to connect an inessential string to something else with a @@ -1620,8 +1621,9 @@ if (move_reasons[r].type == ATTACK_MOVE_GOOD_KO || move_reasons[r].type == DEFEND_MOVE_GOOD_KO) { ko_factor = 0.6; - } else if (move_reasons[r].type == ATTACK_MOVE_BAD_KO - || move_reasons[r].type == DEFEND_MOVE_BAD_KO) { + } + else if (move_reasons[r].type == ATTACK_MOVE_BAD_KO + || move_reasons[r].type == DEFEND_MOVE_BAD_KO) { ko_factor = 0.4; } this_value = 10.0 * (worm[aa].cutstone2 - 1) * ko_factor; @@ -2315,7 +2317,7 @@ static void reevaluate_ko_threats(int ko_move, int color) { - int ko_stone = 0; + int ko_stone = NO_MOVE; int opp_ko_move; int m, n; int pos; @@ -2354,7 +2356,7 @@ int r = move[pos].reason[k]; if (r < 0) break; - if (! (move_reasons[r].type & THREAT_BIT)) + if (!(move_reasons[r].type & THREAT_BIT)) continue; switch (move_reasons[r].type) { case ATTACK_THREAT: Index: interface/play_ascii.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/interface/play_ascii.c,v retrieving revision 1.11 diff -u -r1.11 play_ascii.c --- interface/play_ascii.c 31 Jan 2002 08:27:18 -0000 1.11 +++ interface/play_ascii.c 22 Feb 2002 08:18:25 -0000 @@ -1160,7 +1160,10 @@ } -/* Convert a coordinate pair from ascii text to two integers. */ +/* Convert a coordinate pair from ascii text to two integers. + * FIXME: Check that this function is indeed equivalent to + * string_to_location() and then replace it. + */ static int ascii2pos(Position *pos, char *line, int *i, int *j) { Index: patterns/extract_fuseki.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/extract_fuseki.c,v retrieving revision 1.11 diff -u -r1.11 extract_fuseki.c --- patterns/extract_fuseki.c 19 Dec 2001 21:18:38 -0000 1.11 +++ patterns/extract_fuseki.c 22 Feb 2002 08:18:25 -0000 @@ -130,11 +130,11 @@ /* This is defined in engine/matchpat.c */ extern const int transformations[8][2][2]; -#define TRANSFORM(i,j,ti,tj,trans) \ -do { \ - *ti = transformations[trans][0][0] * (i) + transformations[trans][0][1] * (j); \ - *tj = transformations[trans][1][0] * (i) + transformations[trans][1][1] * (j); \ -} while (0) +#define TRANSFORM(i, j, ti, tj, trans) \ + do { \ + *ti = transformations[trans][0][0] * (i) + transformations[trans][0][1] * (j); \ + *tj = transformations[trans][1][0] * (i) + transformations[trans][1][1] * (j); \ + } while (0) /* A situation is the combination of a board position and the move to Index: patterns/mkpat.c =================================================================== RCS file: /cvsroot/gnugo/gnugo/patterns/mkpat.c,v retrieving revision 1.54 diff -u -r1.54 mkpat.c --- patterns/mkpat.c 21 Feb 2002 16:52:42 -0000 1.54 +++ patterns/mkpat.c 22 Feb 2002 08:18:25 -0000 @@ -1595,7 +1595,8 @@ if (ifc == MAX_INPUT_FILE_NAMES) { fprintf(stderr, "Error : Too many input files; %s", gg_optarg); exit(1); - } else { + } + else { input_file_names[ifc++] = gg_optarg; input_file_names[ifc] = 0; } @@ -1668,9 +1669,9 @@ current_file = ""; } else { - if (input_file_names[ifc] == 0) { + if (input_file_names[ifc] == 0) break; - } else { + else { if ((input_FILE = fopen(input_file_names[ifc], "r")) == NULL) { fprintf(stderr, "Error: Cannot open file %s\n", input_file_names[ifc]);