summaryrefslogtreecommitdiff
path: root/strategies
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2022-01-21 17:20:17 -0500
committerRobby Zambito <contact@robbyzambito.me>2022-01-21 17:20:17 -0500
commitf1a4b5757f0d20739270b22726ebf8442b13cb50 (patch)
tree93e170ddebc79cf5a41777fc040797bc6dfa5d85 /strategies
parent3a85be307b6240525f032b9fad5114bdf172bdc1 (diff)
Fleshed out Scheme primitives
* Moved board specific functions from othello.h to new othello_board.h * Removed unused function pointer for player moves * Added prototypes in headers for SCM functions, including scm_get_current_player, * Made get_winner accept a board and current player. This is useful for predictions to see if some move would make the other player a winner. * get_winner also writes the players scores to provided pointers.
Diffstat (limited to 'strategies')
-rw-r--r--strategies/first-valid-move.scm26
1 files changed, 2 insertions, 24 deletions
diff --git a/strategies/first-valid-move.scm b/strategies/first-valid-move.scm
index e9a9bfb..e682873 100644
--- a/strategies/first-valid-move.scm
+++ b/strategies/first-valid-move.scm
@@ -1,25 +1,3 @@
-(use-modules (ice-9 pretty-print)
- (srfi srfi-1))
-
-(define (make-point row col)
- (cons row col))
-
-(define (point->row point)
- (car point))
-
-(define (point->col point)
- (cdr point))
-
-(define (valid-move-current-board? move)
- (valid-move? (get-board) (current-player) move))
-
-(define all-spots
- (concatenate
- (map (lambda (row) (map (lambda (col) (make-point row col)) (iota 8)))
- (iota 8))))
-
-(define valid-next-moves
- (filter valid-move-current-board? all-spots))
-
+(use-modules (srfi srfi-1))
; Return the first valid move we find.
-(first valid-next-moves)
+(first (valid-moves))