2017-10-15 5 views
0

私は、パッチが建物と同等で、影響力の値が異なる移動を見るために都市景観をモデリングしています。カメは最も高い影響値とパッチの方が、定義された通りに沿って移動するnetlogo:レポーターを使用して影響値を計算する

(its own influence) plus (the influence of neighbors) divided by the 
distance to a specific turtle (max-one-of distance myself) 

:私のようなもので、各パッチの値を算出し、レポーター機能を使用する必要があります。

私はnetlogoを使い始めたばかりで、完全に立ち往生しています。

これまでの内容の一部を取り上げましたが、各パッチの影響値(イン・コーン)を計算するレポーター機能をどのように記述すれば、カメが最高の選択肢。

to setup-influence-field 
    ask patches with [pcolor = green] [set influence commercial-influence] 
    ask patches with [pcolor = orange] [set influence production-influence] 
    ask patches with [pcolor = yellow] [set influence domestic-influence] 
    ask patches with [pcolor = pink] [set influence religious-influence] 
    ask patches with [pcolor = blue] [set influence public-influence] 
end 

to go 
    move-serapis 
end 

to move-serapis 
    ask serapis [set-procession-heading] 
    repeat 2 [ ask serapis [ fd .25 ] display ] 
    tick 
end 

;;;;; the reporter values are need for this part of the code so that the turtles (serapis) can move towards the patches with the highest influence value;;;; 
    to set-procession-heading 
     let direction patches in-cone 4 40 with [influence-field > 0] 
     if any? influence-field 
      [face max-one-of influence-field] ;;;; face towards the highest computed influence value 
     ifelse any? patches with [pcolor = black] in-cone 1 25 
     [process] 
    end 

ご協力いただければ幸いです。

答えて

1

これは完全に正しいとは思いませんし、テストすることはできませんが、エラーを知らせてくれれば、ここで誰かがそれを修正できます。

to set-procession-heading 
    let direction-targets patches in-cone 4 40 with [influence-field > 0] 
    if any? direction-targets 
    [ face max-one-of direction-targets [ influence-amount self ] ] 
end 

to-report influence-amount [ target-node ] 
    report ([ influence-field ] + sum [ influence-field] of neighbors)/distance target-node 
end 

私が行ったことは、計算結果を報告する別の手順を設定したことです。このプロシージャには、影響を受けているカメの身元を渡せるようにする必要があるため、引数(target-nodeという名前)が使用されます。その手続きを済ませたら、可能性のある方向のエージェントセットを計算プロシージャに渡し、最大の値を持つものを選択するだけです。

関連する問題