Some tentative attempts at optimisation. This, actually, makes no
difference in itself - because the world is immutable, this change won't work without a different mechanism for generating the world itself.
This commit is contained in:
parent
42e6cfac05
commit
9912f264fa
|
@ -35,13 +35,14 @@
|
|||
Flow comes from a higher cell to a lower only if the lower is the lowest neighbour of the higher."
|
||||
[world cell]
|
||||
(cond
|
||||
(> (or (:altitude cell) 0) *sealevel*)
|
||||
(not (nil? (:flow cell))) cell
|
||||
(<= (or (:altitude cell) 0) *sealevel*) cell
|
||||
true
|
||||
(merge cell
|
||||
{:flow (+ (:rainfall cell)
|
||||
(apply +
|
||||
(map (fn [neighbour] (:flow (flow world neighbour)))
|
||||
(flow-contributors world cell))))})
|
||||
true cell))
|
||||
(flow-contributors world cell))))})))
|
||||
|
||||
(defn flow-world
|
||||
"Return a world like this `world`, but with cells tagged with the amount of
|
||||
|
|
Loading…
Reference in a new issue