57ce46be0449

Water damps temperature loss
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Mon, 14 Dec 2015 16:31:16 +0000
parents 4dccbc0c808a
children 8783b3a23dce
branches/tags (none)
files README.markdown src/silt/core.clj

Changes

--- a/README.markdown	Mon Dec 14 16:13:27 2015 +0000
+++ b/README.markdown	Mon Dec 14 16:31:16 2015 +0000
@@ -62,6 +62,9 @@
 energy to maintain their temperature (think sweating or burning calories to warm
 up).
 
+Being near water helps creatures regulate their temperature a bit.  They might
+evolve to take advantage of this.
+
 Creatures have an insulation rating that affects how fast or slow they exchange
 heat to/from the environment (think different amounts of fur or skin).
 
--- a/src/silt/core.clj	Mon Dec 14 16:13:27 2015 +0000
+++ b/src/silt/core.clj	Mon Dec 14 16:31:16 2015 +0000
@@ -207,9 +207,19 @@
       dest)))
 
 
+(defn near-water [animal]
+  (->> animal
+    :loc
+    neighbors
+    (map @terrain)
+    (filter identity)
+    (filter #(= (:name %) :water))
+    empty?))
+
 (defn affect-temp [animal]
   (assoc animal :temp (float (/ (Math/abs @world-temp)
-                                (inc (Math/abs (:insulation animal)))))))
+                                (inc (Math/abs (:insulation animal)))
+                                (if (near-water animal) 5 1)))))
 
 (defn fix-temp [{:keys [temp] :as animal}]
   (-> animal
@@ -312,7 +322,7 @@
                   y (rr/rand-gaussian-int oy pond-size)]]
     {:name :water
      :glyph "≈"
-     :energy 0.01
+     :energy 0.1
      :loc (normalize-world-coords [x y])
      :styles {:fg :black :bg :blue}}))