+ if (sim.Resources()[res].state == world::Resource::LIQUID && random.UNorm() < AdaptChance()) {
+ // change texture randomly
+ // TODO: make change depending on surroundings and/or resource
+ int p = random.UInt(2); // back or side
+ int q = random.UInt(2); // mean or deviation
+ math::Distribution &d = p ? genome.skin_side : genome.skin_back;
+ if (q == 0) {
+ // move ± one standard deviation
+ d.Mean(d.Mean() + (random.SNorm() * d.StandardDeviation()));
+ } else {
+ // scale by ±10%, enforce bounds
+ d.StandardDeviation(glm::clamp(d.StandardDeviation() * (1.0 + random.SNorm() * 0.1), 0.0001, 0.5));
+ }
+ }