5 Star 2 Fork 1

玄道公子 / genetic_maze

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
maze_game.h 983 Bytes
一键复制 编辑 原始数据 按行查看 历史
wen.gu 提交于 2017-05-18 16:20 . 添加c++实现版本。
#ifndef __MAZE_GAME_H__
#define __MAZE_GAME_H__
#include "maze_map2.h"
#include "genetic_algorithm.h"
class mazeGame: public geneticAlg<int>
{
public:
mazeGame(mazeMap* map, int popSize, int genomeSize, int maxgenerations, double crossoverRate, double mutationRate);
~mazeGame();
public:
void play();
protected:
virtual void mutate(genome<int>& chromo);
virtual void epoch(std::vector<genome<int>>& oldPop, std::vector<genome<int>>& newPop);
private:
void initializePop();
void geneMutate(int gene, int geneLength, double mutationRate);
void genomeDecode(genome<int>& chromo, std::vector<int>& moveSteps);
void updateFitnessScore();
double testPlay(std::vector<int>& moveSteps);
private:
bool mIsRunning = false;
int mPopSize;
int mGenomeSize;
int mGenerationCnt = 0;
int mMaxGenerations;
int mFittestGenomeIdx = 0;
double mBestFitnessScore = 0.0;
double mTotalFitnessScore = 0.0;
mazeMap* mMap;
std::vector<genome<int>> mPop;
};
#endif // !__MAZE_GAME_H__
C
1
https://gitee.com/xuanwolanxue/genetic_maze.git
git@gitee.com:xuanwolanxue/genetic_maze.git
xuanwolanxue
genetic_maze
genetic_maze
master

搜索帮助