Ticket #171: defend1.patch
| File defend1.patch, 4.1 KB (added by draqo, 5 years ago) |
|---|
-
engine/reading.c
diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
old new 1452 1452 DEFEND_TRY_MOVES(0, NULL); 1453 1453 1454 1454 /* If the string is a single stone and a capture would give a ko, 1455 * try to defend it with ko by backfilling. 1455 * try to defend it with ko by backfilling or killing neighbors 1456 * (only KO_B result is possible). 1456 1457 * If we don't find any defending move return LOSE and not KO_B, 1457 1458 * because we'll lose this ko sooner or later. 1458 1459 */ 1459 if (stackp <= backfill_depth 1460 && countstones(str) == 1 1460 if (!savecode && countstones(str) == 1 1461 1461 && is_ko(lib, other, NULL)) { 1462 int ko_move; 1462 1463 int libs2[6]; 1463 1464 liberties = approxlib(lib, color, 6, libs2); 1464 if (liberties <= 5) { 1465 if (stackp <= backfill_depth) { 1466 if (liberties > 6) 1467 liberties = 6; 1465 1468 for (k = 0; k < liberties; k++) { 1466 1469 int apos = libs2[k]; 1467 1470 if ((liberties == 1 || !is_self_atari(apos, other)) 1468 && trymove(apos, color, "defend1-C", str)) { 1471 && komaster_trymove(apos, color, "defend1-C", str, 1472 &ko_move, stackp <= ko_depth)) { 1469 1473 int acode = do_attack(str, NULL); 1470 1474 popgo(); 1471 1475 CHECK_RESULT(savecode, savemove, acode, apos, move, "backfilling"); 1476 if (savecode) 1477 break; 1478 } 1479 } 1480 } 1481 1482 /* If we still haven't found defense, try to kill neighbors 1483 * (see trevord:700 for example, when these moves could be 1484 * helpful). */ 1485 if (!savecode && stackp <= break_chain_depth) { 1486 int k; 1487 1488 /* Find neighbors of group created by filling a ko, which 1489 * have up to two liberties and aren't neighbors of a ko 1490 * stone. 1491 */ 1492 trymove(lib, color, "defend1-D", str); 1493 1494 break_chain_moves(lib, &moves); 1495 break_chain2_efficient_moves(lib, &moves); 1496 1497 popgo(); 1498 1499 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; 1472 1512 } 1473 1513 } 1474 1514 } -
engine/utils.c
diff -N -r -u -X .ignore gnugo-copy/engine/utils.c gnugo/engine/utils.c
old new 1955 1955 (*num_my_stones) -= new_stones; 1956 1956 1957 1957 for (k = 0; k < num_my_libs; k++) { 1958 if (*num_libs == maxlibs) 1959 break; 1958 1960 if (ml[my_libs[k]]) 1959 1961 continue; 1960 1962 ml[my_libs[k]] = 1; 1961 1963 if (do_add && (liberty_cap == 0 || num_my_libs <= liberty_cap)) { 1962 1964 libs[*num_libs] = my_libs[k]; 1963 1965 (*num_libs)++; 1964 if (*num_libs == maxlibs)1965 break;1966 1966 } 1967 1967 } 1968 1968 } -
regression/13x13c.tst
diff -N -r -u -X .ignore gnugo-copy/regression/13x13c.tst gnugo/regression/13x13c.tst
old new 65 65 #? [G13]* 66 66 67 67 # G13 is still sufficient to get a seki. 68 # 69 # After N6 the game could be: 70 # N7 K12 G13 J13 N5 M3 L13 N4 H13 N6 71 # and now white has to win extremely unforable 3 stage ko, 72 # so this move could be acceptable - G13 and K12 leads to 73 # the similar position - so the best move is N5, which 74 # doesn't allow white making a ko. 68 75 loadsgf games/kgs/tournament11/CrazyStone-GNU.sgf 87 69 76 43 reg_genmove black 70 #? [G13|K12 ]77 #? [G13|K12|N6|N5] -
regression/owl.tst
diff -N -r -u -X .ignore gnugo-copy/regression/owl.tst gnugo/regression/owl.tst
old new 104 104 loadsgf games/incident161.sgf 42 105 105 28 owl_attack B8 106 106 #? [1 C7] 107 # after E9 C7 F9 there is a seki 107 108 29 owl_defend B8 108 #? [1 C7]109 #? [1 (C7|E9)] 109 110 30 owl_attack D8 110 111 #? [1 C7] 112 # same as 29 111 113 31 owl_defend D8 112 #? [1 C7]114 #? [1 (C7|E9)] 113 115 114 116 # incident 189 115 117 loadsgf games/incident189.sgf 180
