Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- struct Gene
- {
- virtual void mutate(float factor) = 0;
- virtual void reset() = 0;
- virtual void randomize() = 0;
- };
- struct Creature
- {
- std::vector< std::unique_ptr<Gene> > dna;
- void mutate(float factor) {
- for(auto& gene: dna)
- gene->mutate(factor);
- }
- void reset() {
- for(auto& gene: dna)
- gene->reset();
- }
- void randomize() {
- for(auto& gene: dna)
- gene->randomize();
- }
- virtual float fitness() const = 0;
- };
- struct World
- {
- std::vector< std::unique_ptr<Creature> > creatures;
- };
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment