新的Netlogo用户在这里,我感觉非常困难。我正在尝试模拟海龟为家庭范围挑选补丁。目前,所有补丁都有0.1或1.0的食物益处,并且乌龟通过寻找具有益处1.0的下一个最接近的补丁来挑选补丁以添加到其家庭范围。在选择高效益补丁的过程中,它会自动添加与益处0.1相交的任何补丁。此代码似乎适用于此行为。
但是,我想让乌龟做一些不同的事情,而不仅仅是选择值为1.0的下一个最接近的补丁。代替:
我希望乌龟能够查看景观中的所有斑块,并计算从其家庭中心到景观中每个斑块的距离。
然后它应该通过将补丁的食物益处除以到该补丁的距离来计算乌龟的值(“值对我”)。所以,利益/距离=价值对我来说。
然后它应该按照最高价值选择下一个目的地补丁。
我已经尝试了所有我能想到的东西,却没有成功。如何以及何时计算到所有补丁的距离?我如何计算对我的价值?我意识到这些计算是特定于乌龟的,因为每只乌龟都有自己的一组距离来测量景观上的每个补丁。因此,我尝试过这样的事情,比如“让价值给我[利益/距离自己],设定目标最大值 - 我的价值”(以及我能想到的每一种可能的变化)。
正如我所说,我对此真的很陌生。如果需要更多详细信息以帮助解决此问题,请与我们联系。非常感谢您的任何帮助!
;;------------------------------------Run model-----------------------------
;; benefit is the food benefit on a patch, either 0.1 or 1.0
;; sum-v is the total food benefits acquired by the turtle as it picks patches for its home range
;; threshold-v is the total benefits required in order to satisfy home range requirements.
;; patches are used? = true once picked, so turtle can only pick unused patches.
;; start-patch is the origin (center) of the home range, from which turtle picks patches.
to go
ask turtles
[pick-territory]
tick
end
to pick-territory
ifelse sum-v < threshold-v ;; if the turtle's sum-v is less than threshold-v, then keep picking
[
;--This line works:---
set destination min-one-of patches with [ benefit >= 1 and used? = false ][ distance myself ]
;; This line appears to work so that turtle decides which is next-closest high-benefit, unused patch from its home range center.
;--BUT...this is what I want to do:---
;; Calculate distance to all patches from start-patch (turtle's home range origin).
;; Calculate "value-to-me" as the benefit (of patch) divided by distance to that patch from turtle's start-patch.
;; Set destination to highest value-to-me patch.
;; I've tried all sorts of things to do this, to no avail.
;; For example, the following code doesn't work...
let value-to-me [benefit / distance myself]
set destination max-one-of value-to-me
;; So I'm hoping for help with all this.
;--After it sets its destination, the turtle does the following:
face destination
forward 1 ;; move forward 1 and do all these things....
set memory lput patch-here memory ;; turtle adds patch to memory of home range as it moves across it
if patch-here = destination
[
set sum-v sum-v + benefit ;; monitors total sum-v acquired as the sum of all benefits from patches
set patches-picked patches-picked + 1 ;; counts the # of patches picked for home range
set used? true ;; changes patch to used? true so knows it's no longer available
let this-turtle self
set owner this-turtle ;; adds the turtle's name to the patch so the patch knows who owns it
move-to start-patch ;; return to origin and find a new available destination patch
]
if patch-here != destination ;; meanwhile, if the patch isn't the destination (turtle moves across it to get there), then do the following:
[
if used? = false ;; if it's an available patch...still add it to the home range, add +1 to patches-picked, add its benefits to sum-v, etc.
[ set sum-v sum-v + benefit
set patches-picked patches-picked + 1
set used? true
let this-turtle self
set owner this-turtle
]
]
]
[stop] ;; stop if sum-v => threshold-v.
end