Minor tidy-up

This commit is contained in:
Simon Brooke 2014-07-21 11:03:07 +01:00
parent 91310af2d8
commit b197368c66
3 changed files with 7 additions and 48 deletions

View file

@ -1,3 +1,5 @@
## Basic ruleset which just grows trees
## Vegetation rules
;; rules which populate the world with plants
@ -5,14 +7,14 @@
if state is grassland then 1 chance in 10 state should be heath
;; heath below the treeline grows gradually into forest, providing browsing pressure is not to high
;; heath below the treeline grows gradually into forest
if state is heath and deer are fewer than 6 and altitude is less than 150 then state should be scrub
if state is heath and altitude is less than 120 then state should be scrub
if state is scrub then 1 chance in 5 state should be forest
;; Forest on fertile land grows to climax
if state is forest and fertility is more than 5 then state should be climax
if state is forest and fertility is more than 5 and altitude is less than 70 then state should be climax
;; Climax forest occasionally catches fire (e.g. lightning strikes)
@ -33,48 +35,6 @@ if state is waste and some neighbours are forest then state should be heath
if state is waste and some neighbours are climax then state should be heath
if state is waste then state should be grassland
## Herbivore rules
;; rules describing the impact of herbivores on the environment
;; if there are too many deer for the fertility of the area to sustain,
;; some die or move on.
;; if deer are more than fertility then deer should be fertility / 2
;; deer arrive occasionally at the edge of the map.
if x is 0 or y is 0 and deer are 0 then 1 chance in 50 deer should be 2
;; deer gradually spread through the world by breeding or migrating.
if fertility is more than 10 and deer is 0 and some neighbours have deer more than 2 then deer should be 2
;; deer breed.
if deer are more than 1 then deer should be deer * 2
## Predator rules
;; rules describing the impact of predator behaviour on the environment
if deer are more than wolves then deer should be deer - wolves
;; if there are not enough deer to sustain the population of wolves,
;; some wolves die or move on.
if wolves are more than deer then deer should be 0 and wolves should be deer + 0
;; wolves arrive occasionally at the edge of the map.
if x is 0 or y is 0 and wolves are 0 then 1 chance in 50 wolves should be 2
;; wolves gradually spread through the world by breeding or migrating.
if state is not water and wolves is 0 and some neighbours have wolves more than 2 then 1 chance in 5 wolves should be 2
;; wolves breed.
if wolves are more than 1 then wolves should be wolves * 2
## Potential blockers
;; Forest increases soil fertility.
@ -87,7 +47,6 @@ if state is in forest or climax then fertility should be fertility + 1
;; end of the file
;; below the waterline we have water.
if state is new and altitude is less than 10 then state should be water
;; above the snowline we have snow.

View file

@ -30,7 +30,7 @@
"Compile each non-comment line of this `string` into an executable anonymous
function, and return the sequence of such functions."
[string]
(map #(compile-rule % true) (remove comment? (trim (split string #"\n")))))
(map #(compile-rule % true) (remove comment? (split string #"\n"))))
(defn compile-file
"Compile each non-comment line of the file indicated by this `filename` into

View file

@ -414,7 +414,7 @@
(use 'mw-engine.utils)
(let [afn (eval (parse-rule rule-text))]
(cond
(and afn return-tuple?)(list afn rule-text)
(and afn return-tuple?)(list afn (trim rule-text))
true afn))))
([rule-text]
(compile-rule rule-text false)))