#ifndef GENETIC_PHENOTYPE_H #define GENETIC_PHENOTYPE_H #include #include #include #include #include "genetic/config.h" namespace Genetic { class Phenotype { public: Phenotype(); virtual ~Phenotype(); virtual int getSize()=0; virtual Phenotype &randomize()=0; /** * Modify the given location by the given magnitude. The magnitude * should be between -1.0 and 1.0 inclusive. A 0.0 indicates no * change. */ virtual void mutate( int iLocation, float fMagnitude )=0; virtual Phenotype ©From( const Phenotype &rSrc, int iStart, int iSize, int iDest=-1 )=0; /** * Produces a Phenotype class that can be used to contain the data for * an offspring. The produced phenotype will be compatible, but empty. */ virtual Phenotype *makeEmptyOffspring( int iNewSize=-1 )=0; virtual Bu::String toString()=0; virtual void write( Bu::Stream &rStream ) {}; virtual void read( Bu::Stream &rStream ) {}; bool hasProperty( const Bu::String &sKey ) const; Bu::Variant getProperty( const Bu::String &sKey ) const; void setProperty( const Bu::String &sKey, Bu::Variant vValue ); void setCreated( Genetic::Time t, Genetic::PhenotypeId id ) { tCreated = t; uId = id; bActive = true; } Genetic::Time getCreated() const { return tCreated; } Genetic::PhenotypeId getId() const { return uId; } bool isActive() const { return bActive; } private: Genetic::Time tCreated; Genetic::PhenotypeId uId; bool bActive; typedef Bu::Hash PropHash; PropHash hProp; }; }; #endif