First commit with view
This commit is contained in:
parent
64c85567d9
commit
8656f37eab
3 changed files with 26 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
set(CMAKE_C_FLAGS "-std=c99 -g -Wall")
|
||||
set(CMAKE_C_FLAGS "-std=c99 -lncurses -g -Wall")
|
||||
set(CMAKE_INSTALL_PREFIX ".")
|
||||
include_directories(include)
|
||||
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
|
||||
project(utictactoe)
|
||||
add_executable(${PROJECT_NAME} src/utictactoe.c src/model.c)
|
||||
add_executable(${PROJECT_NAME} src/utictactoe.c src/model.c src/view.c)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
set(CMAKE_C_FLAGS "-std=c99 -g -Wall")
|
||||
set(CMAKE_C_FLAGS "-std=c99 -lncurses -g -Wall")
|
||||
set(CMAKE_INSTALL_PREFIX ".")
|
||||
include_directories(../include)
|
||||
project(utictactoe)
|
||||
add_executable(${PROJECT_NAME} utictactoe.c model.c)
|
||||
add_executable(${PROJECT_NAME} utictactoe.c model.c view.c)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "utictactoe.h"
|
||||
#include "common.h"
|
||||
#include "model.h"
|
||||
#include "view.h"
|
||||
|
||||
#define OPTIONAL_ARGUMENT_IS_PRESENT \
|
||||
((optarg == NULL && optind < argc && argv[optind][0] != '-') \
|
||||
|
@ -140,24 +141,35 @@ int main(int argc, char* argv[]) {
|
|||
exit (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
FILE *f = fopen("save.txt", "w+");
|
||||
s_utictactoe *s = create_empty_utictactoe(2); //replace by 2 for uttt play
|
||||
s_utictactoe *s = create_empty_utictactoe(1);
|
||||
s_move *m = create_empty_move();
|
||||
m->outer_position = TOPLEFT + rand() % TICTACTOE_SIZE;
|
||||
p_view v = create_view(s);
|
||||
while (s->outer_tictactoe->winner == NOBODY) {
|
||||
draw_utictactoe(s);
|
||||
m->player = get_next_player_to_play(s);
|
||||
m->inner_position = TOPLEFT + rand() % TICTACTOE_SIZE;
|
||||
m->outer_position=get_next_outer_position(s);
|
||||
set_next_player_move(m,v);
|
||||
play_move(s, m);
|
||||
m->outer_position = m->inner_position;
|
||||
}
|
||||
free_view(v);
|
||||
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;
|
||||
|
||||
s = create_empty_utictactoe(2);
|
||||
m = create_empty_move();
|
||||
v = create_view(s);
|
||||
while (s->outer_tictactoe->winner == NOBODY) {
|
||||
m->player = get_next_player_to_play(s);
|
||||
m->outer_position=get_next_outer_position(s);
|
||||
set_next_player_move(m,v);
|
||||
play_move(s, m);
|
||||
m->outer_position = m->inner_position;
|
||||
}
|
||||
free_view(v);
|
||||
draw_utictactoe_history(s);
|
||||
printf("The winner is : %c\n", s->outer_tictactoe->winner);
|
||||
free_move(m);
|
||||
free_utictactoe(s);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue