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."
|
Flow comes from a higher cell to a lower only if the lower is the lowest neighbour of the higher."
|
||||||
[world cell]
|
[world cell]
|
||||||
(cond
|
(cond
|
||||||
(> (or (:altitude cell) 0) *sealevel*)
|
(not (nil? (:flow cell))) cell
|
||||||
|
(<= (or (:altitude cell) 0) *sealevel*) cell
|
||||||
|
true
|
||||||
(merge cell
|
(merge cell
|
||||||
{:flow (+ (:rainfall cell)
|
{:flow (+ (:rainfall cell)
|
||||||
(apply +
|
(apply +
|
||||||
(map (fn [neighbour] (:flow (flow world neighbour)))
|
(map (fn [neighbour] (:flow (flow world neighbour)))
|
||||||
(flow-contributors world cell))))})
|
(flow-contributors world cell))))})))
|
||||||
true cell))
|
|
||||||
|
|
||||||
(defn flow-world
|
(defn flow-world
|
||||||
"Return a world like this `world`, but with cells tagged with the amount of
|
"Return a world like this `world`, but with cells tagged with the amount of
|
||||||
|
|
Loading…
Reference in a new issue