Worked out why the wolves weren't working...
This commit is contained in:
parent
9ad67ba0a4
commit
19db0e0673
|
@ -11,45 +11,45 @@
|
||||||
|
|
||||||
;; rules describing vegetation
|
;; rules describing vegetation
|
||||||
(def vegetation-rules
|
(def vegetation-rules
|
||||||
(list
|
(list
|
||||||
;; Randomly, birds plant tree seeds into pasture.
|
;; Randomly, birds plant tree seeds into pasture.
|
||||||
(fn [cell world] (cond (and (= (:state cell) :pasture)(< (rand 10) 1))(merge cell {:state :scrub})))
|
(fn [cell world] (cond (and (= (:state cell) :pasture)(< (rand 10) 1))(merge cell {:state :scrub})))
|
||||||
;; Scrub below the treeline grows gradually into forest, providing browsing pressure is not to high
|
;; Scrub below the treeline grows gradually into forest, providing browsing pressure is not to high
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond (and
|
(cond (and
|
||||||
(= (:state cell) :scrub)
|
(= (:state cell) :scrub)
|
||||||
;; browsing limit really ought to vary with soil fertility, but...
|
;; browsing limit really ought to vary with soil fertility, but...
|
||||||
(< (+ (population cell :deer)(or (:sheep cell) 0)) 6)
|
(< (+ (population cell :deer)(or (:sheep cell) 0)) 6)
|
||||||
(< (:altitude cell) treeline))
|
(< (:altitude cell) treeline))
|
||||||
(merge cell {:state :scrub2})))
|
(merge cell {:state :scrub2})))
|
||||||
(fn [cell world] (cond (= (:state cell) :scrub2) (merge cell {:state :forest})))
|
(fn [cell world] (cond (= (:state cell) :scrub2) (merge cell {:state :forest})))
|
||||||
;; Forest on fertile land at low altitude grows to climax
|
;; Forest on fertile land at low altitude grows to climax
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond
|
(cond
|
||||||
(and
|
(and
|
||||||
(= (:state cell) :forest)
|
(= (:state cell) :forest)
|
||||||
(> (:fertility cell) 10))
|
(> (:fertility cell) 10))
|
||||||
(merge cell {:state :climax})))
|
(merge cell {:state :climax})))
|
||||||
;; Climax forest occasionally catches fire (e.g. lightning strikes)
|
;; Climax forest occasionally catches fire (e.g. lightning strikes)
|
||||||
(fn [cell world] (cond (and (= (:state cell) :climax)(< (rand lightning-probability) 1)) (merge cell {:state :fire})))
|
(fn [cell world] (cond (and (= (:state cell) :climax)(< (rand lightning-probability) 1)) (merge cell {:state :fire})))
|
||||||
;; Climax forest neighbouring fires is likely to catch fire
|
;; Climax forest neighbouring fires is likely to catch fire
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond
|
(cond
|
||||||
(and (= (:state cell) :climax)
|
(and (= (:state cell) :climax)
|
||||||
(< (rand 3) 1)
|
(< (rand 3) 1)
|
||||||
(not (empty? (get-neighbours-with-state world (:x cell) (:y cell) 1 :fire))))
|
(not (empty? (get-neighbours-with-state world (:x cell) (:y cell) 1 :fire))))
|
||||||
(merge cell {:state :fire})))
|
(merge cell {:state :fire})))
|
||||||
;; After fire we get waste
|
;; After fire we get waste
|
||||||
(fn [cell world] (cond (= (:state cell) :fire) (merge cell {:state :waste})))
|
(fn [cell world] (cond (= (:state cell) :fire) (merge cell {:state :waste})))
|
||||||
;; And after waste we get pioneer species; if there's a woodland seed
|
;; And after waste we get pioneer species; if there's a woodland seed
|
||||||
;; source, it's going to be scrub, otherwise grassland.
|
;; source, it's going to be scrub, otherwise grassland.
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond
|
(cond
|
||||||
(and (= (:state cell) :waste)
|
(and (= (:state cell) :waste)
|
||||||
(not
|
(not
|
||||||
(empty?
|
(empty?
|
||||||
(flatten
|
(flatten
|
||||||
(list
|
(list
|
||||||
(get-neighbours-with-state world (:x cell) (:y cell) 1 :scrub2)
|
(get-neighbours-with-state world (:x cell) (:y cell) 1 :scrub2)
|
||||||
(get-neighbours-with-state world (:x cell) (:y cell) 1 :forest)
|
(get-neighbours-with-state world (:x cell) (:y cell) 1 :forest)
|
||||||
(get-neighbours-with-state world (:x cell) (:y cell) 1 :climax))))))
|
(get-neighbours-with-state world (:x cell) (:y cell) 1 :climax))))))
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
(< (rand 50) 1)
|
(< (rand 50) 1)
|
||||||
(= (population cell :deer) 0))
|
(= (population cell :deer) 0))
|
||||||
(merge cell {:deer 2})))
|
(merge cell {:deer 2})))
|
||||||
;; if there are too many deer for the fertility of the area to sustain,
|
;; if there are too many deer for the fertility of the area to sustain,
|
||||||
;; some die or move on.
|
;; some die or move on.
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond (> (* (population cell :deer) 10) (:fertility cell))
|
(cond (> (* (population cell :deer) 10) (:fertility cell))
|
||||||
|
@ -86,16 +86,16 @@
|
||||||
(merge cell {:deer (int (/ n 2))}))))
|
(merge cell {:deer (int (/ n 2))}))))
|
||||||
;; deer breed.
|
;; deer breed.
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond
|
(cond
|
||||||
(>= (population cell :deer) 2)
|
(>= (population cell :deer) 2)
|
||||||
(merge cell {:deer (int (* (:deer cell) 4))})))
|
(merge cell {:deer (int (* (:deer cell) 4))})))
|
||||||
;; wolves arrive occasionally at the edge of the map.
|
;; wolves arrive occasionally at the edge of the map.
|
||||||
;; (fn [cell world]
|
(fn [cell world]
|
||||||
;; (cond (and (< (count (get-neighbours world cell)) 8)
|
(cond (and (< (count (get-neighbours world cell)) 8)
|
||||||
;; (< (rand 50) 1)
|
(< (rand 50) 1)
|
||||||
;; (= (population cell :wolves) 0))
|
(= (population cell :wolves) 0))
|
||||||
;; (merge cell {:wolves 2})))
|
(merge cell {:wolves 2})))
|
||||||
;; if there are not enough deer to sustain the population of wolves,
|
;; if there are not enough deer to sustain the population of wolves,
|
||||||
;; some wolves die or move on.
|
;; some wolves die or move on.
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond (> (population cell :wolves) (population cell :deer))
|
(cond (> (population cell :wolves) (population cell :deer))
|
||||||
|
@ -109,7 +109,7 @@
|
||||||
(merge cell {:wolves 2}))))
|
(merge cell {:wolves 2}))))
|
||||||
;; wolves breed.
|
;; wolves breed.
|
||||||
(fn [cell world]
|
(fn [cell world]
|
||||||
(cond
|
(cond
|
||||||
(>= (population cell :wolves) 2)
|
(>= (population cell :wolves) 2)
|
||||||
(merge cell {:wolves (int (* (:wolves cell) 2))})))
|
(merge cell {:wolves (int (* (:wolves cell) 2))})))
|
||||||
;; wolves eat deer
|
;; wolves eat deer
|
||||||
|
|
Loading…
Reference in a new issue