Ticket #145: unconditional.c.patch

File unconditional.c.patch, 3.5 kB (added by draqo, 2 years ago)
  • gnugo/engine/unconditional.c

    RCS file: /sources/gnugo/gnugo/engine/unconditional.c,v
    retrieving revision 1.5
    diff -u -r1.5 unconditional.c
     
    5757    string_found = 0; 
    5858     
    5959    /* Visit all friendly strings on the board. */ 
    60     for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     60    scan_board(pos, 
    6161      if (board[pos] != color || find_origin(pos) != pos) 
    6262        continue; 
    6363 
     
    101101          popgo(); 
    102102          moves_played--; 
    103103        } 
    104     } 
     104        ) 
    105105  } 
    106106 
    107107  if (none_invincible) 
     
    331331   * kind of seki described in the comments. 
    332332   */ 
    333333  memset(potential_sekis, 0, sizeof(potential_sekis)); 
    334   for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     334  scan_board(pos, 
    335335    int isolated = 1; 
    336336    int stones[2]; 
    337337    int pos2; 
     
    356356      potential_sekis[stones[0]] = 1; 
    357357      potential_sekis[stones[1]] = 1; 
    358358    } 
    359   } 
     359  ) 
    360360   
    361361  moves_played = capture_non_invincible_strings(color, potential_sekis, 
    362362                                                &none_invincible); 
     
    380380   * 1. Play opponent stones on all liberties of the unconditionally 
    381381   *    alive strings except where illegal. 
    382382   */ 
    383   for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     383  scan_board(pos, 
    384384    if (board[pos] != color || potential_sekis[pos] || find_origin(pos) != pos) 
    385385      continue; 
    386386       
     
    390390      if (trymove(libs[k], other, "unconditional_life", pos)) 
    391391        moves_played++; 
    392392    } 
    393   } 
     393  ) 
    394394 
    395395  /* 2. Recursively extend opponent strings in atari, except where this 
    396396   *    would be suicide. 
     
    400400    /* Nothing found so far in this turn of the loop. */ 
    401401    found_one = 0; 
    402402 
    403     for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     403    scan_board(pos, 
    404404      if (board[pos] != other || countlib(pos) > 1) 
    405405        continue; 
    406406         
     
    410410        moves_played++; 
    411411        found_one = 1; 
    412412      } 
    413     } 
     413        ) 
    414414  } 
    415415 
    416416  /* Now see whether there are any significant sekis on the board. */ 
    417   for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     417  scan_board(pos, 
    418418    if (!potential_sekis[pos] 
    419419        || board[pos] == EMPTY 
    420420        || find_origin(pos) != pos) 
     
    461461      if (countstones(pos) > 2) 
    462462        break; 
    463463    } 
    464   } 
     464  ) 
    465465 
    466466  /* Capture the strings involved in potential sekis. */ 
    467   for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     467  scan_board(pos, 
    468468    if (!potential_sekis[pos] || board[pos] == EMPTY) 
    469469      continue; 
    470470    /* Play as many liberties as we can. */ 
     
    473473      if (trymove(libs[k], other, "unconditional_life", pos)) 
    474474        moves_played++; 
    475475    } 
    476   } 
     476  ) 
    477477     
    478478 
    479   for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     479  scan_board(pos, 
    480480    int apos; 
    481481    int bpos; 
    482     int aopen, bopen; 
    483     int alib, blib; 
     482    int aopen; 
     483        int bopen; 
     484    int alib; 
     485        int blib; 
    484486    if (board[pos] != other || countlib(pos) != 2) 
    485487      continue; 
    486488    findlib(pos, 2, libs); 
     
    515517      trymove(bpos, other, "unconditional_life", pos); 
    516518      moves_played++; 
    517519    } 
    518   } 
     520  ) 
    519521   
    520522  /* Identify unconditionally alive stones and unconditional territory. */ 
    521   for (pos = BOARDMIN; pos < BOARDMAX; pos++) { 
     523  scan_board(pos, 
    522524    if (board[pos] == color && !potential_sekis[pos]) { 
    523525      unconditional_territory[pos] = 1; 
    524526      if (find_origin(pos) == pos) { 
     
    532534      findlib(pos, 1, libs); 
    533535      unconditional_territory[libs[0]] = 2; 
    534536    } 
    535   } 
     537  ) 
    536538   
    537539  /* Take back all moves. */ 
    538540  while (moves_played > 0) {