1

エラーメッセージが表示されました:

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

誰かが私が間違っていること、または2つのエージェントセットの減算に対する別の可能な解決策を教えてもらえますか?

4

1 に答える 1

4

なるほど!あなたが投稿した最初のコードサンプルから推測できたかもしれませんが、最初はflockmates-sidewiseそれflockmates-infrontが品種変数であることに気づきませんでした。

結果として、次の行で:

set flockmates-sidewise (flockmates-sidewise with [not member? self flockmates-infront])

...レポーターを実行しているエージェントの変数ではなく、ブロックをflockmates-infront実行しているエージェントの品種変数を参照します。(そして、まだ初期化されていない場合は、その可能性が非常に高い可能性があります。) 必要なものは次のとおりです。withfind-flockmates0

set flockmates-sidewise (flockmates-sidewise with [
    not member? self [flockmates-infront] of myself
])

myself「私が今していることを私に依頼したタートルまたはパッチ」を意味します。

その場合、行がまったく実行されなかったので、10羽未満の鳥を作成してもエラーは発生しなかったと思いますif

于 2012-12-15T23:33:51.363 に答える