Ticket #170: does_defend.patch
| File does_defend.patch, 4.8 KB (added by draqo, 5 years ago) |
|---|
-
engine/utils.c
diff -N -r -u -X .ignore gnugo-copy/engine/utils.c gnugo/engine/utils.c
old new 133 133 134 134 135 135 /* 136 * does_defend(move, str) returns t rue if the move at (move)137 * defends (str). This means that it defends the string, and that138 * (str) can be captured if no defense is made.139 * 140 * FIXME: Make does_defend() ko aware like does_attack().136 * does_defend(move, str) returns the result code for a defense on the 137 * string 'str' by the move 'move'. However, if the move does not 138 * improve the defense result compared to tenuki, 0 is returned. If the 139 * string (str) can't be captured if no defense is made, 0 is returned 140 * too. 141 141 */ 142 142 143 143 int … … 147 147 int other = OTHER_COLOR(color); 148 148 int result = 0; 149 149 int spos = NO_MOVE; 150 int acode; 150 151 151 if (!attack(str, &spos)) 152 acode = attack(str, &spos); 153 if (!acode) 152 154 return 0; 153 155 154 156 gg_assert(spos != NO_MOVE); 155 157 156 158 if (trymove(move, color, "does_defend-A", str)) { 157 i f (!attack(str, NULL)) {158 result = 1;159 increase_depth_values();159 int acode2 = attack(str, NULL); 160 if (acode2 < acode) { 161 result = REVERSE_RESULT(acode2); 160 162 if (trymove(spos, other, "does_defend-B", str)) { 161 if (!board[str] || !find_defense(str, NULL)) 163 increase_depth_values(); 164 if (board[str]) { 165 int new_result = find_defense(str, NULL); 166 if (new_result < result) 167 result = new_result; 168 } 169 else 162 170 result = 0; 163 171 popgo(); 172 decrease_depth_values(); 164 173 } 165 decrease_depth_values();166 174 } 167 175 popgo(); 168 176 } -
engine/worm.c
diff -N -r -u -X .ignore gnugo-copy/engine/worm.c gnugo/engine/worm.c
old new 397 397 * incorrectly, which may lead to some confusion later. 398 398 */ 399 399 400 /* First look for vertical neighbors. */401 400 for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 402 if (IS_STONE(board[pos]) 403 && IS_STONE(board[SOUTH(pos)]) 404 && !is_same_worm(pos, SOUTH(pos))) { 405 if (worm[pos].attack_codes[0] != 0 406 && worm[SOUTH(pos)].attack_codes[0] != 0) { 407 if (worm[pos].defense_codes[0] == 0 408 && does_defend(worm[SOUTH(pos)].attack_points[0], pos)) { 409 /* FIXME: need to check ko relationship here */ 410 change_defense(pos, worm[SOUTH(pos)].attack_points[0], WIN); 411 } 412 if (worm[SOUTH(pos)].defense_codes[0] == 0 413 && does_defend(worm[pos].attack_points[0], SOUTH(pos))) { 414 /* FIXME: need to check ko relationship here */ 415 change_defense(SOUTH(pos), worm[pos].attack_points[0], WIN); 416 } 417 } 418 } 419 } 420 421 /* Then look for horizontal neighbors. */ 422 for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 423 if (IS_STONE(board[pos]) 424 && IS_STONE(board[EAST(pos)]) 425 && !is_same_worm(pos, EAST(pos))) { 426 if (worm[pos].attack_codes[0] != 0 427 && worm[EAST(pos)].attack_codes[0] != 0) { 428 if (worm[pos].defense_codes[0] == 0 429 && does_defend(worm[EAST(pos)].attack_points[0], pos)) { 430 /* FIXME: need to check ko relationship here */ 431 change_defense(pos, worm[EAST(pos)].attack_points[0], WIN); 401 int neighbor_pos; 402 if (IS_STONE(board[pos])) { 403 /* First look for vertical neighbors, then horizontal. */ 404 for (str = 0; str < 2; str++) { 405 if (str) 406 neighbor_pos = EAST(pos); 407 else 408 neighbor_pos = SOUTH(pos); 409 410 if (IS_STONE(board[neighbor_pos]) 411 && !is_same_worm(pos, neighbor_pos)) { 412 if (!worm[pos].defense_codes[0] 413 && worm[neighbor_pos].attack_codes[0]) { 414 dcode = does_defend(worm[neighbor_pos].attack_points[0], pos); 415 if (dcode) 416 change_defense(pos, worm[neighbor_pos].attack_points[0], dcode); 417 } 418 if (!worm[neighbor_pos].defense_codes[0] 419 && worm[pos].attack_codes[0]) { 420 dcode = does_defend(worm[pos].attack_points[0], neighbor_pos); 421 if (dcode) 422 change_defense(neighbor_pos, worm[pos].attack_points[0], dcode); 423 } 432 424 } 433 if (worm[EAST(pos)].defense_codes[0] == 0434 && does_defend(worm[pos].attack_points[0], EAST(pos))) {435 /* FIXME: need to check ko relationship here */436 change_defense(EAST(pos), worm[pos].attack_points[0], WIN);437 425 } 438 426 } 439 427 } -
patterns/barriers.db
diff -N -r -u -X .ignore gnugo-copy/patterns/barriers.db gnugo/patterns/barriers.db
old new 1892 1892 cDf 1893 1893 bae 1894 1894 1895 ;safe_omove(a) 1895 ;safe_omove(a)>KO_B 1896 1896 ;&& (o_somewhere(e) || oplay_attack(a,e,e)) 1897 1897 ;&& oplay_defend_both(a,b,c,b,D)!=WIN 1898 1898 >return (!xplay_attack(a,f) && (o_somewhere(e) || (!xplay_attack(e,f)))); … … 1911 1911 eFho 1912 1912 cab? 1913 1913 1914 ;safe_omove(a) 1914 ;safe_omove(a)>KO_B 1915 1915 ;&& (o_somewhere(b) || oplay_attack(a,b,b)) 1916 1916 ;&& oplay_defend_both(a,c,d,e,F,G)!=WIN 1917 1917 >return (!xplay_attack(a,h));
