NetLogo:select 具有特定品质的邻居的补丁?
NetLogo: select a patch with neighbors having certain qualities?
我想让我的乌龟移动到某个补丁并制作一个"splotch"。 central patch = my turtle location,可以随机选择,但要满足两个条件:
- 必须与乌龟的实际位置有一定距离
- 必须被具有特定质量的补丁包围(特定半径内的邻居)
原因是在我的乌龟位置周围创造了一种"buffers",目的是阻止我的团块靠近。
请问如何满足这两个条件?
到目前为止,我有:
to go
ask turtles [
; select one of patches in specific distance, and
; surrounded by patches with no magenta color
let aaa one-of patches with [distance myself > 3 and
all? neighbors with [pcolor != magenta]]
; how to write this condition above ??
; and how replace "neighbors" by "in-radius"??
move-to aaa
ask neighbors [ ; create clump of magenta patches
set pcolor magenta ]
ask patch-here [ ; set central patch to magenta
set pcolor magenta ]
]
你快到了;您只需要重新阅读 all?
和 any?
.
的文档
let _candidates patches with [distance myself > 3]
set _candidates _candidates with [
not any? (patches in-radius 3 with [pcolor = magenta])
]
let aaa one-of _candidates
如果有可能没有应聘者,就要提防了。
我想让我的乌龟移动到某个补丁并制作一个"splotch"。 central patch = my turtle location,可以随机选择,但要满足两个条件:
- 必须与乌龟的实际位置有一定距离
- 必须被具有特定质量的补丁包围(特定半径内的邻居)
原因是在我的乌龟位置周围创造了一种"buffers",目的是阻止我的团块靠近。
请问如何满足这两个条件?
到目前为止,我有:
to go
ask turtles [
; select one of patches in specific distance, and
; surrounded by patches with no magenta color
let aaa one-of patches with [distance myself > 3 and
all? neighbors with [pcolor != magenta]]
; how to write this condition above ??
; and how replace "neighbors" by "in-radius"??
move-to aaa
ask neighbors [ ; create clump of magenta patches
set pcolor magenta ]
ask patch-here [ ; set central patch to magenta
set pcolor magenta ]
]
你快到了;您只需要重新阅读 all?
和 any?
.
let _candidates patches with [distance myself > 3]
set _candidates _candidates with [
not any? (patches in-radius 3 with [pcolor = magenta])
]
let aaa one-of _candidates
如果有可能没有应聘者,就要提防了。