;; AI Final Project ;; Module: ALM Specifics-LCell ;; CSC 466 - Graci ;; Jacob Peck - 20110316 (defclass lcell (cell) ( ; l-system associated with the cell (lsystem :accessor lcell-lsystem :initarg :lsystem :initform NIL) ; number of the ruleset, for printing purposes (rulenum :accessor lcell-rulenum :initarg :rulenum :initform 0) ) ) (defmethod make-lcell ((state t) (rulenum integer) (lsystem lsys)) (make-instance 'lcell :state state :history (list state) :lsystem lsystem :rulenum rulenum) ) (defmethod make-ca-lcells ((population integer) (states list) (rule function) (lsystems list) &aux temp cells oldcells ca) (setf cells ()) (setf oldcells ()) (dotimes (i population NIL) (setf temp (pick states)) (setf cells (append cells (list (make-lcell temp i (nth i lsystems))))) (setf oldcells (append oldcells (list (make-lcell temp i (nth i lsystems))))) ) (assign-neighbors cells) (assign-neighbors oldcells) (make-instance 'ca :cells cells :oldcells oldcells :rule rule) ) (defmethod visualize-ca-lcells ((system ca) &aux l) (format t "Here is the world:~%~%") (setf l (ca-cells system)) (dolist (element l NIL) (format t " ~A " (cell-state element)) ) (terpri) (dolist (element l NIL) (format t "~2d " (count 'X (cell-history element))) ) (terpri) NIL )