From 580ebb0e8e083994b5b8476fdd886763d58fdc99 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 2 Jul 2014 23:02:39 +0100 Subject: [PATCH] Separated herbivore rule from predator rules so they can be added separately. --- src/mw_engine/natural_rules.clj | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mw_engine/natural_rules.clj b/src/mw_engine/natural_rules.clj index a1395f6..23a4242 100644 --- a/src/mw_engine/natural_rules.clj +++ b/src/mw_engine/natural_rules.clj @@ -63,8 +63,8 @@ (merge cell {:fertility (+ (:fertility cell) 1)}))) )) -;; rules describing animal behaviour -(def predation-rules +;; rules describing herbivore behaviour +(def herbivore-rules (list ;; deer arrive occasionally at the edge of the map. (fn [cell world] @@ -88,7 +88,11 @@ (fn [cell world] (cond (>= (population cell :deer) 2) - (merge cell {:deer (int (* (:deer cell) 4))}))) + (merge cell {:deer (int (* (:deer cell) 4))}))))) + + ;; rules describing predator behaviour + (def predator-rules + (list ;; wolves arrive occasionally at the edge of the map. (fn [cell world] (cond (and (< (count (get-neighbours world cell)) 8) @@ -117,4 +121,4 @@ (merge cell {:deer (- (population cell :deer) (population cell :wolves))})) )) -(def natural-rules (flatten (list vegetation-rules predation-rules))) +(def natural-rules (flatten (list vegetation-rules herbivore-rules predator-rules)))