我想让我的乌龟移动到某个补丁并制作一个" splotch"。中央补丁=我的乌龟位置,可以随机选择,但满足两个条件:
原因是创造了一种"缓冲区"在我的乌龟的位置附近,目的是阻止我的团队紧密靠近。
请问,我怎样才能满足这两个条件?
到目前为止,我有:
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 ]
]
答案 0 :(得分:2)
你几乎就在那里;您只需重新阅读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
如果可能没有候选人,你应该防范。