From 0026e5937a3f91a1551dee15bc7482ffee1735d6 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Fri, 21 Jan 2022 18:26:46 -0500 Subject: Made apply_move return the number of flipped spaces. This will return zero for invalid moves, and non-zero for valid moves. This means we can continue to use the result of this as a boolean. Also created a new Scheme primitive which returns the number of tiles flipped by a given move. Created two strategies. One which picks the move that flips the most tiles in the current turn, and one which flips the least. --- include/othello_move.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/othello_move.h b/include/othello_move.h index 2e2974b..a1f030d 100644 --- a/include/othello_move.h +++ b/include/othello_move.h @@ -39,11 +39,14 @@ SCM scm_valid_moves(SCM scm_board, SCM 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, - struct move move); +// Returns non-zero number if the move was valid. +// Returns the number of flipped tiles. +int apply_move(enum player_color **board, enum player_color current_player, + struct move move); // Does not actually modify the current board state. Returns a new board with // the move applied. If the move was not valid, an empty list (nil) is returned. SCM scm_apply_move(SCM move, SCM board, SCM current_player); +SCM scm_get_num_flipped_by_move(SCM move, SCM board, SCM current_player); + struct move scm_move_to_c_move(SCM scm_move); -- cgit v1.2.3