Here's the beginning of a mini lisp practice project, connect 4. Feel free to chime in with code, critiques or other input. I would like to practice the coding approach of a dsl and simultaneous bottom up and top down, so to start here is some pseudo code:
bottom up:
bottom up:
(defun make-board () )
(defun print-board (board) )
(defun end-game () )
(defun get-move () )
(defun make-move (board, x y player) )
(defun test-for-win (board, player) )
(defun count-how-many-in-horizontal-line (board, player, line) )
(defun count-how-many-in-vertical-line (board, player, line) )
(defun count-how-many-in-diagonal-line (board, player, x1,x2,y1,y2) )
(defun list-of-board-rows (board) )
(defun list-of-board-columns (board) )
(defun list-of-board-diagonals (board) )
(defun get-list-of-moves (board,player) )
(defun find-best-move (board,player) )
(defun move-evaluator (board, player) )
(defun min-max (board, player) )
top down:
(defun connect4 ()
(setf live-board (make-board ))
(do ((repeat))
((eq x 99) (end-game))
(print-board (live-board) )
(multiple-value-bind x y (get-move))
;;first version wont use min-max
(make-move (live-board,x,y,human) )
(setf mate-avoid-move (test-for-win (live-board,player) )
(if (not (null mate-avoid-move)) (make-move (mate-avoid-move (live-board, computer)))
(progn
(multiple-value-bind (find-best-move (live-board, computer) )
(make-move (live-board,x,y,computer))
)
)
)