RCS file: /cvsroot/gnugo/gnugo/engine/interface.c,v
retrieving revision 1.56
diff -u -r1.56 interface.c
|
|
|
|
| 65 | 65 | void |
| 66 | 66 | gnugo_clear_board(int boardsize) |
| 67 | 67 | { |
| 68 | | gg_assert(MIN_BOARD <= boardsize && boardsize <= MAX_BOARD); |
| 69 | 68 | board_size = boardsize; |
| 70 | 69 | clear_board(); |
| 71 | 70 | #if 0 |
| … |
… |
|
| 220 | 219 | } |
| 221 | 220 | |
| 222 | 221 | 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; |
| 258 | 222 | } |
| 259 | 223 | |
| 260 | 224 | |
RCS file: /cvsroot/gnugo/gnugo/interface/play_ascii.c,v
retrieving revision 1.59
diff -u -r1.59 play_ascii.c
|
|
|
|
| 351 | 351 | CMD_CAPTURE, CMD_DEFEND, |
| 352 | 352 | CMD_HELPDEBUG, CMD_SHOWAREA, CMD_SHOWMOYO, CMD_SHOWTERRI, |
| 353 | 353 | CMD_GOTO, CMD_SAVE, CMD_LOAD, CMD_SHOWDRAGONS, CMD_LISTDRAGONS, |
| 354 | | SETHURRY, SETLEVEL, NEW, COUNT, CONTINUE |
| | 354 | SETLEVEL, NEW, COUNT, CONTINUE |
| 355 | 355 | }; |
| 356 | 356 | |
| 357 | 357 | |
| … |
… |
|
| 400 | 400 | if (!strncmp(command, "play", 4)) return PLAY; |
| 401 | 401 | if (!strncmp(command, "info", 4)) return INFO; |
| 402 | 402 | if (!strncmp(command, "force", 4)) return FORCE; |
| 403 | | if (!strncmp(command, "hurry", 5)) return SETHURRY; |
| 404 | 403 | if (!strncmp(command, "level", 5)) return SETLEVEL; |
| 405 | 404 | if (!strncmp(command, "pass", 4)) return PASS; |
| 406 | 405 | if (!strncmp(command, "save", 3)) return CMD_SAVE; |
| … |
… |
|
| 610 | 609 | do_play_ascii(Gameinfo *gameinfo) |
| 611 | 610 | { |
| 612 | 611 | int m, num; |
| 613 | | int sz; |
| 614 | 612 | float fnum; |
| 615 | 613 | int passes = 0; /* two passes and its over */ |
| 616 | 614 | int tmp; |
| … |
… |
|
| 705 | 703 | printf("\nInvalid board size: %d\n", num); |
| 706 | 704 | break; |
| 707 | 705 | } |
| 708 | | sz = num; |
| 709 | 706 | /* Init board. */ |
| 710 | | gnugo_clear_board(sz); |
| | 707 | board_size = num; |
| | 708 | clear_board(); |
| 711 | 709 | /* In case max handicap changes on smaller board. */ |
| 712 | 710 | gameinfo->handicap = place_fixed_handicap(gameinfo->handicap); |
| 713 | | sgfOverwritePropertyInt(sgftree.root, "SZ", sz); |
| | 711 | sgfOverwritePropertyInt(sgftree.root, "SZ", board_size); |
| 714 | 712 | sgfOverwritePropertyInt(sgftree.root, "HA", gameinfo->handicap); |
| 715 | 713 | break; |
| 716 | 714 | |
| … |
… |
|
| 729 | 727 | break; |
| 730 | 728 | } |
| 731 | 729 | /* Init board. */ |
| 732 | | gnugo_clear_board(board_size); |
| | 730 | clear_board(); |
| 733 | 731 | /* Place stones on board but don't record sgf |
| 734 | 732 | * in case we change more info. */ |
| 735 | 733 | gameinfo->handicap = place_fixed_handicap(num); |
| … |
… |
|
| 781 | 779 | printf("\nSet level to %d\n", level); |
| 782 | 780 | break; |
| 783 | 781 | |
| 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 | | |
| 797 | 782 | case DISPLAY: |
| 798 | 783 | if (!opt_showboard) |
| 799 | 784 | ascii_showboard(); |
| … |
… |
|
| 1173 | 1158 | static void |
| 1174 | 1159 | showcapture(char *line) |
| 1175 | 1160 | { |
| 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 | } |
| 1183 | 1170 | |
| 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); |
| 1186 | 1173 | else |
| 1187 | 1174 | mprintf("\n%m cannot be attacked\n", i, j); |
| 1188 | 1175 | } |
| … |
… |
|
| 1191 | 1178 | static void |
| 1192 | 1179 | showdefense(char *line) |
| 1193 | 1180 | { |
| 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 | } |
| 1201 | 1190 | |
| 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); |
| 1205 | 1194 | else |
| 1206 | 1195 | mprintf("\n%m cannot be defended\n", i, j); |
| 1207 | 1196 | } |
| … |
… |
|
| 1244 | 1233 | return; |
| 1245 | 1234 | } |
| 1246 | 1235 | |
| 1247 | | gnugo_clear_board(board_size); |
| | 1236 | clear_board(); |
| 1248 | 1237 | handi = place_free_handicap(handi); |
| 1249 | 1238 | printf("\nPlaced %d stones of free handicap.\n", handi); |
| 1250 | 1239 | } |
| 1251 | 1240 | else { /* User is to place handicap */ |
| 1252 | | gnugo_clear_board(board_size); |
| | 1241 | clear_board(); |
| 1253 | 1242 | handi = 0; |
| 1254 | 1243 | |
| 1255 | 1244 | while (1) { |
| … |
… |
|
| 1275 | 1264 | } |
| 1276 | 1265 | } |
| 1277 | 1266 | else if (!strncmp(line, "clear", 5)) { |
| 1278 | | gnugo_clear_board(board_size); |
| | 1267 | clear_board(); |
| 1279 | 1268 | handi = 0; |
| 1280 | 1269 | } |
| 1281 | 1270 | else if (!strncmp(line, "done", 4)) { |