# HG changeset patch # User Steve Losh # Date 1450106397 0 # Node ID 36916ec275e69756611ccf8dd49202ba501f47f9 # Parent c49e58fdf0608d36e2db0eae262e3bf92c62bd96 Tweak mutations diff -r c49e58fdf060 -r 36916ec275e6 src/silt/core.clj --- a/src/silt/core.clj Mon Dec 14 15:15:08 2015 +0000 +++ b/src/silt/core.clj Mon Dec 14 15:19:57 2015 +0000 @@ -46,7 +46,6 @@ (def world-temp (ref 0)) -(def mutation-chance 10) (def reproduction-rate 10) (def animals (ref {})) @@ -114,17 +113,19 @@ (defn mutate-directions [dirs] (update-in dirs [(rr/rand-int 0 9) 1] inc)) -(defn mutate-animal [animal mc] - (-> animal - (update :insulation - (maybe mc v - (+ v (rand-nth [-1 1])))) - (update :directions - (maybe mc v - (mutate-directions v))) - (update-in [:styles :fg] - (maybe mc v - (rr/rand-nth [:white :blue :green :yellow :red]))))) +(defn mutate-animal + ([animal] (mutate-animal animal nil)) + ([animal mc] + (-> animal + (update :insulation + (maybe (or mc 10) v + (+ v (rand-nth [-1 1])))) + (update :directions + (maybe (or mc 20) v + (mutate-directions v))) + (update-in [:styles :fg] + (maybe (or mc 0.01) v + (rr/rand-nth [:white :blue :green :yellow :red])))))) (defn map-vals [m f] (into {} (for [[k v] m] @@ -184,7 +185,7 @@ (assoc :age 0) (assoc :energy 60) (update :loc (fn [[x y]] (normalize-world-coords [(inc x) y]))) - (mutate-animal mutation-chance))) + mutate-animal)) (defn reproduce [animal] [(update animal :energy - 60)