added options for single player and two player

master
simonkellet 3 years ago
parent 517d366f22
commit a84b5918b9
  1. 49
      main.c
  2. BIN
      ttt

@ -24,26 +24,49 @@ int free_spaces();
int main(int argc, char *argv[]){ int main(int argc, char *argv[]){
char flag = ' '; char flag = ' ';
int players;
clear_board(); clear_board();
printf("How many players? (1/2)\n> ");
scanf("%d", &players);
do{ //this could be tidier i think
flag = check_win(); if(players == 1){
if(free_spaces() == 0){ do{
break; flag = check_win();
} if(free_spaces() == 0){
break;
}
print_board();
player_choice('X');
print_board();
print_board(); cpu_choice('O');
flag = check_win();
print_board();
player_choice('X'); } while(flag == ' ');
flag = check_win();
print_board();
player_choice('O'); } else if(players == 2){
flag = check_win(); do{
print_board(); flag = check_win();
if(free_spaces() == 0){
break;
}
} while(flag == ' '); print_board();
player_choice('X');
print_board();
player_choice('O');
flag = check_win();
print_board();
} while(flag == ' ');
}
if(flag == ' ') if(flag == ' ')
printf(BOLDMAGENTA "\nNo-one won!" RESET); printf(BOLDMAGENTA "\nNo-one won!" RESET);
else else

BIN
ttt

Binary file not shown.
Loading…
Cancel
Save