0
背景:我在NetLogo中爲區域選擇建模。海龜佔據了由道路劃分的景觀。每隻烏龜選擇其領土中心,然後建立一個領土。龜以所有權價值爲基礎爲其領土選擇補丁,所有權價值基於食物與旅行成本。旅行費用包括距離,還應包括是否需要穿越公路才能抵達補丁。Netlogo:識別超出線性特徵的所有修補程序
目標:我希望每隻烏龜都能識別所有需要穿過馬路才能到達該地區中心的補丁。烏龜應該爲這些補丁分配更高的成本。每隻烏龜都會佔據不同的景觀,因此這些費用將針對每隻烏龜。 這可以怎麼做?
示例代碼:我已經添加了幾行有關如何可能接近一路持有道路費用的想法每個龜,但不知道如何將這些將被計算或是否有更好的辦法,同時建立地區舉行這樣的信息:
patches-own
[ owner ;; turtle who claims patch for territory
benefit ;; i.e., food
primary-feature ;; either "road" or null
;; Need a way to calculate and remember road-related patch costs for each turtle,
;; which are based on whether the turtle must cross a road to reach the patch.
;; Perhaps this could be a patch variable tied to each turtle as follows:
road-costs-to-turtle-1
road-costs-to-turtle-2
;; etc...? If so, these would be calculated after turtle chooses a territory center.
]
turtles-own
[ start-patch ;; my territory center
destination ;; my next patch to claim
territory ;; patches I own
]
to go
pick-center
pick-patch
end
to pick-center
setxy random-xcor random-ycor
set start-patch (patch-here)
;; Turtle selects a patch for its territory center. Turtle will next need
;; to calculate costs for patches based on whether a patch requires crossing
;; a road to reach it. I'm at a loss for how to identify all patches beyond
;; roads from the turtle's perspective, however.
end
to pick-patch
if patch-here = start-patch [ set destination highest-value ]
;; Turtle travels to and adds patches to its territory once reaches destination.
end
to-report highest-value
let available-destinations (patch-set [neighbors4] of territory) with [owner = nobody]
report max-one-of available-destinations ([benefit-to-me/cost-to-me])
end
to-report benefit-to-me
report benefit ;; i.e., food value of patch
end
to-report cost-to-me
let road-cost ;;<--???
;; Not sure how to identify if patches are past a road and thus costlier.
;; If this is a patches-own variable, then the coding may be something like:
if who = 1 [let road-cost road-cost-to-turtle-1] ;; etc.
report distance [start-patch] of myself + road-cost
end
你看看[GIS擴展](https://ccl.northwestern.edu/netlogo/docs/gis.html)嗎?如果你使用多邊形,你可以捍衛內部和外部的東西。 – delaye