X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcreature%2FGenome.hpp;h=3361fdef2037d6f913a72ba12c098fe1ddc2e5de;hb=6c1097479fd1ea41f0f76b91e67613822acf2e90;hp=057c6609915abc0cece270fbdb197a426215eb41;hpb=42db7d9d2286e50896ad172e2e4a8fbe65c8a4a9;p=blobs.git diff --git a/src/creature/Genome.hpp b/src/creature/Genome.hpp index 057c660..3361fde 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 @@ -16,17 +18,46 @@ class Creature; struct Genome { + template + struct PropertySet { + /// the age at which to transition to the next phase + T age; + /// maximum body mass + T mass; + /// fertility factor + T fertility; + /// skin highlight pronounciation + T highlight; + }; template struct Properties { - T birth_mass; - T fertile_mass; - T max_mass; - - T fertile_age; - T infertile_age; - T death_age; + PropertySet props[6]; + PropertySet &Birth() noexcept { return props[0]; } + const PropertySet &Birth() const noexcept { return props[0]; } + PropertySet &Child() noexcept { return props[1]; } + const PropertySet &Child() const noexcept { return props[1]; } + PropertySet &Youth() noexcept { return props[2]; } + const PropertySet &Youth() const noexcept { return props[2]; } + PropertySet &Adult() noexcept { return props[3]; } + const PropertySet &Adult() const noexcept { return props[3]; } + PropertySet &Elder() noexcept { return props[4]; } + const PropertySet &Elder() const noexcept { return props[4]; } + PropertySet &Death() noexcept { return props[5]; } + const PropertySet &Death() const noexcept { return props[5]; } - T fertility; + /// "typical" properties + /// every one of these should have at least one + /// negative impact to prevent super-beings evolving + /// power at the cost of higher solid intake + T strength; + /// more endurance at the cost of higher liquid intake + T stamina; + /// more speed at the cost of higher fatigue + T dexerty; + /// higher mental capacity at the cost of boredom + T intelligence; + /// how likely to mutate + T mutability; }; Properties properties; @@ -46,8 +77,43 @@ struct Genome { }; std::vector composition; + math::Distribution base_hue; + math::Distribution base_saturation; + math::Distribution base_lightness; + void Configure(Creature &) const; + static PropertySet Instantiate( + const PropertySet &p, + math::GaloisLFSR &rand + ) noexcept { + return { + p.age.FakeNormal(rand.SNorm()), + p.mass.FakeNormal(rand.SNorm()), + p.fertility.FakeNormal(rand.SNorm()), + glm::clamp(p.highlight.FakeNormal(rand.SNorm()), 0.0, 1.0) + }; + } + + static Properties Instantiate( + const Properties &p, + math::GaloisLFSR &rand + ) noexcept { + return { + Instantiate(p.props[0], rand), + Instantiate(p.props[1], rand), + Instantiate(p.props[2], rand), + Instantiate(p.props[3], rand), + Instantiate(p.props[4], rand), + Instantiate(p.props[5], rand), + p.strength.FakeNormal(rand.SNorm()), + p.stamina.FakeNormal(rand.SNorm()), + p.dexerty.FakeNormal(rand.SNorm()), + p.intelligence.FakeNormal(rand.SNorm()), + p.mutability.FakeNormal(rand.SNorm()) + }; + } + }; }