让龟在特定的补丁上随机出现

时间:2017-02-08 23:36:24

标签: gis netlogo

使用GIS,我创建了一个城市的路线图。我希望海龟在设置过程中随机出现在道路上的任何补丁上。我该怎么做呢?

2 个答案:

答案 0 :(得分:0)

使用“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

您可以将[XXX]位更改为

with [ROAD=TRUE]

如果您想使用所拥有的变量放置一个可重现的示例,那么更容易为您提供更有用的答案

答案 1 :(得分:0)

补丁[道路?]

海龟自己[家庭补丁]

设置

设置的驱动程序

设置驱动程序
  创造司机的车号[
     用[道路?设置家庭补丁一个补丁? =真]
    设置形状“飞机”
    设定颜色25
    设定尺寸8
    移动到家庭补丁
   ]
结束