From c5c54396bdf8ef14c17a0bc5b8f0fda74aa958cf Mon Sep 17 00:00:00 2001 From: Robby Zambito Date: Tue, 18 Jan 2022 22:37:04 -0500 Subject: * Made print_board accept a board to print. * free_board should not return anything. * is_valid_move and has_valid_moves accept a board. * Implemented primitives for Scheme strategies to get the current player, and to get the board, and the validity of a move. * Removed game logic from is_valid_move. Instead simply apply the move to a temp board, and see if the move worked. * Created a very simple strategy for testing these primitives. It only hardcodes the first move, and then fails since that move is no longer valid. --- strategies/first-move.scm | 34 ++++++++++++++++++++++++++++++++++ strategies/user-input.scm | 1 + 2 files changed, 35 insertions(+) create mode 100644 strategies/first-move.scm create mode 100644 strategies/user-input.scm (limited to 'strategies') diff --git a/strategies/first-move.scm b/strategies/first-move.scm new file mode 100644 index 0000000..7c89078 --- /dev/null +++ b/strategies/first-move.scm @@ -0,0 +1,34 @@ +(use-modules (ice-9 pretty-print) + (srfi srfi-1)) + +;(pretty-print (get-board)) +;(newline) + +(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)))) + +(display "All valid moves: ") +(for-each (lambda (valid-move) (display valid-move) (newline)) + (filter valid-move-current-board? all-spots)) +(newline) + +; Does not work yet +(display (valid-moves (get-board) (current-player))) +(newline) + +; The last value is simply used as the move +(make-point 3 2) diff --git a/strategies/user-input.scm b/strategies/user-input.scm new file mode 100644 index 0000000..afdab2d --- /dev/null +++ b/strategies/user-input.scm @@ -0,0 +1 @@ +(read) -- cgit v1.2.3