From c3ed67477ce2bae4d08218df68b185a32c0271e0 Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Tue, 18 Jan 2022 22:45:39 -0500 Subject: Added a slightly more interesting AI This AI will simply pick the first valid move it finds. This is pretty much the most basic AI that a full game can be played against. --- strategies/first-valid-move.scm | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 strategies/first-valid-move.scm (limited to 'strategies') 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) -- cgit v1.2.3