diff options
-rw-r--r-- | strategies/first-valid-move.scm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/strategies/first-valid-move.scm b/strategies/first-valid-move.scm new file mode 100644 index 0000000..e9a9bfb --- /dev/null +++ b/strategies/first-valid-move.scm @@ -0,0 +1,25 @@ +(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)) + +; Return the first valid move we find. +(first valid-next-moves) |