找到具有相同参数的海龟,然后将它们组合起来
Finding turtles with the same arguments and then combine them
我是 Netlogo 的新手,在编程方面进展顺利。但是,我目前遇到了一个问题。
我将海龟用作鱼的超级个体(参见 Railsback 和 Grimm 2005),这意味着每只海龟都有丰度、性别、年龄和大小的参数。在一年周期结束时,我想找到具有相同性别、年龄和大小特征的海龟,然后将它们的丰度组合成一只具有相同特征的海龟(然后除了新组合的海龟外,所有海龟都会死亡)。有谁知道如何做到这一点?任何建议将不胜感激。
我没有测试我的解决方案,但这应该可行。本质上,对于每只海龟,找出谁是具有相同属性的海龟,并将其添加到 运行 总丰度中,然后让它们去死。
ask turtles [
let others-abundance 0 ;; accumulate other's abundances
ask other turtles with [ sex = [sex] of myself and abundance = [abundance] of myself and age = [age] of myself] and size = [size] of myself] ;;determine who are the others with same properties
[
set others-abundance other-abundance + abundance
die
]
set abundance abundance + other-abundance
]
我是 Netlogo 的新手,在编程方面进展顺利。但是,我目前遇到了一个问题。
我将海龟用作鱼的超级个体(参见 Railsback 和 Grimm 2005),这意味着每只海龟都有丰度、性别、年龄和大小的参数。在一年周期结束时,我想找到具有相同性别、年龄和大小特征的海龟,然后将它们的丰度组合成一只具有相同特征的海龟(然后除了新组合的海龟外,所有海龟都会死亡)。有谁知道如何做到这一点?任何建议将不胜感激。
我没有测试我的解决方案,但这应该可行。本质上,对于每只海龟,找出谁是具有相同属性的海龟,并将其添加到 运行 总丰度中,然后让它们去死。
ask turtles [
let others-abundance 0 ;; accumulate other's abundances
ask other turtles with [ sex = [sex] of myself and abundance = [abundance] of myself and age = [age] of myself] and size = [size] of myself] ;;determine who are the others with same properties
[
set others-abundance other-abundance + abundance
die
]
set abundance abundance + other-abundance
]