将海龟分配给随机空补丁
Assign Turtles to Random Empty Patch
在我的设置中,我使用以下代码创建名为 "darks" 的代理,并将这些代理分配给一组指定的补丁(免费补丁)。
我正在尝试将每只海龟分配到指定区域内的随机斑块,而不是任何海龟共享一个斑块。
我偶然发现了告诉补丁发芽特定乌龟的代码,但是我可以在不求助于补丁发芽的情况下实现我的目标吗?
create-darks #-of-darks [
set shape "person"
set size 1
set color black
move-to one-of free-patches
]
你可以得到一个没有深色的补丁 there.I 如果有足够的 space 也只会创建一个深色 space。
let n-or-remaining-spaces min (list n (count patches with [not any? darks-here]))
create-darks n-or-remaining-spaces
[
;;Your other setup code
move-to one-of patches with [not any? darks-here]
]
在我的设置中,我使用以下代码创建名为 "darks" 的代理,并将这些代理分配给一组指定的补丁(免费补丁)。
我正在尝试将每只海龟分配到指定区域内的随机斑块,而不是任何海龟共享一个斑块。
我偶然发现了告诉补丁发芽特定乌龟的代码,但是我可以在不求助于补丁发芽的情况下实现我的目标吗?
create-darks #-of-darks [
set shape "person"
set size 1
set color black
move-to one-of free-patches
]
你可以得到一个没有深色的补丁 there.I 如果有足够的 space 也只会创建一个深色 space。
let n-or-remaining-spaces min (list n (count patches with [not any? darks-here]))
create-darks n-or-remaining-spaces
[
;;Your other setup code
move-to one-of patches with [not any? darks-here]
]