Corrections in play_move()
This commit is contained in:
parent
e9dca0371f
commit
8db53c2eaf
2 changed files with 20 additions and 13 deletions
|
@ -45,7 +45,6 @@ char get_short_player(e_player player){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHORT_VERSION(code) SHORT_##code
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create empty move
|
* Create empty move
|
||||||
|
@ -265,7 +264,6 @@ e_status play_move(s_utictactoe *p_uttt, s_move *p_move) {
|
||||||
if (is_move_valid(p_uttt, p_move) == NO) {
|
if (is_move_valid(p_uttt, p_move) == NO) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
p_uttt->outer_tictactoe->content[p_move->outer_position] = p_move->player;
|
|
||||||
list_element_s_move *value = (list_element_s_move*)
|
list_element_s_move *value = (list_element_s_move*)
|
||||||
malloc(sizeof(list_element_s_move));
|
malloc(sizeof(list_element_s_move));
|
||||||
|
|
||||||
|
|
|
@ -140,15 +140,24 @@ int main(int argc, char* argv[]) {
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s_move *test_move = create_empty_move();
|
FILE *f = fopen("save.txt", "w+");
|
||||||
free_move(test_move);
|
s_utictactoe *s = create_empty_utictactoe(2); //replace by 2 for uttt play
|
||||||
s_tictactoe *test_ttt = create_empty_tictactoe();
|
s_move *m = create_empty_move();
|
||||||
free_tictactoe(test_ttt);
|
m->outer_position = TOPLEFT + rand() % TICTACTOE_SIZE;
|
||||||
s_utictactoe *test_uttt = create_empty_utictactoe(1);
|
while (s->outer_tictactoe->winner == NOBODY) {
|
||||||
free_utictactoe(test_uttt);
|
draw_utictactoe(s);
|
||||||
test_uttt = create_empty_utictactoe(2);
|
m->player = get_next_player_to_play(s);
|
||||||
free_utictactoe(test_uttt);
|
m->inner_position = TOPLEFT + rand() % TICTACTOE_SIZE;
|
||||||
test_uttt = create_empty_utictactoe(3);
|
play_move(s, m);
|
||||||
free_utictactoe(test_uttt);
|
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;
|
return EXIT_SUCCESS;
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue