X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2FGenome.hpp;h=882a8a28f3b9c5e6acf1671c4a6883c944c9339c;hp=057c6609915abc0cece270fbdb197a426215eb41;hb=838022c799cecd0e93826565e537a0667bded024;hpb=e0180e01f4c659c97973f585fea5eb3344254ce0 diff --git a/src/creature/Genome.hpp b/src/creature/Genome.hpp index 057c660..882a8a2 100644 --- a/src/creature/Genome.hpp +++ b/src/creature/Genome.hpp @@ -2,6 +2,7 @@ #define BLOBS_CREATURE_GENOME_HPP_ #include "../math/Distribution.hpp" +#include "../math/GaloisLFSR.hpp" #include @@ -17,17 +18,27 @@ class Creature; struct Genome { template - struct Properties { - T birth_mass; - T fertile_mass; - T max_mass; - - T fertile_age; - T infertile_age; - T death_age; - + struct PropertySet { + T age; + T mass; T fertility; }; + template + struct Properties { + 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]; } + }; Properties properties; @@ -48,6 +59,31 @@ struct Genome { 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()) + }; + } + + 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) + }; + } + }; }