Commit 0b2e8c4f authored by Adrian Kosmaczewski's avatar Adrian Kosmaczewski

Started Common Lisp implementation

parent e68aa37d
= Common Lisp
This version can be executed using[Common Lisp] with the following command: `CL_SOURCE_REGISTRY=$(pwd)/conway sbcl --script main.lisp`.
== Tests
(deftype cell () '(dead alive))
(defun print-cell (c)
(if (eq c 'alive)
(format nil " * |")
(format nil " |")))
(asdf:defsystem "conway"
:description "Conway's Game of Life in Common Lisp"
:version "0.0.1"
:author "Adrian Kosmaczewski <>"
:licence "Public Domain"
:components ((:file "coord")
(:file "world")
(:file "cell")))
(defstruct coord x y)
(defclass world ()
((size :accessor size :initarg :size)
(aliveCells :initarg :alive))
(:documentation "A lattice of cells referenced by coord values."))
(defmethod evolve ((object world))
(make-instance 'world :size (size object)))
(require "asdf")
(asdf:operate 'asdf:load-op 'conway)
(defparameter *my-hash* (make-hash-table))
(defparameter *coord1* (make-coord :x 45 :y 64))
(defparameter *coord2* (make-coord :x 356 :y 65))
(setf (gethash *coord1* *my-hash*) 'alive)
(format t "~A~%" (print-cell (gethash *coord1* *my-hash*)))
(format t "~A~%" (gethash *coord2* *my-hash*))
;; NIL
(setf (gethash *coord2* *my-hash*) 'dead)
(format t "~A~%" (print-cell (gethash *coord2* *my-hash*)))
(defun fa ()
(vector *coord1* *coord2* (make-coord :x 1 :y 2)))
(defparameter *vec* (fa))
(format t "~A~%" *vec*)
(sleep 0.5)
(defparameter *w1* (make-instance 'world :size 556 :alive nil))
(defparameter *w2* (evolve *w1*))
(format t "~A~%" (size *w2*))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment