#include #include #include #include "common.h" int main(int argc, char *argv[]) { if (argc != 5) { fprintf(stderr,"%s \n",argv[0]); exit(1); } long movex=atol(argv[1])-2; /* program-internal moves are have the lowest occupied column at 0, but for the user it's 2 */ long movey=atol(argv[2])-2; /* program-internal moves are have the lowest occupied row at 0, but for the user it's 2 */ Boardstate *b = loadboard(argv[3]); printf("Old position:\n"); printboard(b); printf("%c to move\n\n",b->toplay); int result=plyfull(b,movex,movey); if (result==-1) { fprintf(stderr,"invalid move\n"); exit(1); } printf("New position:\n"); printboard(b); if (result==1) { printf("Game over: %c wins\n",b->toplay); exit(0); } printf("%c to move\n",b->toplay); saveboard(b,argv[4]); return 0; }