                   (cond ((and (>= dir 2) (<= dir 4)) 1)
                         ((or (= dir 1) (= dir 5)) 0)
                         (t -1))
-                  *width*)
-               *width*))
+                  evolution-width)
+               evolution-width))
 
     (setf (animal-y animal)
           (mod (+ y
                   (cond ((and (>= dir 1) (<= dir 2)) -1)
                         ((or (= dir 3) (= dir 7)) 0)
                         (t 1))
-                  *height*)
-               *height*))
+                  evolution-height)
+               evolution-height))
 
     (decf (animal-energy animal))))
 


(defalias 'insertc 'insert-colored-text)

(defvar *width* 80)
(defvar *height* 30)
(defvar *jungle* '(45 10 10 10))
(defvar *plant-energy* 80)

(defvar *plants* (make-hash-table :test #'equal))

(defun random-plant (left top width height)
  (let ((pos (cons (+ left (random width)) (+ top (random height)))))
    (setf (gethash pos *plants*) t)))

(defun add-plants ()
  (apply 'random-plant *jungle*)
  (random-plant 0 0 *width* *height*))

(defstruct animal x y energy dir genes)

(defvar *animals*
  (list (make-animal :x      (ash *width* -1)
                     :y      (ash *height* -1)
                     :energy 1000
                     :dir    0
                     :genes (loop repeat 8
                                  collecting (1+ (random 10))))))

(defun move (animal)
  (let ((dir (animal-dir animal))

;; evolution.el -- the evolution demo, ported to EmacsLisp

(defvar evolution-width 80)
(defvar evolution-height 30)
(defvar evolution-jungle-rectangle '(45 10 10 10))
(defvar evolution-plant-energy 80)

(defvar evolution-plants (make-hash-table :test #'equal))

(defvar evolution-animals
  (list (make-animal :x      (ash evolution-width -1)
                     :y      (ash evolution-height -1)
                     :energy 1000
                     :dir    0
                     :genes (loop repeat 8
                                  collecting (1+ (random 10))))))

(defvar evolution-reproduction-energy 200)

;; major mode things
(defun evolution ()
  (interactive)
  (switch-to-buffer "*evolution*")
