NetLogo代理集减法

NetLogo代理集减法,netlogo,Netlogo,我收到了错误消息: MEMBER? expected input to be a string or list or agentset but got the number 0 instead. 在运行以下NetLogo代码时: to find-flockmates ;; turtle reporter ;; latch on to the nearby birds set flockmates-infront other birds in-cone vision cone-infr

我收到了错误消息:

MEMBER? expected input to be a string or list or agentset but got the number 0 instead.
在运行以下NetLogo代码时:

to find-flockmates  ;; turtle reporter
  ;; latch on to the nearby birds
  set flockmates-infront other birds in-cone vision cone-infront-degree
  set flockmates-sidewise other birds in-cone vision cone-sidewise-degree

  ;; agentset substraction
  if (count flockmates-infront > 0)[
    set flockmates-sidewise (flockmates-sidewise with [not member? self flockmates-infront])  
    ] 
end

有人能告诉我我做错了什么,或者用另一种可能的方法减去两个代理集吗?

我明白了,现在!很难从你发布的最初代码示例中猜到,我起初没有意识到,
侧向的
侧向的
是品种变量

因此,在这方面:

set flockmates-sidewise (flockmates-sidewise with [not member? self flockmates-infront])
flockmates-infront
指的是执行带有
块的
代理的品种变量,not指的是运行
find flockmates
reporter的代理的变量。(如果还没有初始化,那么它很可能是
0
)。您需要的是:

set flockmates-sidewise (flockmates-sidewise with [
    not member? self [flockmates-infront] of myself
])
意思是“让我做我现在正在做的事的乌龟或补丁。”


我猜您在创建少于10只鸟时没有得到错误,因为在这种情况下,您的
if
阻止执行该行。

我明白了,现在!很难从你发布的最初代码示例中猜到,我起初没有意识到,
侧向的
侧向的
是品种变量

因此,在这方面:

set flockmates-sidewise (flockmates-sidewise with [not member? self flockmates-infront])
flockmates-infront
指的是执行带有
块的
代理的品种变量,not指的是运行
find flockmates
reporter的代理的变量。(如果还没有初始化,那么它很可能是
0
)。您需要的是:

set flockmates-sidewise (flockmates-sidewise with [
    not member? self [flockmates-infront] of myself
])
意思是“让我做我现在正在做的事的乌龟或补丁。”


我猜您在创建少于10只鸟时没有收到错误,因为在这种情况下,您的
if
阻止了执行该行。

可能有什么我没有看到的,但看起来您做得不错。。。您是每次都会出现此错误,还是仅在特殊情况下才会出现此错误?你有没有试过
show flockmates-infront
,看看它是否设置为除agentset之外的任何东西?(据我所知,它不应该。可能没有人
,但你的
,如果
会处理这个问题。)这个错误每次都会被触发,除非我创造的鸟/海龟少于10.5只。您介意将您的完整模型发布到某个地方吗?祝您玩得开心;)也许有什么我没有看到,但看起来你做得对。。。您是每次都会出现此错误,还是仅在特殊情况下才会出现此错误?你有没有试过
show flockmates-infront
,看看它是否设置为除agentset之外的任何东西?(据我所知,它不应该。可能没有人
,但你的,如果会处理这个问题。)这个错误每次都会被触发,除非我创造的鸟/海龟少于10.5只。您介意将您的完整模型发布到某个地方吗?祝您玩得开心;)谢谢。你让我开心!谢谢。你让我开心!