本文介绍了比较两个代理变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用遗传算法进行仿真(用于作业).我想做的是比较代理在特定补丁上的适应性,而适应性最低的代理将死亡.
I am currently making a simulation (for homework) using genetic algorithms. What I want to do is compare the fitness of agents on a specific patch and the one with the lowest fitness will die.
我已经在网上搜索并找到了以下代码:if any? breed1-here with [fitness > fitness-of myself] [die]]
I have scoured the net and found this code: if any? breed1-here with [fitness > fitness-of myself] [die]]
但是这似乎不起作用,现在我完全没有主意了.
But this doesn't seem to work and now I'm completely out of ideas.
推荐答案
let goner min-one-of breed1-here [fitness]
if is-turtle? goner [ ask goner [ die ] ]`
is-turtle?
检查是必需的,因为补丁可能为空.
the is-turtle?
check is necessary because the patch might be empty.
这篇关于比较两个代理变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!