首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NetLogo:选择一个具有某些特性的邻居的补丁?

NetLogo:选择一个具有某些特性的邻居的补丁?
EN

Stack Overflow用户
提问于 2016-04-22 02:51:37
回答 1查看 1.8K关注 0票数 1

我想让我的海龟移动到特定的补丁,并做一个“斑点”。中央补丁=我的海龟位置,可以随机选择,但满足两个条件:

  • 必须与海龟的实际位置有一定距离
  • 以具有特定质量的斑块包围(一定半径内的邻居)

原因是为了在我海龟的位置周围创造一种“缓冲器”,目的是阻止我的集群的接近。

请问,我怎样才能满足这两个条件?

就目前而言,我有:

代码语言:javascript
复制
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 ]
 ]

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-04-22 12:04:50

您就快到了;您只需要重新阅读all?any?的文档。

代码语言:javascript
复制
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

如果可能没有候选人,你应该警惕这一点。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36783963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档