diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
|
old
|
new
|
|
| 131 | 131 | * is a defense version. |
| 132 | 132 | */ |
| 133 | 133 | #define DEFEND_TRY_MOVES(no_deep_branching, attack_hint) \ |
| | 134 | DEFEND_TRY_MOVES_LIMIT(no_deep_branching, attack_hint, WIN) |
| | 135 | |
| | 136 | /* Like DEFEND_TRY_MOVES but called when the best possible result is |
| | 137 | * known - we can finish trying moves earlier. |
| | 138 | */ |
| | 139 | #define DEFEND_TRY_MOVES_LIMIT(no_deep_branching, attack_hint, limit) \ |
| 134 | 140 | do { \ |
| 135 | 141 | int k; \ |
| 136 | 142 | \ |
| … |
… |
|
| 139 | 145 | int dpos = moves.pos[k]; \ |
| 140 | 146 | \ |
| 141 | 147 | if (komaster_trymove(dpos, color, moves.message[k], str, &ko_move,\ |
| 142 | | stackp <= ko_depth && savecode == 0)) { \ |
| | 148 | stackp <= ko_depth && !savecode)) { \ |
| 143 | 149 | int acode = do_attack(str, (attack_hint)); \ |
| 144 | 150 | popgo(); \ |
| 145 | 151 | \ |
| … |
… |
|
| 153 | 159 | savecode = KO_B; \ |
| 154 | 160 | } \ |
| 155 | 161 | } \ |
| 156 | | } \ |
| 157 | 162 | \ |
| 158 | | if ((no_deep_branching) && stackp >= branch_depth) \ |
| 159 | | RETURN_RESULT(savecode, savemove, move, "branching limit"); \ |
| | 163 | if (savecode == (limit)) \ |
| | 164 | RETURN_RESULT(savecode, savemove, move, "best defense"); \ |
| | 165 | \ |
| | 166 | if ((no_deep_branching) && stackp >= branch_depth) \ |
| | 167 | RETURN_RESULT(savecode, savemove, move, "branching limit"); \ |
| | 168 | } \ |
| 160 | 169 | } \ |
| 161 | 170 | \ |
| 162 | 171 | moves.num_tried = moves.num; \ |
| … |
… |
|
| 177 | 186 | \ |
| 178 | 187 | if ((board_ko_pos || !send_two_return_one(apos, other)) \ |
| 179 | 188 | && komaster_trymove(apos, other,moves.message[k],str,&ko_move,\ |
| 180 | | stackp <= ko_depth && savecode == 0)) { \ |
| | 189 | stackp <= ko_depth && !savecode)) { \ |
| 181 | 190 | int dcode = do_find_defense(str, (defense_hint)); \ |
| 182 | 191 | \ |
| 183 | 192 | if (REVERSE_RESULT(dcode) > savecode \ |
| 184 | 193 | && do_attack(str, NULL)) { \ |
| 185 | 194 | if (!ko_move) { \ |
| 186 | | if (dcode == 0) { \ |
| | 195 | if (!dcode) { \ |
| 187 | 196 | popgo(); \ |
| 188 | 197 | RETURN_RESULT(WIN, apos, move, "attack effective"); \ |
| 189 | 198 | } \ |
| … |
… |
|
| 198 | 207 | } \ |
| 199 | 208 | \ |
| 200 | 209 | popgo(); \ |
| 201 | | } \ |
| 202 | 210 | \ |
| 203 | | if ((no_deep_branching) && stackp >= branch_depth) \ |
| 204 | | RETURN_RESULT(savecode, savemove, move, "branching limit"); \ |
| | 211 | if ((no_deep_branching) && stackp >= branch_depth) \ |
| | 212 | RETURN_RESULT(savecode, savemove, move, "branching limit"); \ |
| | 213 | } \ |
| 205 | 214 | } \ |
| 206 | 215 | \ |
| 207 | 216 | moves.num_tried = moves.num; \ |
| … |
… |
|
| 1420 | 1429 | int savecode = 0; |
| 1421 | 1430 | int liberties; |
| 1422 | 1431 | int k; |
| | 1432 | int suggest_move; |
| 1423 | 1433 | |
| 1424 | 1434 | SETUP_TRACE_INFO("defend1", str); |
| 1425 | 1435 | reading_node_counter++; |
| … |
… |
|
| 1444 | 1454 | moves.message[0] = "liberty"; |
| 1445 | 1455 | moves.num = 1; |
| 1446 | 1456 | moves.num_tried = 0; |
| | 1457 | suggest_move = NO_MOVE; |
| 1447 | 1458 | |
| 1448 | 1459 | break_chain_moves(str, &moves); |
| 1449 | 1460 | set_up_snapback_moves(str, lib, &moves); |
| 1450 | 1461 | |
| 1451 | 1462 | order_moves(str, &moves, color, READ_FUNCTION_NAME, *move); |
| 1452 | | DEFEND_TRY_MOVES(0, NULL); |
| | 1463 | DEFEND_TRY_MOVES(0, &suggest_move); |
| 1453 | 1464 | |
| 1454 | 1465 | /* If the string is a single stone and a capture would give a ko, |
| 1455 | 1466 | * try to defend it with ko by backfilling or killing neighbors |
| … |
… |
|
| 1483 | 1494 | * (see trevord:700 for example, when these moves could be |
| 1484 | 1495 | * helpful). */ |
| 1485 | 1496 | if (!savecode && stackp <= break_chain_depth) { |
| 1486 | | int k; |
| 1487 | | |
| 1488 | 1497 | /* Find neighbors of group created by filling a ko, which |
| 1489 | 1498 | * have up to two liberties and aren't neighbors of a ko |
| 1490 | 1499 | * stone. |
| … |
… |
|
| 1497 | 1506 | popgo(); |
| 1498 | 1507 | |
| 1499 | 1508 | order_moves(str, &moves, color, READ_FUNCTION_NAME, *move); |
| 1500 | | |
| 1501 | | for (k = moves.num_tried; k < moves.num; k++) { |
| 1502 | | int dpos = moves.pos[k]; |
| 1503 | | if (komaster_trymove(dpos, color, moves.message[k], str, |
| 1504 | | &ko_move, stackp <= ko_depth)) { |
| 1505 | | int acode = do_attack(str, NULL); |
| 1506 | | popgo(); |
| 1507 | | CHECK_RESULT(savecode, savemove, acode, dpos, move, |
| 1508 | | "defense effective"); |
| 1509 | | |
| 1510 | | if (savecode) |
| 1511 | | break; |
| 1512 | | } |
| 1513 | | } |
| | 1509 | DEFEND_TRY_MOVES_LIMIT(0, &suggest_move, KO_B); |
| 1514 | 1510 | } |
| 1515 | 1511 | } |
| 1516 | 1512 | |