Ticket #168: send2ret1.patch

File send2ret1.patch, 3.3 KB (added by draqo, 5 years ago)
  • engine/board.c

    diff -N -r -u -X .ignore gnugo-copy/engine/board.c gnugo/engine/board.c
    old new  
    33103310} 
    33113311 
    33123312/* 
     3313 * If (pos) has exactly one neighbor of color (color) 
     3314 * returns position of this neighbor. Otherwise returns -1. 
     3315 */ 
     3316 
     3317int 
     3318find_neighbor(int pos, int color) 
     3319{ 
     3320  int npos; 
     3321 
     3322  ASSERT_ON_BOARD1(pos); 
     3323  ASSERT1(IS_STONE(color), pos); 
     3324 
     3325  if (board[SOUTH(pos)] == color) 
     3326    npos = SOUTH(pos); 
     3327  else 
     3328    npos = 0; 
     3329  if (board[WEST(pos)] == color) { 
     3330    if (npos) 
     3331      npos = -1; 
     3332    else 
     3333      npos = WEST(pos); 
     3334  } 
     3335  if (board[NORTH(pos)] == color) { 
     3336    if (npos) 
     3337      npos = -1; 
     3338    else 
     3339      npos = NORTH(pos); 
     3340  } 
     3341  if (board[EAST(pos)] == color) { 
     3342    if (npos) 
     3343      npos = -1; 
     3344    else 
     3345      npos = EAST(pos); 
     3346  } 
     3347  return npos ? npos : -1; 
     3348} 
     3349 
     3350/* 
    33133351 * Returns true if str1_pos and str2_pos belong to the same string. 
    33143352 */ 
    33153353 
  • engine/board.h

    diff -N -r -u -X .ignore gnugo-copy/engine/board.h gnugo/engine/board.h
    old new  
    330330int second_order_liberty_of_string(int pos, int str_pos); 
    331331int neighbor_of_string(int pos, int str_pos); 
    332332int has_neighbor(int pos, int color); 
     333int find_neighbor(int pos, int color); 
    333334int same_string(int str1_pos, int str2_pos); 
    334335int adjacent_strings(int str1_pos, int str2_pos); 
    335336void mark_string(int str, signed char mx[BOARDMAX], signed char mark); 
  • engine/reading.c

    diff -N -r -u -X .ignore gnugo-copy/engine/reading.c gnugo/engine/reading.c
    old new  
    175175      int ko_move;                                                      \ 
    176176      int apos = moves.pos[k];                                          \ 
    177177                                                                        \ 
    178       if (komaster_trymove(apos, other, moves.message[k], str,&ko_move, \ 
    179                            stackp <= ko_depth && savecode == 0)) {      \ 
     178      if ((board_ko_pos || !send_two_return_one(apos, other))           \ 
     179          && komaster_trymove(apos, other,moves.message[k],str,&ko_move,\ 
     180                              stackp <= ko_depth && savecode == 0)) {   \ 
    180181        int dcode = do_find_defense(str, (defense_hint));               \ 
    181182                                                                        \ 
    182183        if (REVERSE_RESULT(dcode) > savecode                            \ 
     
    14521453 
    14531454  /* If the string is a single stone and a capture would give a ko, 
    14541455   * try to defend it with ko by backfilling. 
    1455    * 
    1456    * FIXME: What is an example of this? Is it correct that the 
    1457    *           return value is WIN and not KO_A or KO_B? 
     1456   * If we don't find any defending move return LOSE and not KO_B, 
     1457   * because we'll lose this ko sooner or later. 
    14581458   */ 
    14591459  if (stackp <= backfill_depth 
    14601460      && countstones(str) == 1 
  • engine/utils.c

    diff -N -r -u -X .ignore gnugo-copy/engine/utils.c gnugo/engine/utils.c
    old new  
    14341434  int other = OTHER_COLOR(color); 
    14351435  int lib1; 
    14361436  int lib2; 
     1437  int neighbor; 
     1438 
     1439  /* We must check this, because in such position: 
     1440   * 
     1441   * ----- 
     1442   * O.*OX 
     1443   * OOXXX 
     1444   * 
     1445   * move * prevents making an eye by X player. 
     1446   */ 
     1447  neighbor = find_neighbor(move, color); 
     1448  if (neighbor == -1 || countlib(neighbor) != 2) 
     1449    return 0; 
    14371450 
    14381451  /* Try to play the move. */ 
    14391452  if (!trymove(move, color, "send_two_return_one-A", NO_MOVE))