diff --git a/main.c b/main.c index b651b1289c1bd511537e744ff6f505016a0f2221..9c3e10981ec45baeb100dbd489387b373660c22e 100644 --- a/main.c +++ b/main.c @@ -8,7 +8,11 @@ #include "puissance.h" int main() { + puissance game; + game_init(&game, RAND_AI, DEFAULT_ROW, DEFAULT_COL); + + game_destroy(&game); return EXIT_SUCCESS; } diff --git a/puissance.c b/puissance.c index 010f54d50d323211fde103df547823eab600a6d2..f926d3fad94ef34a226f5210574d18d72dc06035 100644 --- a/puissance.c +++ b/puissance.c @@ -5,3 +5,46 @@ #include "puissance.h" #include <stdio.h> + +void game_init(puissance *p, GameMode mode, int row, int col) { + p->mode = mode; + p->current_player = PLAYER_ONE; + p->row = row; + p->col = col; + p->data = malloc(col * sizeof(int*)); + for (int i = 0; i < col; i++) { + p->data[i] = malloc(row * sizeof(int*)); + } +} + +void print_game(puissance p) { + +} + +void verify_game(puissance p) { + +} + +bool manual_play(puissance *p, int selected_col_index) { + bool valid_action = true; + + return valid_action; +} + +bool random_play(puissance *p) { + bool valid_action = true; + + return valid_action; +} + +bool smart_play(puissance *p) { + bool valid_action = true; + + return valid_action; +} + +void game_destroy(puissance *p) { + free(p->data); + p = NULL; +} + diff --git a/puissance.h b/puissance.h index bf975a03ad017268157ba421b173760a9abf7311..fdfec3c8fc70e9bccd94dd47debdbb808742a246 100644 --- a/puissance.h +++ b/puissance.h @@ -9,4 +9,43 @@ #include <stdlib.h> #include <stdbool.h> +#define ROW_MIN 4 +#define COL_MIN 4 +#define DEFAULT_ROW 6 +#define DEFAULT_COL 7 + +typedef enum { + RAND_AI, + SMART_AI, + TWO_PLAYERS, +} GameMode; + +typedef enum { + PLAYER_ONE, + PLAYER_TWO, +} Player; + +typedef enum { + ONGOING, + DRAW, + PLAYER_ONE_WIN, + PLAYER_TWO_WIN, +} GameResult; + +typedef struct _puissance { + GameMode mode; + Player current_player; + int row; + int col; + int** data; +} puissance; + +void game_init(puissance *p, GameMode mode, int row, int col); +void print_game(puissance p); +void verify_game(puissance p); +bool manual_play(puissance *p, int selected_col_index); +bool random_play(puissance *p); +bool smart_play(puissance *p); +void game_destroy(puissance *p); + #endif \ No newline at end of file