2
我試圖在NetLogo中模擬避免來自人類代理的動物代理。首先,我問一個單一的掠奪者避免使用兩種行爲,「謹慎」和「害怕」。這很好。但後來我問獵物動物(現在有168個人,但可能還有更多人)也這樣做,模型已經放慢到蝸牛的速度。由於我對NetLogo相當陌生,我確信有一種更有效的方式來編碼這種行爲。有關如何簡化此過程的任何建議?我相信有更好的方法來做到這一點。謝謝!在NetLogo中簡化代理行爲
to avoid-people ;; test if people too close to predator and prey and animals moves away if is.
ask predator [
ifelse ticks mod 24 >= 5 and ticks mod 24 < 18 [ ;makes sure the animals respond to people during the daytime
humans-near
ifelse any? wary
[ fd 0 ]
[ ]
humans-too-near
if any? scared
[run-away]
] [set wary 0 set scared 0]]
ask preys [
ifelse ticks mod 24 >= 5 and ticks mod 24 < 18 [
humans-near
ifelse any? wary
[ fd 0 ]
[ ]
humans-too-near
if any? scared
[run-away]
] [set wary 0 set scared 0]]
end
;;人類-附近,人類太接近的功能 ;;報警距離和飛行出現距離是捕食者滑塊但獵物設定值
to humans-near ;;adds all humans in alert-distance radius of animal to an agent subset for that agent.
ask predator [
set wary humans in-radius alert-distance]
ask preys [
set wary humans in-radius 10]
end
to humans-too-near ;;adds all humans in flight-initiation-distance radius of animal to an agent subset for that agent.
ask predator [
set scared humans in-radius flight-initiation-distance]
ask preys [
set scared humans in-radius 5]
end
to run-away ;;Make animal avoid the human closest to it.
set nearest-human min-one-of scared [distance myself]
turn-away ([heading] of nearest-human) max-separate-turn
end
;;這使動物在熱帶森林裏遠離人類居住。
;;馬克斯 - 獨立 - 又是一個滑塊支配的捕食者運行從人
to turn-away [new-heading max-turn]
turn-at-most (subtract-headings heading new-heading) max-turn
ifelse [habitat = typeTrop] of patch-ahead run-distance
[fd run-distance] [turn-away ([heading] of nearest-human) max-separate-turn]
end
to turn-at-most [turn max-turn]
ifelse abs turn > max-turn
[ ifelse turn > 0
[ rt max-turn ]
[ lt max-turn ] ]
[ rt turn ]
end
如果您可以發佈Wary and Scared的代碼併發布需要很長時間的代碼(用戶配置文件擴展),我們可能會更好地幫助您 – Marzy
我不明白Wary是一個函數,您如何設置它?這些代理的屬性是? – Marzy
這是一個很好的使用netlogo的複雜性科學課程,http://www.complexityexplorer.org/online-courses/3/segments/1028 – Marzy