-
-
Save amalloy/1086948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn add-buildings | |
([world] | |
(add-buildings world 0.5)) | |
([world prob] | |
(let [maxy (dec (count world)) | |
maxx (dec (count (world 0)))] | |
(loop [world world, cury maxy, curx maxx] | |
(if (and (zero? curx) (zero? cury)) | |
world | |
(let [new-world (update-in world [cury curx] | |
(fn [arg] | |
(if (> (rand) prob) | |
(make-building 1.0 0.0 {}) | |
arg)))] | |
(if (zero? curx) | |
(recur new-world (dec cury) maxx) | |
(recur new-world cury (dec curx))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment