Added settlement ruleset

This commit is contained in:
Simon Brooke 2014-07-20 15:17:09 +01:00
parent 1c838a79bd
commit 4a48acee20
4 changed files with 21 additions and 19 deletions

View file

@ -3366,7 +3366,7 @@ important.</p>
</ul>
</td><td class="codes"><pre class="brush: clojure">(defn get-int
[map key]
(cond map
(cond (map? map)
(let [v (map key)]
(cond (and v (integer? v)) v
true 0))
@ -3415,14 +3415,19 @@ important.</p>
* `depth` an integer representing the distance from [x,y] that
should be searched;
* `property` a keyword representing a property of the neighbours;
* `value` a value of that property;
* `value` a value of that property (or, possibly, the name of another);
* `op` a comparator function to use in place of `=`.
</code></pre>
<p> It gets messy.</p>
</td><td class="codes"><pre class="brush: clojure">(defn get-neighbours-with-property-value
([world x y depth property value op]
(filter #(eval (list op (get % property) value)) (get-neighbours world x y depth)))
(filter
#(eval
(list op
(or (get % property) (get-int % property))
value))
(get-neighbours world x y depth)))
([world x y depth property value]
(get-neighbours-with-property-value world x y depth property value =))
([world cell depth property value]