Ticket #199: gunnar_7_12.7c.diff

File gunnar_7_12.7c.diff, 3.0 kB (added by gunnar, 7 months ago)

Don't amalgamate dragons over three liberty strings or a specific class of two liberty strings.

  • patterns/conn.db

     
    629629Bc 
    630630dA 
    631631 
    632 ;((attack(A) && lib(A) < 4) || (attack(B) && lib(B) < 4)) 
     632;((attack(A) && !distrust_tactics_helper(A)) 
     633; || (attack(B) && !distrust_tactics_helper(B))) 
    633634;&& !disconnect_helper(c,d) 
    634635 
    635636 
  • patterns/helpers.c

     
    808808} 
    809809 
    810810 
     811/* This helper is intended to detect semeai kind of positions where 
     812 * the tactical reading can't be trusted enough to allow amalgamation 
     813 * over presumably tactically dead strings. 
     814 * 
     815 * It has turned out to be best not to trust tactical reading of three 
     816 * and four liberty strings at all. Not trusting two liberty strings 
     817 * leads to an underamalgamation and unnecessarily many dragons on the 
     818 * board. Therefore we try to detect two liberty strings with an 
     819 * enclosed nakade, which after capturing leads to an unreliable 
     820 * reading at three or four liberties. 
     821 * 
     822 * More specifically we check whether the string has a neighbor with 
     823 * the following properties: 
     824 * 1. At least three stones in size. 
     825 * 2. All its liberties are common liberties with the string. 
     826 * 3. It has no second order liberties. 
     827 * 4. Its liberties are adjacent to no other strings than itself and 
     828 *    the primary string. 
     829 * 
     830 * If we find such a neighbor 1 is returned, otherwise 0. 
     831 */ 
     832int distrust_tactics_helper(int str) 
     833{ 
     834  int color = board[str]; 
     835  int adj; 
     836  int adjs[MAXCHAIN]; 
     837  int k; 
     838  int r; 
     839  int s; 
     840  int lib = countlib(str); 
     841 
     842  ASSERT1(IS_STONE(board[str]), str); 
     843   
     844  if (lib > 2) 
     845    return 1; 
     846  else if (lib == 1) 
     847    return 0; 
     848   
     849  adj = chainlinks3(str, adjs, lib); 
     850  for (r = 0; r < adj; r++) { 
     851    int nakade = 1; 
     852    int adjlib; 
     853    int adjlibs[3]; 
     854    if (countstones(adjs[r]) < 3) 
     855      continue; 
     856    adjlib = findlib(adjs[r], 3, adjlibs); 
     857    for (s = 0; s < adjlib; s++) { 
     858      int str_found = 0; 
     859      for (k = 0; k < 4; k++) { 
     860        int pos = adjlibs[s] + delta[k]; 
     861        if (board[pos] == EMPTY 
     862            && !liberty_of_string(pos, adjs[r])) 
     863          nakade = 0; 
     864        else if (board[pos] == color) { 
     865          if (same_string(pos, str)) 
     866            str_found = 1; 
     867          else 
     868            nakade = 0; 
     869        } 
     870        else if (board[pos] == OTHER_COLOR(color) 
     871                 && !same_string(pos, adjs[r])) 
     872          nakade = 0; 
     873      } 
     874      if (!str_found) 
     875        nakade = 0; 
     876    } 
     877    if (nakade) 
     878      return 1; 
     879  } 
     880   
     881  return 0; 
     882} 
     883 
    811884/* 
    812885 * LOCAL Variables: 
    813886 * tab-width: 8 
  • patterns/patterns.h

     
    326326int adjacent_to_defendable_stone_in_atari(int str); 
    327327void backfill_replace(int move, int str); 
    328328int break_mirror_helper(int str, int color); 
     329int distrust_tactics_helper(int str); 
    329330int disconnect_helper(int apos, int bpos); 
    330331 
    331332