summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2021-11-21 16:22:14 -0500
committerRobby Zambito <contact@robbyzambito.me>2021-11-21 16:22:14 -0500
commitc523507224275b09f275755c26df5bd19cc8358c (patch)
tree94d730e3cc83a67f4f3de0609bb98be536691b3d
parentc39ad6eb10bea035fbe1b88f9bfcf77d0fd3d7b3 (diff)
Make board parameter non-const
-rw-r--r--include/othello.h12
-rw-r--r--src/print_board.c2
-rw-r--r--src/valid_moves.c4
3 files changed, 12 insertions, 6 deletions
diff --git a/include/othello.h b/include/othello.h
index cd3dbac..e6c7796 100644
--- a/include/othello.h
+++ b/include/othello.h
@@ -44,17 +44,23 @@ void initialize_board(enum player_color board[8][8]);
// True if move is valid for current_player.
// Otherwise false.
-bool is_valid_move(const enum player_color board[8][8],
+bool is_valid_move(enum player_color board[8][8],
const enum player_color current_player,
const struct move move);
// True if current_player has any valid moves.
// Otherwise false.
-bool has_valid_moves(const enum player_color board[8][8],
+bool has_valid_moves(enum player_color board[8][8],
const enum player_color current_player);
// Plays a game to completion, starting with board.
enum player_color game_loop(enum player_color board[8][8]);
// Prints the current state of the board, including coordinates in the margins.
-void print_board(const enum player_color board[8][8]);
+void print_board(enum player_color board[8][8]);
+
+// Returns the color of the player whose turn it is.
+enum player_color get_current_player(void);
+
+// Returns the current board.
+const enum player_color **get_board(void);
diff --git a/src/print_board.c b/src/print_board.c
index d9af6d1..4256e7e 100644
--- a/src/print_board.c
+++ b/src/print_board.c
@@ -22,7 +22,7 @@
#include "othello.h"
-void print_board(const enum player_color board[8][8]) {
+void print_board(enum player_color board[8][8]) {
puts(" 0 1 2 3 4 5 6 7");
for (int row = 0; row < 8; row++) {
diff --git a/src/valid_moves.c b/src/valid_moves.c
index 8c46c45..d37de3c 100644
--- a/src/valid_moves.c
+++ b/src/valid_moves.c
@@ -22,7 +22,7 @@
#include "othello.h"
-bool is_valid_move(const enum player_color board[8][8],
+bool is_valid_move(enum player_color board[8][8],
const enum player_color current_player,
const struct move move) {
// The move must be a positive position.
@@ -81,7 +81,7 @@ bool is_valid_move(const enum player_color board[8][8],
return is_valid_up || is_valid_down || is_valid_left || is_valid_right;
}
-bool has_valid_moves(const enum player_color board[8][8],
+bool has_valid_moves(enum player_color board[8][8],
const enum player_color current_player) {
bool result = false;
struct move move;