2017-10-02 4 views
0

ランダムに分布したいくつかの無作為に分類されていない多数のタートルクラスターのうち、 netlogoワールド/インターフェースにおける最大、最小、平均クラスターサイズ(半径方向範囲)と同様に、安定したカメ(黒色)も含まれています。私はエージェントが設定され、それがベースの入植者を認識していないので、それは同様に平均と分の機能のために同じことをするだろう賭けMAX expected input to be a list but got the number 10 instead.netlogoの最大、最小および平均のカメのクラスタサイズとタートルクラスターの数の決定

globals[ cluster-size cluster-count cluster-size-growth cluster-count-growth ] 

to setup 
    clear-all 
    ask patches [ set pcolor white ] 
    create-turtles 1000 [ 
    set color black 
    set label-color blue 
    setxy random-xcor random-ycor 
    set cluster-size 1 
    ] 
    ask n-of 5 turtles [ 
    ask turtles in-radius one-of [1 2 3] [ 
     set color one-of [red grey] 
    ] 
    ] 
end 

to cluster-collect 
    let base-settlers turtles with [ color = red ] 
    let consp-settlers turtles with [ color = grey ] 
    ask base-settlers [ 
    set cluster-count count consp-settlers in-radius cluster-size 
    set cluster-size-growth cluster-size + 1 
    set cluster-count-growth count consp-settlers in-radius cluster-size-growth 
    if cluster-count >= 1 [ 
     ifelse (cluster-count-growth - cluster-count != 0) [ 
     set cluster-size cluster-size + 1 
     ][ 
     print count base-settlers with [ count turtles with [ color = grey ] >= 1 ] 
     ] 
    ] 
    ] 
    print [ max cluster-size-growth ] of base-settlers 
    print [ max cluster-count-growth ] of base-settlers 
    print [ mean cluster-size-growth ] of base-settlers 
    print [ mean cluster-count-growth ] of base-settlers 
    print [ min cluster-size-growth ] of base-settlers 
    print [ min cluster-count-growth ] of base-settlers 
    print [ standard-deviation cluster-size-growth ] of base-settlers 
    print [ standard-deviation cluster-count-growth ] of base-settlers 
    print [ variance cluster-size-growth ] of base-settlers 
    print [ variance cluster-count-growth ] of base-settlers 
end 

私が手にエラーは次のとおりです。このコードを変換して、最大、最小、および平均のクラスターサイズ(半径範囲)と定着した(赤と灰色)カメの数を得る方法に関する考えはありますか?

答えて

3

コードを実行すると、NetLogoはエラーを生成する行を強調表示します。問題の行はprint max cluster-size-growthです。あなたが先に見た場合、それ以前にlet cluster-size-growth cluster-size + 1let cluster-size 1があります。したがってcluster-size-growthは1 + 1、または2です。変数cluster-count-growthも数値です。

これらの2つの変数をそれぞれのカメで計算し、同じタイプのカメに対して最大/平均/最小値を取ろうとしていると思います。その場合、すべてのカメの変数を最初に作成する(つまり、ask []ステートメントを終了する)必要があります。print max cluster-size-growth of base-settlersのような処理を行います。 ask []ブロックの最後にローカル変数の値が失われるため、turtle-ownの変数を設定する必要があります。

+0

私はクラスタ変数をグローバルにしていますが、netlogoは 'ask []'コマンドの外でも 'print max cluster-size-growth of base-settlers'に問題があります。私が受け取るエラーは、 'MAXがリストになると期待されていますが、代わりに数字11を取得しました。 ' – nigus21

+2

これは、[]内に' max'があるからです。 'base-settlersのprint max [cluster-size-growth]を試してみてください。申し訳ありませんが、元のコメントには適切な構文がありませんでした。 – JenB

関連する問題