diff options
Diffstat (limited to 'src/initialize_board.c')
-rw-r--r-- | src/initialize_board.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/initialize_board.c b/src/initialize_board.c index 2e037c3..18b1468 100644 --- a/src/initialize_board.c +++ b/src/initialize_board.c @@ -18,20 +18,26 @@ #define _GNU_SOURCE +#include <stdlib.h> + #include "othello.h" -void initialize_board(enum player_color board[8][8]) { +void initialize_board(enum player_color ***board) { + *board = malloc(8 * sizeof(enum player_color *)); + for (int i = 0; i < 8; i++) { + (*board)[i] = malloc(8 * sizeof(enum player_color)); + } // Set all the positions to empty for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { - board[i][j] = EMPTY; + (*board)[i][j] = EMPTY; } } // Fill the starting positions - board[3][3] = WHITE; - board[3][4] = BLACK; - board[4][3] = BLACK; - board[4][4] = WHITE; + (*board)[3][3] = WHITE; + (*board)[3][4] = BLACK; + (*board)[4][3] = BLACK; + (*board)[4][4] = WHITE; } |