Ticket #25: gunnar_7_7.8.diff

File gunnar_7_7.8.diff, 5.4 kB (added by gunnar, 3 years ago)

Remove some more mostly trivial wrapper functions from engine/interface.c

  • engine/interface.c

    RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
    retrieving revision 1.56
    diff -u -r1.56 interface.c
     
    6565void 
    6666gnugo_clear_board(int boardsize) 
    6767{ 
    68   gg_assert(MIN_BOARD <= boardsize && boardsize <= MAX_BOARD); 
    6968  board_size = boardsize; 
    7069  clear_board(); 
    7170#if 0 
     
    220219  } 
    221220    
    222221  return value; 
    223 } 
    224  
    225 /* Interface to attack() */ 
    226 int 
    227 gnugo_attack(int m, int n, int *i, int *j) 
    228 { 
    229   int retval; 
    230   int move; 
    231  
    232   retval = attack(POS(m, n), &move); 
    233  
    234   if (i) 
    235     *i = I(move); 
    236   if (j) 
    237     *j = J(move); 
    238    
    239   return retval; 
    240 } 
    241  
    242  
    243 /* Interface to find_defense() */ 
    244 int 
    245 gnugo_find_defense(int m, int n, int *i, int *j) 
    246 { 
    247   int retval; 
    248   int move; 
    249  
    250   retval = find_defense(POS(m, n), &move); 
    251  
    252   if (i) 
    253     *i = I(move); 
    254   if (j) 
    255     *j = J(move); 
    256  
    257   return retval; 
    258222} 
    259223 
    260224 
  • interface/play_ascii.c

    RCS file: /cvsroot/gnugo/gnugo/interface/play_ascii.c,v
    retrieving revision 1.59
    diff -u -r1.59 play_ascii.c
     
    351351               CMD_CAPTURE, CMD_DEFEND, 
    352352               CMD_HELPDEBUG, CMD_SHOWAREA, CMD_SHOWMOYO, CMD_SHOWTERRI, 
    353353               CMD_GOTO, CMD_SAVE, CMD_LOAD, CMD_SHOWDRAGONS, CMD_LISTDRAGONS, 
    354                SETHURRY, SETLEVEL, NEW, COUNT, CONTINUE 
     354               SETLEVEL, NEW, COUNT, CONTINUE 
    355355}; 
    356356 
    357357 
     
    400400  if (!strncmp(command, "play", 4)) return PLAY; 
    401401  if (!strncmp(command, "info", 4)) return INFO; 
    402402  if (!strncmp(command, "force", 4)) return FORCE; 
    403   if (!strncmp(command, "hurry", 5)) return SETHURRY; 
    404403  if (!strncmp(command, "level", 5)) return SETLEVEL; 
    405404  if (!strncmp(command, "pass", 4)) return PASS; 
    406405  if (!strncmp(command, "save", 3)) return CMD_SAVE; 
     
    610609do_play_ascii(Gameinfo *gameinfo) 
    611610{ 
    612611  int m, num; 
    613   int sz; 
    614612  float fnum; 
    615613  int passes = 0;  /* two passes and its over */ 
    616614  int tmp; 
     
    705703            printf("\nInvalid board size: %d\n", num); 
    706704            break; 
    707705          } 
    708           sz = num; 
    709706          /* Init board. */ 
    710           gnugo_clear_board(sz); 
     707          board_size = num; 
     708          clear_board(); 
    711709          /* In case max handicap changes on smaller board. */ 
    712710          gameinfo->handicap = place_fixed_handicap(gameinfo->handicap); 
    713           sgfOverwritePropertyInt(sgftree.root, "SZ", sz); 
     711          sgfOverwritePropertyInt(sgftree.root, "SZ", board_size); 
    714712          sgfOverwritePropertyInt(sgftree.root, "HA", gameinfo->handicap); 
    715713          break; 
    716714 
     
    729727            break; 
    730728          } 
    731729          /* Init board. */ 
    732           gnugo_clear_board(board_size); 
     730          clear_board(); 
    733731          /* Place stones on board but don't record sgf  
    734732           * in case we change more info. */ 
    735733          gameinfo->handicap = place_fixed_handicap(num); 
     
    781779          printf("\nSet level to %d\n", level); 
    782780          break; 
    783781 
    784           /* Level replaces hurry as of 2.7.204. This option is retained 
    785            * for compatibility with gnugoclient.  
    786            */ 
    787         case SETHURRY: 
    788           command += 6; 
    789           if (sscanf(command, "%d", &num) != 1) { 
    790             printf("\nInvalid command syntax!\n"); 
    791             break; 
    792           } 
    793           level = 10 - num; 
    794           printf("\nSet hurry to %d\n", 10 - level); 
    795           break; 
    796  
    797782        case DISPLAY: 
    798783          if (!opt_showboard) 
    799784            ascii_showboard(); 
     
    11731158static void 
    11741159showcapture(char *line) 
    11751160{ 
    1176   int i, j, x, y; 
    1177   if (line) 
    1178     if (!string_to_location(board_size, line, &i, &j) 
    1179         || BOARD(i, j) == EMPTY) { 
    1180       printf("\ninvalid point!\n"); 
    1181       return; 
    1182     } 
     1161  int i, j; 
     1162  int move; 
     1163 
     1164  gg_assert(line); 
     1165  if (!string_to_location(board_size, line, &i, &j) 
     1166      || BOARD(i, j) == EMPTY) { 
     1167    printf("\ninvalid point!\n"); 
     1168    return; 
     1169  } 
    11831170   
    1184   if (gnugo_attack(i, j, &x, &y)) 
    1185     mprintf("\nSuccessfull attack of %m at %m\n", i, j, x, y); 
     1171  if (attack(POS(i, j), &move)) 
     1172    mprintf("\nSuccessful attack of %m at %1m\n", i, j, move); 
    11861173  else 
    11871174    mprintf("\n%m cannot be attacked\n", i, j); 
    11881175} 
     
    11911178static void 
    11921179showdefense(char *line) 
    11931180{ 
    1194   int i, j, x, y; 
    1195   if (line) 
    1196     if (!string_to_location(board_size, line, &i, &j) 
    1197         || BOARD(i, j) == EMPTY) { 
    1198       printf("\ninvalid point!\n"); 
    1199       return; 
    1200     } 
     1181  int i, j; 
     1182  int move; 
     1183   
     1184  gg_assert(line); 
     1185  if (!string_to_location(board_size, line, &i, &j) 
     1186      || BOARD(i, j) == EMPTY) { 
     1187    printf("\ninvalid point!\n"); 
     1188    return; 
     1189  } 
    12011190 
    1202     if (gnugo_attack(i, j, &x, &y)) { 
    1203       if (gnugo_find_defense(i, j, &x, &y)) 
    1204         mprintf("\nSuccessfull defense of %m at %m\n", i, j, x, y); 
     1191  if (attack(POS(i, j), NULL)) { 
     1192      if (find_defense(POS(i, j), &move)) 
     1193        mprintf("\nSuccessful defense of %m at %1m\n", i, j, move); 
    12051194      else 
    12061195        mprintf("\n%m cannot be defended\n", i, j); 
    12071196    } 
     
    12441233      return; 
    12451234    } 
    12461235 
    1247     gnugo_clear_board(board_size); 
     1236    clear_board(); 
    12481237    handi = place_free_handicap(handi); 
    12491238    printf("\nPlaced %d stones of free handicap.\n", handi); 
    12501239  } 
    12511240  else { /* User is to place handicap */ 
    1252     gnugo_clear_board(board_size); 
     1241    clear_board(); 
    12531242    handi = 0; 
    12541243 
    12551244    while (1) { 
     
    12751264        } 
    12761265      } 
    12771266      else if (!strncmp(line, "clear", 5)) { 
    1278         gnugo_clear_board(board_size); 
     1267        clear_board(); 
    12791268        handi = 0; 
    12801269      } 
    12811270      else if (!strncmp(line, "done", 4)) {