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