X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcreature%2FGenome.hpp;h=96d8bf1ff91ebdf942eb1b7ebefde61249b3e4fb;hb=HEAD;hp=057c6609915abc0cece270fbdb197a426215eb41;hpb=42db7d9d2286e50896ad172e2e4a8fbe65c8a4a9;p=blobs.git diff --git a/src/creature/Genome.hpp b/src/creature/Genome.hpp index 057c660..96d8bf1 100644 --- a/src/creature/Genome.hpp +++ b/src/creature/Genome.hpp @@ -2,6 +2,8 @@ #define BLOBS_CREATURE_GENOME_HPP_ #include "../math/Distribution.hpp" +#include "../math/GaloisLFSR.hpp" +#include "../math/glm.hpp" #include @@ -18,36 +20,69 @@ struct Genome { template struct Properties { - T birth_mass; - T fertile_mass; - T max_mass; - - T fertile_age; - T infertile_age; - T death_age; - - T fertility; + /// every one of these should have at least one + /// negative impact to prevent super-beings evolving + T props[9]; + /// power at the cost of higher solid intake + T &Strength() noexcept { return props[0]; } + const T &Strength() const noexcept { return props[0]; } + /// more endurance at the cost of higher liquid intake + T &Stamina() noexcept { return props[1]; } + const T &Stamina() const noexcept { return props[1]; } + /// more speed at the cost of higher fatigue + T &Dexerty() noexcept { return props[2]; } + const T &Dexerty() const noexcept { return props[2]; } + /// higher mental capacity at the cost of boredom + T &Intelligence() noexcept { return props[3]; } + const T &Intelligence() const noexcept { return props[3]; } + /// average lifetime in seconds + T &Lifetime() noexcept { return props[4]; } + const T &Lifetime() const noexcept { return props[4]; } + /// how likely to succeed in reproduction + T &Fertility() noexcept { return props[5]; } + const T &Fertility() const noexcept { return props[5]; } + /// how likely to mutate + T &Mutability() noexcept { return props[6]; } + const T &Mutability() const noexcept { return props[6]; } + /// how likely to adapt to new environments + T &Adaptability() noexcept { return props[7]; } + const T &Adaptability() const noexcept { return props[7]; } + /// mass of offspring + T &OffspringMass() noexcept { return props[8]; } + const T &OffspringMass() const noexcept { return props[8]; } }; Properties properties; + math::Distribution base_hue; + math::Distribution base_saturation; + math::Distribution base_lightness; - struct Composition { - // which resource - int resource; - // how much contained in the body - // relative value to determine average density - math::Distribution mass; - // how much to circulate - math::Distribution intake; - // how important for alive-being - math::Distribution penalty; - // how much off the mass may stay in the body - math::Distribution growth; - }; - std::vector composition; + math::Distribution highlight_hue; + math::Distribution highlight_saturation; + math::Distribution highlight_lightness; + + math::Distribution skin_back; + math::Distribution skin_side; void Configure(Creature &) const; + static Properties Instantiate( + const Properties &p, + math::GaloisLFSR &rand + ) noexcept { + return { + p.props[0].FakeNormal(rand.SNorm()), + p.props[1].FakeNormal(rand.SNorm()), + p.props[2].FakeNormal(rand.SNorm()), + p.props[3].FakeNormal(rand.SNorm()), + p.props[4].FakeNormal(rand.SNorm()), + glm::clamp(p.props[5].FakeNormal(rand.SNorm()), 0.0, 1.0), + glm::clamp(p.props[6].FakeNormal(rand.SNorm()), 0.0, 1.0), + glm::clamp(p.props[7].FakeNormal(rand.SNorm()), 0.0, 1.0), + p.props[8].FakeNormal(rand.SNorm()) + }; + } + }; }