2016-08-27 5 views
1

変数がaである1/16ヘクタールのセルを使用します。これらのうちのいくつかはシミュレーション中に1の値を得ます。パターンはランダムであり、分布しています。私は1ヘクタール(4x4パッチ)の2番目のパッチサイズを作成したいので、次のように質問することができます:[任意のパッチをここに変数a = 1で]表示することができます 助けを非常に感謝!はNetlogoの2つの異なるパッチサイズを使用します

答えて

1

さまざまな種類のパッチを宣言することはできません。異なるサイズのパッチを使用することはできません。しかし、あなたが望むものは、それに頼ることなく完全に実行可能です。あなたのヘクタールは小さなパッチのセットにすぎません。各ヘクタールはエージェントセットであり、それらのエージェントセットをリストに格納することができます。ここで

はそれを行う方法です:

patches-own [ a hectare-id ] 
globals [ hectares ] 

to setup 
    clear-all 
    resize-world 0 31 0 31 ; use a 32 * 32 world to make things nicer 

    ask patches [ 
    ; assign a hectare id based on the coordinates of the patch 
    set hectare-id (word floor (pxcor/4) "-" floor (pycor/4)) 
    ] 

    ; create a list of patch agentsets 
    set hectares map [ 
    patches with [ hectare-id = ? ]  
    ] remove-duplicates [ hectare-id ] of patches 

    ; this is part is unnecessary: it only serve to 
    ; visually distinguish hectares in the view 
    (foreach hectares n-values length hectares [ ? + 1 ] [ 
    ask ?1 [ set pcolor scale-color green (?2/length hectares) -0.5 1.5 ] 
    ]) 

    ask n-of 10 patches [ set a 1 ] 

    ; filter the list of hectares, keeping only those 
    ; where there is any patch with a = 1 in the agentset 
    ; and print the length of that filtered list 
    show length filter [ any? ? with [ a = 1 ] ] hectares 

end 
関連する問題