From c5c54396bdf8ef14c17a0bc5b8f0fda74aa958cf Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Tue, 18 Jan 2022 22:37:04 -0500 Subject: * Made print_board accept a board to print. * free_board should not return anything. * is_valid_move and has_valid_moves accept a board. * Implemented primitives for Scheme strategies to get the current player, and to get the board, and the validity of a move. * Removed game logic from is_valid_move. Instead simply apply the move to a temp board, and see if the move worked. * Created a very simple strategy for testing these primitives. It only hardcodes the first move, and then fails since that move is no longer valid. --- include/othello.h | 4 ++-- include/othello_move.h | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/othello.h b/include/othello.h index 14c402b..40a36c4 100644 --- a/include/othello.h +++ b/include/othello.h @@ -45,14 +45,14 @@ void initialize_board(void); enum player_color **copy_board(enum player_color **board); // Free the specified board. -enum player_color **free_board(enum player_color **board); +void free_board(enum player_color **board); // Plays a game to completion, starting with board. enum player_color game_loop(char *player_one_strategy, char *player_two_strategy); // Prints the current state of the board, including coordinates in the margins. -void print_board(void); +void print_board(enum player_color **board); // Returns the color of the player whose turn it is. enum player_color get_current_player(void); diff --git a/include/othello_move.h b/include/othello_move.h index 0c3716e..281cb9b 100644 --- a/include/othello_move.h +++ b/include/othello_move.h @@ -27,12 +27,14 @@ struct move get_scm_move(char *strategy_path); // True if move is valid for current_player. // Otherwise false. -bool is_valid_move(const enum player_color current_player, +bool is_valid_move(enum player_color **board, + 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 current_player); +bool has_valid_moves(enum player_color **board, + const enum player_color current_player); /* Returns true if the move was valid */ bool apply_move(enum player_color **board, enum player_color current_player, -- cgit v1.2.3