summaryrefslogtreecommitdiff
path: root/src/phenotypebinary.h
blob: 92146d2c69b1e5bc53463a6ade1788138964d5f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef GENETIC_PHENOTYPE_BINARY_H
#define GENETIC_PHENOTYPE_BINARY_H

#include "genetic/phenotype.h"

namespace Genetic
{
	class PhenotypeBinary : public Phenotype
	{
	public:
		PhenotypeBinary( int iSize, bool bRandom=false );
		virtual ~PhenotypeBinary();

		virtual int getSize() { return iSize; }
		virtual Phenotype &randomize();
		virtual void mutate( int iLocation, float fMagnitude );		
		virtual Phenotype *makeEmptyOffspring( int iNewSize=-1 );
		virtual Phenotype &copyFrom( const Phenotype &rSrc, int iStart,
				int iCount, int iDest=-1 );
		virtual Bu::String toString();

		virtual void write( Bu::Stream &rStream );
		virtual void read( Bu::Stream &rStream );

		void extractBits( uint32_t &rTarget, int iStart, int iBits );
		void extractBits( uint64_t &rTarget, int iStart, int iBits );

	private:
		int iSize;
		int iWords;
		uint_fast32_t *aGenes;
	};
};

#endif