遗传算法的每一代应该有多少个单元?
我正在开发一款 Roguelike 游戏,并使用 GA 来生成关卡。 我的问题是,我的每一代 GA 应该有多少个级别? 而且,它应该有几代? 是每一代有几个级别更好,还是有很多代更好,或者反之亦然?
I am working on a roguelike and am using a GA to generate levels. My question is, how many levels should be in each generation of my GA? And, how many generations should it have? It it better to have a few levels in each generation, with many generations, or the other way around?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

对于这类事情确实没有硬性规定——大多数实验都喜欢在群体中至少使用至少 200 名成员,然后扩展到数百万甚至更多。 世代数通常在 100 至 10,000 范围内。 一般来说,为了回答你的最后一个问题,最好在种群中拥有大量成员,以便“晚熟”基因在种群中停留足够长的时间以成熟,然后使用较少的代数。
但实际上,这些都不是重要的事情。 任何遗传算法最关键的部分是适应度函数。 如果你没有一个像样的适应度函数来准确评估你认为的“好”水平或“坏”水平,那么无论你使用多少代,你都不会得到有趣的结果,或者你们的人口有多少:)
There really isn't a hard and fast rule for this type of thing - most experiments like to use at least 200 members in a population at the barest minimum, scaling up to millions or more. The number of generations is usually in the 100 to 10,000 range. In general, to answer your final question, it's better to have lots of members in the population so that "late-bloomer" genes stay in a population long enough to mature, and then use a smaller number of generations.
But really, these aren't the important thing. The most critical part of any GA is the fitness function. If you don't have a decent fitness function that accurately evaluates what you consider to be a "good" level or a "bad" level, you're not going to end up with interesting results no matter how many generations you use, or how big your population is :)