+ glm::dvec3 base_color(
+ std::fmod(base_hue.FakeNormal(random.SNorm()) + 1.0, 1.0),
+ glm::clamp(base_saturation.FakeNormal(random.SNorm()), 0.0, 1.0),
+ glm::clamp(base_lightness.FakeNormal(random.SNorm()), 0.0, 1.0)
+ );
+ glm::dvec3 highlight_color(
+ std::fmod(base_color.x + 0.5, 1.0),
+ 1.0 - base_color.y,
+ 1.0 - base_color.z
+ );
+ c.BaseColor(hsl2rgb(base_color));
+ c.HighlightColor(hsl2rgb(highlight_color));
+
+ c.Mass(c.GetProperties().props[0].mass);
+ c.Density(mass / volume);
+ c.GetSteering().MaxAcceleration(1.4 * std::atan(c.GetProperties().strength));
+ c.GetSteering().MaxSpeed(4.4 * std::atan(c.GetProperties().dexerty));
+ c.AddGoal(std::unique_ptr<Goal>(new IdleGoal(c)));
+}
+
+
+void Split(Creature &c) {
+ Creature *a = new Creature(c.GetSimulation());
+ const Situation &s = c.GetSituation();
+ a->Name(c.GetSimulation().Assets().name.Sequential());
+ // TODO: mutate
+ c.GetGenome().Configure(*a);
+ s.GetPlanet().AddCreature(a);
+ // TODO: duplicate situation somehow
+ a->GetSituation().SetPlanetSurface(
+ s.GetPlanet(), s.Surface(),
+ s.Position() + glm::dvec3(0.0, a->Size() * 0.51, 0.0));
+ a->BuildVAO();
+
+ Creature *b = new Creature(c.GetSimulation());
+ b->Name(c.GetSimulation().Assets().name.Sequential());
+ c.GetGenome().Configure(*b);
+ s.GetPlanet().AddCreature(b);
+ b->GetSituation().SetPlanetSurface(
+ s.GetPlanet(), s.Surface(),
+ s.Position() + glm::dvec3(0.0, b->Size() * -0.51, 0.0));
+ b->BuildVAO();
+
+ c.Die();
+}
+
+
+Memory::Memory(Creature &c)
+: c(c) {
+}
+
+Memory::~Memory() {
+}
+
+void Memory::Tick(double dt) {
+ Situation &s = c.GetSituation();
+ if (s.OnSurface()) {
+ TrackStay({ &s.GetPlanet(), s.Surface(), s.SurfacePosition() }, dt);
+ }
+}
+
+void Memory::TrackStay(const Location &l, double t) {
+ const world::TileType &type = l.planet->TypeAt(l.surface, l.coords.x, l.coords.y);
+ auto entry = known_types.find(type.id);
+ if (entry != known_types.end()) {
+ entry->second.last_been = c.GetSimulation().Time();
+ entry->second.last_loc = l;
+ entry->second.time_spent += t;
+ } else {
+ known_types.emplace(type.id, Stay{
+ c.GetSimulation().Time(),
+ l,
+ c.GetSimulation().Time(),
+ l,
+ t
+ });
+ }
+}
+
+
+NameGenerator::NameGenerator()
+: counter(0) {
+}
+
+NameGenerator::~NameGenerator() {
+}
+
+std::string NameGenerator::Sequential() {
+ std::stringstream ss;
+ ss << "Blob " << ++counter;
+ return ss.str();