X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2FGenome.hpp;h=75ca79c70188c439c4683b3a238e8271663d9196;hp=3361fdef2037d6f913a72ba12c098fe1ddc2e5de;hb=475f28f06c9e14912bab8119264e247ef466513d;hpb=e99964b46daba40b1fad1224a42f5ea9f18d1642 diff --git a/src/creature/Genome.hpp b/src/creature/Genome.hpp index 3361fde..75ca79c 100644 --- a/src/creature/Genome.hpp +++ b/src/creature/Genome.hpp @@ -18,99 +18,57 @@ 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 { - 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]; } - - /// "typical" properties /// every one of these should have at least one /// negative impact to prevent super-beings evolving + T props[8]; /// power at the cost of higher solid intake - T strength; + 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; + T &Stamina() noexcept { return props[1]; } + const T &Stamina() const noexcept { return props[1]; } /// more speed at the cost of higher fatigue - T dexerty; + T &Dexerty() noexcept { return props[2]; } + const T &Dexerty() const noexcept { return props[2]; } /// higher mental capacity at the cost of boredom - T intelligence; + 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; + T &Mutability() noexcept { return props[6]; } + const T &Mutability() const noexcept { return props[6]; } + /// mass of offspring + T &OffspringMass() noexcept { return props[7]; } + const T &OffspringMass() const noexcept { return props[7]; } }; Properties properties; - - 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 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()) + 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()), + p.props[5].FakeNormal(rand.SNorm()), + p.props[6].FakeNormal(rand.SNorm()), + p.props[7].FakeNormal(rand.SNorm()) }; }