diff options
author | Robby Zambito <contact@robbyzambito.me> | 2022-01-21 18:26:46 -0500 |
---|---|---|
committer | Robby Zambito <contact@robbyzambito.me> | 2022-01-21 18:26:46 -0500 |
commit | 0026e5937a3f91a1551dee15bc7482ffee1735d6 (patch) | |
tree | 22d328c06829f131d33af02ed47027357646820b /include/othello_move.h | |
parent | 0846d554b20df412aa16c7e250c400daee82dd59 (diff) |
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.
Diffstat (limited to 'include/othello_move.h')
-rw-r--r-- | include/othello_move.h | 9 |
1 files changed, 6 insertions, 3 deletions
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); |