使用 GIS 创建了一个城市的路线图。我希望海龟在设置过程中随机出现在任何有道路的补丁上。我将如何做到这一点?
使用"n-of","with"和"sprout"命令即可完成工作。
to world ## This block will make the colors,
##you won't want to use this but it made the example reproducible
ask patches [set pcolor random 50]
end
to make_turtles
let Q 5 ##set this to the number of patches you want to spawn a turtle
ask n-of Q patches with [pcolor = 30] [sprout 1] ##tells Q number of random of patches with
##the desired character (in this case pcolor = 30)
## to sprout 1 turtle
end
您可以将 with [XXX] 位更改为
with [ROAD=TRUE]
如果你想放一个可重现的例子,用拥有的变量,会更容易给你一个更有用的答案
补丁[道路?
海龟自己的[主场补丁]
到设置
安装驱动程序
结束
到安装驱动程序
创建驱动程序的汽车数量 [
设置主补丁 一个补丁与 [ 道路? = 真]
设置形状"飞机">
设置颜色 25
套装尺寸 8
移至主页补丁
]
结束