我有两个品种,我想在设置过程中将它们堆叠成每个补丁 10 个为一组,每个品种单独放置。我尝试过如下简单的表达式,但它们似乎不起作用。关于如何安排这个的任何想法?
ask breed1
[
if count breed1 patch-here < 10 and count breed2 patch-here = 0
[move-to patch-here]
]
ask breed2
[
if count breed2 patch-here < 10 and count breed1 patch-here = 0
[move-to patch-here]
]
更新:
这段代码应该可以工作,但仍然不能满足我的要求。感谢 Seth 指出模型库示例代码。它部分起作用,它确实集中了一些海龟,但仍然有混合品种种群的斑块。我怀疑在 go 过程或某种循环中它可能会起作用,但在 setup 过程中它没有达到它应该达到的效果。
to concentrate
ask breed1
[
let like-patches patches with [ any? breed1-here and not any? breed2-here]
if any? like-patches
[if count breed1-here < 10
[let target one-of like-patches
face target
move-to target ] ]
]
ask breed2
[
let like-patches patches with [ any? breed2-here and not any? breed1-here]
if any? like-patches
[if count breed2-here < 10
[let target one-of like-patches
face target
move-to target ]]
]
如果我为每个品种创建了一个补丁网格,那么这行简单的代码行似乎可以部分工作,因此它们从一开始就在空间上是分开的:
ask breed1
[
if count breed1-here > 10
[move-to one-of patches with [count breed1-here >= 1]]
]
ask breed2
[
if count breed2-here > 10
[move-to one-of patches with [count breed2-here >= 1]]
]