Ticket #148: cleanup.diff
| File cleanup.diff, 12.4 kB (added by draqo, 20 months ago) |
|---|
-
config.vcin
diff -N -r -u -X .ignore gnugo-copy/config.vcin gnugo/config.vcin
old new 19 19 #define DEFAULT_LEVEL 10 20 20 21 21 /* Default hash table size in megabytes */ 22 #define DEFAULT_MEMORY 822 #define DEFAULT_MEMORY -1 23 23 24 24 /* Compile support for GTP communication over TCP/IP channel. */ 25 25 #define ENABLE_SOCKET_SUPPORT 1 -
engine/board.c
diff -N -r -u -X .ignore gnugo-copy/engine/board.c gnugo/engine/board.c
old new 693 693 return 0; 694 694 695 695 /* 4. Test if the location is the ko point. */ 696 if (pos == board_ko_pos) {696 if (pos == board_ko_pos) { 697 697 /* The ko position is guaranteed to have all neighbors of the 698 698 * same color, or off board. If that color is the same as the 699 699 * move the ko is being filled, it is always allowed. This 700 700 * could be tested with has_neighbor() but here a faster test 701 701 * suffices. 702 702 */ 703 if (board[WEST(pos)] == OTHER_COLOR(color)704 || board[EAST(pos)] == OTHER_COLOR(color))705 *ko_move_allowed = 1;706 }703 if (board[WEST(pos)] == OTHER_COLOR(color) 704 || board[EAST(pos)] == OTHER_COLOR(color)) 705 *ko_move_allowed = 1; 706 } 707 707 708 708 /* 5. Test for suicide. */ 709 if (is_suicide(pos, color)) {709 if (is_suicide(pos, color)) { 710 710 *ko_move_allowed = 0; 711 711 return 0; 712 712 } … … 1758 1758 int 1759 1759 findlib(int str_pos, int maxlib, int *libs) 1760 1760 { 1761 int k;1762 1761 int liberties; 1763 1762 int to_copy; 1764 1763 int str_nr; … … 1778 1777 liberties = string[str_nr].liberties; 1779 1778 to_copy = maxlib > liberties ? liberties : maxlib; 1780 1779 1781 if (to_copy <= MAX_LIBERTIES) {1780 if (to_copy <= MAX_LIBERTIES) 1782 1781 /* The easy case, it suffices to copy liberty locations from the 1783 1782 * incrementally updated list. 1784 1783 */ 1785 for (k = 0; k < to_copy; k++) 1786 libs[k] = string_libs[str_nr].list[k]; 1787 } 1784 memcpy(libs, string_libs[str_nr].list, to_copy * sizeof(libs[0])); 1788 1785 else { 1789 1786 /* The harder case, where we have to traverse the stones in the 1790 1787 * string. We don't have to check explicitly if we are back to 1791 1788 * the start of the chain since we will run out of liberties 1792 1789 * before that happens. 1793 1790 */ 1794 int pos, checked_pos; 1791 int pos; 1792 int checked_pos; 1793 int k; 1794 1795 1795 liberty_mark++; 1796 1796 for (k = 0, pos = FIRST_STONE(str_nr); 1797 1797 k < to_copy; -
engine/liberty.h
diff -N -r -u -X .ignore gnugo-copy/engine/liberty.h gnugo/engine/liberty.h
old new 2 2 * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * 3 3 * http://www.gnu.org/software/gnugo/ for more information. * 4 4 * * 5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006*5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 * 6 6 * by the Free Software Foundation. * 7 7 * * 8 8 * This program is free software; you can redistribute it and/or * … … 337 337 void movelist_change_point(int move, int code, int max_points, 338 338 int points[], int codes[]); 339 339 340 /* worm.c */ 341 void change_tactical_point(int str, int move, int code, 342 int points[], int codes[]); 343 340 344 /* surround.c */ 341 345 int compute_surroundings(int pos, int apos, int showboard, 342 346 int *surround_size); -
engine/movelist.c
diff -N -r -u -X .ignore gnugo-copy/engine/movelist.c gnugo/engine/movelist.c
old new 2 2 * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * 3 3 * http://www.gnu.org/software/gnugo/ for more information. * 4 4 * * 5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006*5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 * 6 6 * by the Free Software Foundation. * 7 7 * * 8 8 * This program is free software; you can redistribute it and/or * … … 29 29 #include "liberty.h" 30 30 31 31 32 static void move list_sort_points(int max_points, int points[], int codes[]);33 static void swap_points_and_codes(int points[], int codes[], int m, int n);32 static void move_up_list(int points[], int codes[], int inserted_index); 33 static void move_down_list(int last_index, int points[], int codes[], int changed_index); 34 34 35 35 36 36 /* Return the code for the move if it is known. … … 69 69 70 70 /* Yes, we do. */ 71 71 if (k < max_points) { 72 if (code s[k] <= code)72 if (code >= codes[k]) 73 73 return; /* Old news. */ 74 74 75 75 codes[k] = code; 76 movelist_sort_points(max_points, points, codes); 77 return; 76 move_down_list(k, points, codes, k); 78 77 } 79 80 78 /* This tactical point is new to us. */ 81 if (code > codes[max_points - 1]) { 82 points[max_points - 1] = move; 83 codes[max_points - 1] = code; 84 movelist_sort_points(max_points, points, codes); 79 else { 80 k--; /* last index */ 81 if (code <= codes[k]) 82 return; /* Too bad move to store. */ 83 84 points[k] = move; 85 codes[k] = code; 86 move_up_list(points, codes, k); 85 87 } 86 88 } 87 89 88 90 89 /* Sort the tactical points so we have it sorted in falling order on 90 * the code values. 91 * 92 * We use shaker sort because we prefer a stable sort and in all use 93 * cases we can expect it to suffice with one turn through the outer 94 * loop. 91 /* Sort the changed tactical point. We set it to the higher value, so 92 * we just have to move it up the table. 95 93 */ 96 94 97 95 static void 98 move list_sort_points(int max_points, int points[], int codes[])96 move_up_list(int points[], int codes[], int inserted_index) 99 97 { 100 int start = 0; 101 int end = max_points - 1; 102 int new_start; 103 int new_end; 104 int k; 105 106 while (start < end) { 107 new_start = end; 108 for (k = end; k > start; k--) 109 if (codes[k] > codes[k-1]) { 110 swap_points_and_codes(points, codes, k, k-1); 111 new_start = k; 112 } 113 start = new_start; 114 new_end = start; 115 for (k = start; k < end - 1; k++) 116 if (codes[k] < codes[k+1]) { 117 swap_points_and_codes(points, codes, k, k+1); 118 new_end = k; 119 } 120 end = new_end; 98 int new_index; 99 int inserted_code = codes[inserted_index]; 100 101 for (new_index = inserted_index; new_index > 0; new_index--) { 102 if (inserted_code <= codes[new_index - 1]) 103 break; 104 } 105 106 if (new_index != inserted_index) { 107 int tmp = points[inserted_index]; 108 memmove(points + new_index + 1, points + new_index, 109 (inserted_index - new_index) * sizeof(int)); 110 points[new_index] = tmp; 111 112 memmove(codes + new_index + 1, codes + new_index, 113 (inserted_index - new_index) * sizeof(int)); 114 codes[new_index] = inserted_code; 121 115 } 122 116 } 123 117 118 119 /* Sort the changed tactical point. We set it to the lower value, so 120 * we just have to move it down the table. 121 */ 122 124 123 static void 125 swap_points_and_codes(int points[], int codes[], int m, int n)124 move_down_list(int last_index, int points[], int codes[], int changed_index) 126 125 { 127 int tmp = points[m]; 128 points[m] = points[n]; 129 points[n] = tmp; 130 tmp = codes[m]; 131 codes[m] = codes[n]; 132 codes[n] = tmp; 126 int new_index; 127 int inserted_code = codes[changed_index]; 128 129 for (new_index = changed_index; new_index < last_index; new_index++) { 130 if (inserted_code >= codes[new_index + 1]) 131 break; 132 } 133 134 if (new_index != changed_index) { 135 int tmp = points[changed_index]; 136 memmove(points + changed_index, points + changed_index + 1, 137 (new_index - changed_index) * sizeof(int)); 138 points[new_index] = tmp; 139 140 memmove(codes + changed_index, codes + changed_index + 1, 141 (new_index - changed_index) * sizeof(int)); 142 codes[new_index] = inserted_code; 143 } 133 144 } 134 145 135 146 -
engine/persistent.c
diff -N -r -u -X .ignore gnugo-copy/engine/persistent.c gnugo/engine/persistent.c
old new 2 2 * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * 3 3 * http://www.gnu.org/software/gnugo/ for more information. * 4 4 * * 5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006*5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 * 6 6 * by the Free Software Foundation. * 7 7 * * 8 8 * This program is free software; you can redistribute it and/or * … … 445 445 print_persistent_cache_entry(entry); 446 446 } 447 447 /* FIXME: This is an ugly hack. */ 448 if ( cache->name == "reading cache"448 if (strcmp(cache->name, "reading cache") == 0 449 449 && (debug & DEBUG_READING_PERFORMANCE) 450 450 && entry->cost >= MIN_READING_NODES_TO_REPORT) { 451 451 if (entry->result != 0) -
engine/reading.c
diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
old new 2 2 * This is GNU Go, a Go program. Contact gnugo@gnu.org, or see * 3 3 * http://www.gnu.org/software/gnugo/ for more information. * 4 4 * * 5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 and 2006*5 * Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 and 2007 * 6 6 * by the Free Software Foundation. * 7 7 * * 8 8 * This program is free software; you can redistribute it and/or * … … 1055 1055 if (trymove(aa, other, "attack_threats-A", str)) { 1056 1056 int acode = attack(str, NULL); 1057 1057 if (acode != 0) 1058 movelist_change_point(aa, acode, max_points, moves, codes);1058 change_tactical_point(str, aa, acode, moves, codes); 1059 1059 popgo(); 1060 1060 } 1061 1061 … … 1071 1071 if (trymove(bb, other, "attack_threats-B", str)) { 1072 1072 int acode = attack(str, NULL); 1073 1073 if (acode != 0) 1074 movelist_change_point(bb, acode, max_points, moves, codes);1074 change_tactical_point(str, bb, acode, moves, codes); 1075 1075 popgo(); 1076 1076 } 1077 1077 } … … 1117 1117 else 1118 1118 acode = attack(str, NULL); 1119 1119 if (acode != 0) 1120 movelist_change_point(bb, acode, max_points, moves, codes);1120 change_tactical_point(str, bb, acode, moves, codes); 1121 1121 popgo(); 1122 1122 } 1123 1123 } -
engine/worm.c
diff -N -r -u -X .ignore gnugo-copy/engine/worm.c gnugo/engine/worm.c
old new 37 37 static void find_worm_attacks_and_defenses(void); 38 38 static void find_worm_threats(void); 39 39 static int find_lunch(int str, int *lunch); 40 static void change_tactical_point(int str, int move, int code,41 int points[MAX_TACTICAL_POINTS],42 int codes[MAX_TACTICAL_POINTS]);43 40 static void propagate_worm2(int str); 44 41 static int genus(int str); 45 42 static void markcomponent(int str, int pos, int mg[BOARDMAX]); … … 758 755 continue; 759 756 760 757 TRACE("considering attack of %1m\n", str); 761 /* Initialize all relevant fields at once. */762 for (k = 0; k < MAX_TACTICAL_POINTS; k++) {763 worm[str].attack_codes[k] = 0;764 worm[str].attack_points[k] = 0;765 worm[str].defense_codes[k] = 0;766 worm[str].defense_points[k] = 0;767 }768 propagate_worm(str);769 758 770 759 acode = attack(str, &attack_point); 771 760 if (acode != 0) { … … 1182 1171 * change_defense_threat(). 1183 1172 */ 1184 1173 1185 staticvoid1174 void 1186 1175 change_tactical_point(int str, int move, int code, 1187 1176 int points[MAX_TACTICAL_POINTS], 1188 1177 int codes[MAX_TACTICAL_POINTS]) -
makevcdist.pl
diff -N -r -u -X .ignore gnugo-copy/makevcdist.pl gnugo/makevcdist.pl
old new 9 9 RESIGNATION_ALLOWED => 1, 10 10 HASHING_SCHEME => 2, 11 11 DEFAULT_LEVEL => 10, 12 DEFAULT_MEMORY => 8,12 DEFAULT_MEMORY => -1, 13 13 ENABLE_SOCKET_SUPPORT => 1, 14 14 ALTERNATE_CONNECTIONS => 1, 15 15 SEMEAI_NODE_LIMIT => 500,
