netlogo使用邻居的多个集水区

时间:2015-05-06 10:05:41

标签: netlogo

你好我是netlogo编程的新手, 我有一些问题..我想制作一个模型,在一个名为home-patches的分隔区域创建海龟,并且必须进入名为security-patches的其他分隔区域。现在我希望海龟使用集水区进入这个安全补丁。问题是我已经制作了10个不同的安全补丁,面积为3 * 3补丁,我使用这个代码生成了集水区

ask security-patches [set catchment-area other patches in-radius catchment-radius ]

我使用“in-radius”命令设置c区域的半径,catchment-radius是界面中的滑块

问题是它只在一个安全补丁的补丁中只创建一个阴道区域随机选择

如果它在这里可能有用的是我如何设置安全补丁和家庭补丁

set security-patches patches with 
   [(pxcor <= 3 and pycor <= 3) 
or (pycor >= 13 and pycor <= 16 and pxcor <= 3) 

or (pxcor <= 3 and pycor >= 26) 

or (pxcor >= 20 and pxcor <= 24 and pycor >= 26) 
or (pxcor >= 20 and pxcor <= 24 and pycor <= 3)
or (pxcor >= 67 and pycor >= 13 and pycor <= 16)
or (pxcor >= 49 and pxcor <= 53 and pycor >= 26)
or (pxcor >= 49 and pxcor <= 53 and pycor <= 3)
or (pxcor >= 67 and pycor <= 3)
or (pxcor >= 67 and pycor >= 26)]


 set home-patches patches with 
   [(pycor > 3 and pycor < 13) 
or ( pycor > 16 and pycor < 26) 
or (pxcor > 10 and pxcor < 20) 
or (pycor >= 13 and pycor <= 16 and pxcor >= 4 and pxcor <= 10)
or (pxcor > 3 and pxcor < 6 and pycor <= 3)
or (pxcor > 3 and pxcor < 6 and pycor >= 26)
or (pxcor >= 20 and pxcor < 67 and pycor >= 13 and pycor <= 16)
or (pxcor >= 6 and pxcor <= 10 and pycor >= 26)
or (pxcor >= 6 and pxcor <= 10 and pycor <= 3)
or (pxcor > 24 and pxcor < 49 and pycor >= 26)
or (pxcor > 53 and pxcor < 67 and pycor >= 26)
or (pxcor > 24 and pxcor < 49 and pycor <= 3)
or (pxcor > 53 and pxcor < 67 and pycor <= 3)]

我将世界的尺寸设定为70 * 30

1 个答案:

答案 0 :(得分:1)

我尝试了你的代码。首先,我使用集水区作为全局变量,并且世界按照您的指定行事,然后我尝试将集水区设置为每个补丁的拥有区域,以便每个补丁都有一个关联:

patches-own[
  catchment-area
]

现在使用您编写的命令来设置集合区域,仅为安全补丁设置它们,并且每个区域的集水区域等于patches in-radius catchment-radius。 我希望这个解决方案能够满足您的需求。