;; --------------------------------------------- ;; John Paxton ;; August 26, 2007 ;; CS 436 ;; --------------------------------------------- ;; This file contains the driver functions for ;; the first programming assignment. The objective ;; of the assignment is to determine whether the ;; last stone played in a game of Gomoku creates a ;; run of 5 (or more) like-colored stones. ;; --------------------------------------------- (defconstant *empty* 'empty) ;; constant for empty square (defconstant *black* 'black) ;; constant for black stone (defconstant *white* 'white) ;; constant for white stone ;; --------------------------------------------- ;; test ;; --------------------------------------------- ;; This is function that should be called to ;; test the correctness of the solution. ;; --------------------------------------------- (defun test () (let ( board ;; Gomoku board ) (setf board (make-array '(19 19) :initial-element *empty*)) (test-aux board 9 4 *white*) (test-aux board 9 5 *white*) (test-aux board 9 6 *white*) (test-aux board 9 7 *white*) (test-aux board 9 8 *white*) (test-aux board 2 14 *black*) (test-aux board 6 14 *black*) (test-aux board 3 14 *black*) (test-aux board 5 14 *black*) (test-aux board 4 14 *black*) (setf board (make-array '(10 10) :initial-element *empty*)) (test-aux board 5 4 *black*) (test-aux board 4 3 *black*) (test-aux board 3 2 *black*) (test-aux board 7 6 *black*) (test-aux board 6 5 *black*) (test-aux board 8 7 *black*) (test-aux board 9 8 *black*) (test-aux board 3 6 *white*) (test-aux board 4 5 *white*) (test-aux board 5 4 *white*) (test-aux board 6 3 *white*) (test-aux board 7 2 *white*) (test-aux board 0 9 *white*) (test-aux board 1 8 *white*) (test-aux board 2 7 *white*) (setf board (make-array '(8 8) :initial-element *empty*)) (test-aux board 0 0 *white*) (test-aux board 1 0 *black*) (test-aux board 2 0 *white*) (test-aux board 3 0 *black*) (test-aux board 4 0 *black*) (test-aux board 5 0 *black*) (test-aux board 6 0 *black*) (test-aux board 7 0 *black*) (test-aux board 0 1 *white*) (test-aux board 0 2 *white*) (test-aux board 0 3 *white*) (test-aux board 0 7 *white*) (test-aux board 0 6 *white*) (test-aux board 0 5 *white*) (test-aux board 0 4 *white*) ) ) ;; --------------------------------------------- ;; test-aux ;; --------------------------------------------- ;; board : Gomoku board ;; x : x coordinate of last stone played ;; y : y coordinate of last stone played ;; color : color of last stone played ;; --------------------------------------------- ;; Play a stone in the appropriate position and ;; the call five-in-a-row-p to determine whether ;; the game is won. ;; --------------------------------------------- (defun test-aux (board x y color) (setf (aref board x y) color) (if (five-in-row-p board x y) (format t "Win for ~a playing at (~a, ~a)~%" color x y) ) )