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  
    14521452  DEFEND_TRY_MOVES(0, NULL); 
    14531453 
    14541454  /* 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). 
    14561457   * If we don't find any defending move return LOSE and not KO_B, 
    14571458   * because we'll lose this ko sooner or later. 
    14581459   */ 
    1459   if (stackp <= backfill_depth 
    1460       && countstones(str) == 1 
     1460  if (!savecode && countstones(str) == 1 
    14611461      && is_ko(lib, other, NULL)) { 
     1462    int ko_move; 
    14621463    int libs2[6]; 
    14631464    liberties = approxlib(lib, color, 6, libs2); 
    1464     if (liberties <= 5) { 
     1465    if (stackp <= backfill_depth) { 
     1466      if (liberties > 6) 
     1467        liberties = 6; 
    14651468      for (k = 0; k < liberties; k++) { 
    14661469        int apos = libs2[k]; 
    14671470        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)) { 
    14691473          int acode = do_attack(str, NULL); 
    14701474          popgo(); 
    14711475          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; 
    14721512        } 
    14731513      } 
    14741514    } 
  • engine/utils.c

    diff -N -r -u -X .ignore gnugo-copy/engine/utils.c gnugo/engine/utils.c
    old new  
    19551955      (*num_my_stones) -= new_stones; 
    19561956 
    19571957    for (k = 0; k < num_my_libs; k++) { 
     1958      if (*num_libs == maxlibs) 
     1959        break; 
    19581960      if (ml[my_libs[k]]) 
    19591961        continue; 
    19601962      ml[my_libs[k]] = 1; 
    19611963      if (do_add && (liberty_cap == 0 || num_my_libs <= liberty_cap)) { 
    19621964        libs[*num_libs] = my_libs[k]; 
    19631965        (*num_libs)++; 
    1964         if (*num_libs == maxlibs) 
    1965           break; 
    19661966      } 
    19671967    } 
    19681968  } 
  • regression/13x13c.tst

    diff -N -r -u -X .ignore gnugo-copy/regression/13x13c.tst gnugo/regression/13x13c.tst
    old new  
    6565#? [G13]* 
    6666 
    6767# 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. 
    6875loadsgf games/kgs/tournament11/CrazyStone-GNU.sgf 87 
    697643 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  
    104104loadsgf games/incident161.sgf 42 
    10510528 owl_attack B8 
    106106#? [1 C7] 
     107# after E9 C7 F9 there is a seki 
    10710829 owl_defend B8 
    108 #? [1 C7] 
     109#? [1 (C7|E9)] 
    10911030 owl_attack D8 
    110111#? [1 C7] 
     112# same as 29 
    11111331 owl_defend D8 
    112 #? [1 C7] 
     114#? [1 (C7|E9)] 
    113115 
    114116# incident 189 
    115117loadsgf games/incident189.sgf 180