⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cgp.h

📁 C人工智能游戏开发的一些实例源代码 C Game development in artificial intelligence source code of some examples
💻 H
字号:
//GPExample
//Copyright John Manslow
//29/09/2001

#ifndef _CGP_
#define _CGP_

//Forward declaration of base class for GP program node
class CGPNode;

class CGP
{
public:

	CGP(unsigned long);			//Population size
	~CGP();

	//Returns a pointer to a new randomly created program
	CGPNode *pGetRandomSubtree(void);

	//Mutates the program passed in the function's parameter list
	CGPNode* pMutate(CGPNode *);

	//Creates a new program by applying a crossover operator to the two program specified (by their locations
	//in the population) in the parameter list
	CGPNode *pCross(unsigned long,unsigned long);

	//Returns a pointer to a progarm so that its fitness can be evaluated
	CGPNode *pGetChromosomeForEvaluation(void);

	//Sets the fitness of the working program to the fitness provided
	void SetFitness(double);

	//Returns a pointer to the best program found so far
	CGPNode *pGetBestChromosome(void);

	//Returns the performance of the best program discovered so far
	double dGetBestPerformance(void);

private:

	//The population size
	unsigned long ulPopulationSize;

	//The number of fitness evaluations made so far
	unsigned long ulIteration;

	//The program whos fitness is currently being evaluated
	unsigned long ulWorkingTree;

	//The population of programs
	CGPNode **pProgram;
	//And their fitnesses
	double *pdFitnesses;

	//Search parameters
	double dMutationProbability;
	double dCrossoverProbability;

	//A copy of the best program discovered so far and its performance
	CGPNode *pFittestTree;
	double dBestFitness;
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -