将补丁添加到代理集并从代理中删除补丁
add a patch to an agentset and remove a patch from an agents
我有关于netlogo agentset操作的问题寻求帮助,谢谢。
我想添加一个补丁,比如 patch-here,到全局代理集变量:mypatches。海龟程序的正确写法是什么?我尝试了以下但它不起作用:
set mypatches (patch-set mypatches patch-here)
我想从全局代理集变量 mypatches 中删除一个补丁,例如 patch-here。海龟程序的正确写法是什么?以下代码不起作用,因为其中一个运算符假定从 mypatches 中删除 self(这是一只乌龟),但我想要的是从 mypatches 中删除 patch-here。
set mypatches one-of mypatches
附加补丁
patch-set
需要补丁代理集,因此您必须
在添加第一个补丁之前将 mypatches
初始化为空集:
set mypatches no-patches
删除补丁
您可以使用 with
进行过滤:
set mypatches mypatches with [[patch-here] of myself != self]
也许更优雅而不是 "self-confusing" 解决方案是要求 patch-here
用 other
:
ask patch-here [set mypatches other mypatches]
我有关于netlogo agentset操作的问题寻求帮助,谢谢。
我想添加一个补丁,比如 patch-here,到全局代理集变量:mypatches。海龟程序的正确写法是什么?我尝试了以下但它不起作用:
set mypatches (patch-set mypatches patch-here)
我想从全局代理集变量 mypatches 中删除一个补丁,例如 patch-here。海龟程序的正确写法是什么?以下代码不起作用,因为其中一个运算符假定从 mypatches 中删除 self(这是一只乌龟),但我想要的是从 mypatches 中删除 patch-here。
set mypatches one-of mypatches
附加补丁
patch-set
需要补丁代理集,因此您必须
在添加第一个补丁之前将 mypatches
初始化为空集:
set mypatches no-patches
删除补丁
您可以使用 with
进行过滤:
set mypatches mypatches with [[patch-here] of myself != self]
也许更优雅而不是 "self-confusing" 解决方案是要求 patch-here
用 other
:
ask patch-here [set mypatches other mypatches]