遗传算法和俄罗斯方块
我使用遗传算法创建俄罗斯方块播放器,并面临一些问题。我读过很多相关的著作,但他们没有给我足够的关于 GA 的细节。
问题是我的代理似乎很快就陷入困境......我使用评估函数涵盖 4 个特征:高度、覆盖的孔、平坦度和清除的行数。我读过一些使用相同评估的论文,并且能够执行数千行。
经过 600 代之后,在拥有 100 个智能体的情况下,最好的智能体平均只能完成 260 行,这是蹩脚的。所有代理都演奏相同的乐曲序列。
我的 GA 详细信息:
世代:600 人口:100个
基因:4个浮点值的数组,介于0和1之间。
均匀交叉以一定的概率发生,并以一定的概率在两个父母之间交换基因。
突变以一定的概率发生,这里我尝试了3种不同的方法:交换基因,用随机值替换基因,或者向基因添加一些噪声值。
我的精英率为50%,并注意到一些好的特工被选中,并产生了更差的特工,污染了人口。
选择就像轮盘赌......
如果有人能给我有关交叉和变异的最佳方式的详细信息,我很感激!
谢谢,抱歉这么长的帖子!
Im creating a Tetris player using genetic algorithms, and facing some issues. I've read a lot of related works, but they don't give me enough details on the GA.
The problem is that my agent seems to get stucked very fast...Im using a evaluation function take covers 4 features:height, covered holes, flatness and number of cleared rows. I read some paper that uses the same evaluation, and is capable of doing thousands of rows.
After 600 generations, with a population of 100 agents, the best one is capable of doing only 260 rows on average, that's lame. All agents are playing the same piece sequence.
Details of my GA:
generations:600
population:100
genes: Array of 4 float values, between 0 and 1.
Uniform crossover happens at a certain probability, and swaps genes between two parents, with a certain probability.
Mutation occurs at a certain probability, here i've tried 3 different approaches:swap genes, replace the gene with a random value, or add some noise value to the gene.
I have a elite rate of 50%, and noticed that some good agents are being selected and given birth to worse agents, contaminating the population.
Selection is roulette wheel...
If someone could give me details on the best way to crossover and mutate, i appreciate!
Thanks, and sorry for the long post!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
评价函数似乎存在一些差异。您描述了四个特征:
但是,您引用的论文描述了五个特征:
(强调我的)
所以看来您缺少评估函数和基因构成中的“井”特征。
There seems to be some difference in the evaluation functions. You describe four features:
However, the paper you reference describes five features:
(emphasis mine)
So it appears that you are missing the "wells" feature in your evaluation function and the makeup of the genes.
与论文不同,您应该实现游戏的“下一块”方面。
在计算“效用”之前,模拟所有可能的“当前块”放置,然后是“下一块”。
为了提高性能,您可以缓存“下一块”展示位置以获得最佳“实用性”,这样它们就不需要再次重新计算为“当前块”展示位置。
虽然计算会更慢,但我相信你的代理会发展得更快/更聪明。
Unlike the paper, you should implement the 'next piece' aspect of the game.
Simulate all possible 'current piece' placements followed by 'next piece' before calculating the 'utility'.
For the sake of performance you can cache the 'next piece' placements for the best 'utility' so that they don't need to be recalculated as 'current piece' placements again.
While the calculations will be slower I believe your agents will evolve faster/smarter.