]> git.localhorst.tv Git - blobs.git/blobdiff - src/creature/Creature.hpp
introduce random genetic mutations
[blobs.git] / src / creature / Creature.hpp
index f36a2db1f1172770855a9eebdfc6554202689b6f..3cff2e04cd5264aefab4510679d4abf80bca5f59 100644 (file)
@@ -58,7 +58,7 @@ public:
        const Genome::Properties<double> &GetProperties() const noexcept { return properties; }
 
        const Genome::PropertySet<double> &CurProps() const noexcept { return properties.props[cur_prop]; }
-       const Genome::PropertySet<double> &NextProps() const noexcept { return properties.props[cur_prop + 1]; }
+       const Genome::PropertySet<double> &NextProps() const noexcept { return properties.props[std::min(5, cur_prop + 1)]; }
 
        void BaseColor(const glm::dvec3 &c) noexcept { base_color = c; }
        const glm::dvec3 &BaseColor() const noexcept { return base_color; }
@@ -68,16 +68,19 @@ public:
 
        void Mass(double m) noexcept { mass = m; size = std::cbrt(mass / density); }
        double Mass() const noexcept { return mass; }
-       void Grow(double amount) noexcept;
+       void Ingest(int res, double amount) noexcept;
 
        void Density(double d) noexcept { density = d; size = std::cbrt(mass / density); }
        double Density() const noexcept { return density; }
 
        double Size() const noexcept;
        double Age() const noexcept;
+       std::string AgeName() const;
        double AgeLerp(double from, double to) const noexcept;
-       // change of giving birth per tick
+       // chance of giving birth per tick
        double Fertility() const noexcept;
+       // chance of random genetic mutation per tick
+       double Mutability() const noexcept;
 
        void Health(double h) noexcept { health = h; }
        double Health() const noexcept { return health; }
@@ -90,6 +93,10 @@ public:
        Memory &GetMemory() noexcept { return memory; }
        const Memory &GetMemory() const noexcept { return memory; }
 
+       /// constantly active goal. every creature in the simulation is required to have one
+       void SetBackgroundTask(std::unique_ptr<Goal> &&g) { bg_task = std::move(g); }
+       Goal &BackgroundTask() { return *bg_task; }
+
        void AddNeed(std::unique_ptr<Need> &&n) { needs.emplace_back(std::move(n)); }
        const std::vector<std::unique_ptr<Need>> &Needs() const noexcept { return needs; }
 
@@ -134,6 +141,7 @@ private:
 
        Memory memory;
 
+       std::unique_ptr<Goal> bg_task;
        std::vector<std::unique_ptr<Need>> needs;
        std::vector<std::unique_ptr<Goal>> goals;