Bug fixed!
This commit is contained in:
parent
6320b3e5b0
commit
8593289a7b
|
@ -87,13 +87,13 @@
|
|||
(cond (> (* (population cell :deer) 10) (get-int cell :fertility))
|
||||
(merge cell {:deer (int (/ (get-int cell :fertility) 10))})))
|
||||
;; deer gradually spread through the world by breeding or migrating.
|
||||
;; (fn [cell world]
|
||||
;; (let [n (apply + (map #(population % :deer) (get-neighbours world cell)))]
|
||||
;; (cond (and
|
||||
;; (= (population cell :deer) 0)
|
||||
;; (>= n 2))
|
||||
;; (merge cell {:deer (int (/ n 2))}))))
|
||||
;; deer breed.
|
||||
(fn [cell world]
|
||||
(let [n (apply + (map #(population % :deer) (get-neighbours world cell)))]
|
||||
(cond (and
|
||||
(= (population cell :deer) 0)
|
||||
(>= n 2))
|
||||
(merge cell {:deer (int (/ n 2))}))))
|
||||
deer breed.
|
||||
(fn [cell world]
|
||||
(cond
|
||||
(>= (population cell :deer) 2)
|
||||
|
@ -114,13 +114,13 @@
|
|||
(cond (> (population cell :wolves) (population cell :deer))
|
||||
(merge cell {:wolves 0})))
|
||||
;; wolves gradually spread through the world by breeding or migrating.
|
||||
;; (fn [cell world]
|
||||
;; (let [n (apply + (map #(population % :wolves) (get-neighbours world cell)))]
|
||||
;; (cond (and
|
||||
;; (= (population cell :wolves) 0)
|
||||
;; (>= n 2))
|
||||
;; (merge cell {:wolves 2}))))
|
||||
;; wolves breed.
|
||||
(fn [cell world]
|
||||
(let [n (apply + (map #(population % :wolves) (get-neighbours world cell)))]
|
||||
(cond (and
|
||||
(= (population cell :wolves) 0)
|
||||
(>= n 2))
|
||||
(merge cell {:wolves 2}))))
|
||||
wolves breed.
|
||||
(fn [cell world]
|
||||
(cond
|
||||
(>= (population cell :wolves) 2)
|
||||
|
|
|
@ -48,11 +48,12 @@
|
|||
(defn get-neighbours
|
||||
([world x y depth]
|
||||
"Get the neighbours to distance depth of the cell at x, y in this world."
|
||||
(map #(get-cell world (first %) (first (rest %)))
|
||||
(remove #(= % (list x y))
|
||||
(combo/cartesian-product
|
||||
(range (- x depth) (+ x depth))
|
||||
(range (- y depth) (+ y depth))))))
|
||||
(remove nil?
|
||||
(map #(get-cell world (first %) (first (rest %)))
|
||||
(remove #(= % (list x y))
|
||||
(combo/cartesian-product
|
||||
(range (- x depth) (+ x depth 1))
|
||||
(range (- y depth) (+ y depth 1)))))))
|
||||
([world cell depth]
|
||||
"Get the neighbours to distance depth of this cell in this world."
|
||||
(get-neighbours world (:x cell) (:y cell) depth))
|
||||
|
|
Loading…
Reference in a new issue