Corrections in play_move()

This commit is contained in:
Yorick Barbanneau 2021-10-15 16:39:52 +02:00
parent e9dca0371f
commit 8db53c2eaf
2 changed files with 20 additions and 13 deletions

View file

@ -140,15 +140,24 @@ int main(int argc, char* argv[]) {
exit (EXIT_FAILURE);
}
}
s_move *test_move = create_empty_move();
free_move(test_move);
s_tictactoe *test_ttt = create_empty_tictactoe();
free_tictactoe(test_ttt);
s_utictactoe *test_uttt = create_empty_utictactoe(1);
free_utictactoe(test_uttt);
test_uttt = create_empty_utictactoe(2);
free_utictactoe(test_uttt);
test_uttt = create_empty_utictactoe(3);
free_utictactoe(test_uttt);
FILE *f = fopen("save.txt", "w+");
s_utictactoe *s = create_empty_utictactoe(2); //replace by 2 for uttt play
s_move *m = create_empty_move();
m->outer_position = TOPLEFT + rand() % TICTACTOE_SIZE;
while (s->outer_tictactoe->winner == NOBODY) {
draw_utictactoe(s);
m->player = get_next_player_to_play(s);
m->inner_position = TOPLEFT + rand() % TICTACTOE_SIZE;
play_move(s, m);
m->outer_position = m->inner_position;
}
draw_utictactoe(s);
draw_utictactoe_history(s);
save_a_utictactoe_to_file(f, s);
printf("The winner is : %c\n", s->outer_tictactoe->winner);
free_move(m);
free_utictactoe(s);
fclose(f);
return EXIT_SUCCESS;
}
}