diff --git a/project.clj b/project.clj index 165d839..12a77e0 100644 --- a/project.clj +++ b/project.clj @@ -7,4 +7,7 @@ [hiccup "1.0.5"] [mw-engine "0.1.5-SNAPSHOT"] [mw-parser "0.1.5-SNAPSHOT"]] - :plugins [[lein-gorilla "0.3.4"]]) + :plugins [[lein-gorilla "0.3.4"]] +;; :jvm-opts ["-XX:ThreadStackSize=8192k"] + :jvm-opts ["-d64" "-Xmx12g"] + ) diff --git a/src/mw_explore/mw_explore.clj b/src/mw_explore/mw_explore.clj index 3378085..2ca2b9d 100644 --- a/src/mw_explore/mw_explore.clj +++ b/src/mw_explore/mw_explore.clj @@ -27,11 +27,13 @@ ;; ** ;; @@ -(time (def w0 (heightmap/apply-heightmap "../mw-ui/resources/public/img/heightmaps/great_britain_and_ireland_med.png"))) -;; (time (def w0 (heightmap/apply-heightmap "../mw-ui/resources/public/img/heightmaps/small_hill.png"))) +;;(time (def w0 (heightmap/apply-heightmap "../mw-ui/resources/public/img/heightmaps/great_britain_and_ireland_med.png"))) +(time (def w0 (heightmap/apply-heightmap "../mw-ui/resources/public/img/heightmaps/great_britain_and_ireland_original.png"))) +;;(time (def w0 (heightmap/apply-heightmap "../mw-ui/resources/public/img/heightmaps/great_britain_and_ireland_small.png"))) +;;(time (def w0 (heightmap/apply-heightmap "../mw-ui/resources/public/img/heightmaps/small_hill.png"))) ;; @@ ;; -> -;;; "Elapsed time: 1295.377747 msecs" +;;; "Elapsed time: 1555.555578 msecs" ;;; ;; <- ;; => @@ -48,7 +50,7 @@ (time (def w1 (drainage/rain-world (drainage/flood-hollows w0)))) ;; @@ ;; -> -;;; "Elapsed time: 897449.632732 msecs" +;;; "Elapsed time: 865276.685472 msecs" ;;; ;; <- ;; => @@ -59,12 +61,19 @@ ;;; ## Next, trace the water flow ;;; ;;; The present algorithm adds the sum of the flow through all the cells for which the cell currently under consideration is the lowest neighbour, recursively uphill. This is obviously inefficient and at present takes even longer. -;;; +;;; ;; ** ;; @@ -(time (def w2 (drainage/flow-world w1))) +(time (def w2 (drainage/flow-world-nr w1))) ;; @@ +;; -> +;;; "Elapsed time: 950758.294506 msecs" +;;; +;; <- +;; => +;;; {"type":"html","content":"#'mw-explore.mw-explore/w2","value":"#'mw-explore.mw-explore/w2"} +;; <= ;; ** ;;; Notice how long it took! This is woefully inefficient. It is a big job - but it isn't that big a job. @@ -75,7 +84,7 @@ ;; ** ;; @@ -(defn shades-of-blue +(defn shades-of-blue "Create CSS specifications for shades of blue which vary in intensity with `n`." [n] (cond @@ -135,7 +144,7 @@ (render-cell {:flow 10 :altitude 20}) ;; @@ ;; => -;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":":td","value":":td"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":style","value":":style"},{"type":"html","content":""background-color: rgb( 215, 215, 255);"","value":"\"background-color: rgb( 215, 215, 255);\""}],"value":"[:style \"background-color: rgb( 215, 215, 255);\"]"}],"value":"{:style \"background-color: rgb( 215, 215, 255);\"}"},{"type":"html","content":"" "","value":"\" \""},{"type":"html","content":"20","value":"20"}],"value":"[:td {:style \"background-color: rgb( 215, 215, 255);\"} \" \" 20]"} +;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":":td","value":":td"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":style","value":":style"},{"type":"html","content":""background-color: rgb( 215, 215, 255);"","value":"\"background-color: rgb( 215, 215, 255);\""}],"value":"[:style \"background-color: rgb( 215, 215, 255);\"]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":title","value":":title"},{"type":"html","content":""{:flow 10, :altitude 20}"","value":"\"{:flow 10, :altitude 20}\""}],"value":"[:title \"{:flow 10, :altitude 20}\"]"}],"value":"{:style \"background-color: rgb( 215, 215, 255);\", :title \"{:flow 10, :altitude 20}\"}"},{"type":"html","content":"" "","value":"\" \""},{"type":"html","content":"20","value":"20"}],"value":"[:td {:style \"background-color: rgb( 215, 215, 255);\", :title \"{:flow 10, :altitude 20}\"} \" \" 20]"} ;; <= ;; @@ @@ -172,7 +181,7 @@ (nth (nth w2 128) 128) ;; @@ ;; => -;;; {"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":flow","value":":flow"},{"type":"html","content":"2","value":"2"}],"value":"[:flow 2]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":rainfall","value":":rainfall"},{"type":"html","content":"1","value":"1"}],"value":"[:rainfall 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":gradient","value":":gradient"},{"type":"html","content":"68","value":"68"}],"value":"[:gradient 68]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":altitude","value":":altitude"},{"type":"html","content":"42","value":"42"}],"value":"[:altitude 42]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":x","value":":x"},{"type":"html","content":"128","value":"128"}],"value":"[:x 128]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":y","value":":y"},{"type":"html","content":"128","value":"128"}],"value":"[:y 128]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":state","value":":state"},{"type":"html","content":":new","value":":new"}],"value":"[:state :new]"}],"value":"{:flow 2, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}"} +;;; {"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":flow","value":":flow"},{"type":"html","content":"1","value":"1"}],"value":"[:flow 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":generation","value":":generation"},{"type":"html","content":"256","value":"256"}],"value":"[:generation 256]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":rainfall","value":":rainfall"},{"type":"html","content":"1","value":"1"}],"value":"[:rainfall 1]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":gradient","value":":gradient"},{"type":"html","content":"68","value":"68"}],"value":"[:gradient 68]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":altitude","value":":altitude"},{"type":"html","content":"42","value":"42"}],"value":"[:altitude 42]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":x","value":":x"},{"type":"html","content":"128","value":"128"}],"value":"[:x 128]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":y","value":":y"},{"type":"html","content":"128","value":"128"}],"value":"[:y 128]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":state","value":":state"},{"type":"html","content":":new","value":":new"}],"value":"[:state :new]"}],"value":"{:flow 1, :generation 256, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}"} ;; <= ;; @@ @@ -180,14 +189,14 @@ ;; @@ ;; => -;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":":td","value":":td"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":style","value":":style"},{"type":"html","content":""background-color: rgb( 247, 247, 255);"","value":"\"background-color: rgb( 247, 247, 255);\""}],"value":"[:style \"background-color: rgb( 247, 247, 255);\"]"}],"value":"{:style \"background-color: rgb( 247, 247, 255);\"}"},{"type":"html","content":"" "","value":"\" \""},{"type":"html","content":"42","value":"42"}],"value":"[:td {:style \"background-color: rgb( 247, 247, 255);\"} \" \" 42]"} +;;; {"type":"list-like","open":"[","close":"]","separator":" ","items":[{"type":"html","content":":td","value":":td"},{"type":"list-like","open":"{","close":"}","separator":", ","items":[{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":style","value":":style"},{"type":"html","content":""background-color: rgb( 251, 251, 255);"","value":"\"background-color: rgb( 251, 251, 255);\""}],"value":"[:style \"background-color: rgb( 251, 251, 255);\"]"},{"type":"list-like","open":"","close":"","separator":" ","items":[{"type":"html","content":":title","value":":title"},{"type":"html","content":""{:flow 1, :generation 256, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}"","value":"\"{:flow 1, :generation 256, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}\""}],"value":"[:title \"{:flow 1, :generation 256, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}\"]"}],"value":"{:style \"background-color: rgb( 251, 251, 255);\", :title \"{:flow 1, :generation 256, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}\"}"},{"type":"html","content":"" "","value":"\" \""},{"type":"html","content":"42","value":"42"}],"value":"[:td {:style \"background-color: rgb( 251, 251, 255);\", :title \"{:flow 1, :generation 256, :rainfall 1, :gradient 68, :altitude 42, :x 128, :y 128, :state :new}\"} \" \" 42]"} ;; <= ;; @@ (html (render-cell (nth (nth w2 128) 128))) ;; @@ ;; => -;;; {"type":"html","content":""<td style=\\"background-color: rgb( 247, 247, 255);\\"> 42</td>"","value":"\"