NetLogo:在选择目的地之前,测量障碍物周围的实际行程距离

NetLogo:在选择目的地之前,测量障碍物周围的实际行程距离,netlogo,Netlogo,我正在Netlogo中模拟领土殖民化。海龟0选择一个区域中心,然后通过按值顺序添加补丁来构建一个区域。价值基于收益/成本,其中收益是斑块中的食物量,成本是距离区域中心的距离。海龟0在总面片值达到阈值后完成其领土的构建。接下来,海龟1发芽并重复这个过程来选择自己的领地,然后海龟2,依此类推。重要的是,新海龟应该避免穿越其他地区,不能采摘已经拥有的补丁 问题:海龟需要在已经拥有的补丁周围旅行。补丁的价值(效益/成本)应根据所需的实际旅行距离,而不是欧几里得距离,准确地计算成本 我该如何将其编码为实

我正在Netlogo中模拟领土殖民化。海龟0选择一个区域中心,然后通过按值顺序添加补丁来构建一个区域。价值基于收益/成本,其中收益是斑块中的食物量,成本是距离区域中心的距离。海龟0在总面片值达到阈值后完成其领土的构建。接下来,海龟1发芽并重复这个过程来选择自己的领地,然后海龟2,依此类推。重要的是,新海龟应该避免穿越其他地区,不能采摘已经拥有的补丁

问题:海龟需要在已经拥有的补丁周围旅行。补丁的价值(效益/成本)应根据所需的实际旅行距离,而不是欧几里得距离,准确地计算成本

我该如何将其编码为实际旅行距离(即,在现有活动范围内的障碍物周围),以使海龟按实际价值的顺序选择补丁?下面是一些代码。有什么想法吗?提前谢谢

patches-own [
    benefit   ;; ranges 0.1-1 and represents food available in the patch
    owner ]   ;; patches are owned once selected for a territory

turtles-own 
   [ sum-value ]   ;; sum of values of patches in my territory   

globals [threshold = 25]

to setup
    ask patches [ set owner nobody ]
end

to go 
    ask turtles [build-territory]
    tick
end

to build-territory
     if sum-value > threshold [stop] ;; keeps picking patches for territory until I've met my threshold
     pick-patch
     reproduce  ;; sprouts a new hatchling when done building territory
end 

to pick-patch
    let _destination highest-value  ;; this is calculated in reporters, below
    ifelse _destination != nobody [
    face _destination forward 1   ;; turtle will need to avoid obstacles here, haven't figured that out yet.
      if patch-here = _destination
        [ claim-patch _destination ]
    ]
    [stop] ;; if there is no _destination
end

to claim-patch [_patch]
     ask _patch [set owner myself]
     set sum-value sum-value + (benefit / (distance start-patch))
     set pcolor [color] of self
     ;; etc....
end

to reproduce
  if sum-value > threshold [ ask patch 75 75 [sprout 1 ] ]
end    

;;;; --reporters for calculations:-- 

to-report highest-value  ;; calculates value, benefit / cost.
     let available-destinations edge-patches  
     report max-one-of available-destinations [benefit-to-me / cost-to-me]          
end

to-report edge-patches  ;; constrains to searching along edge of territory so it remains contiguous.
     report (patch-set [neighbors4] of territory) with [owner = nobody]
end   

to-report benefit-to-me
     report mean [benefit] of patches in-radius 2   ;; this is basically a moving windows analysis to find a cluster of high-benefit patches.
end

to-report cost-to-me
     report distance myself   ;; this is where turtle needs to account for actual travel costs (non-euclidean distance), including around other territories. how to accomplish?
end

你好!看起来您可能需要一个寻路算法来确定成本最低的路径。它们很难实现,但您可能有幸建立了一个节点网络,并使用它们来确定最短距离。检查或查看Netlogo中一些成本最低的实现。再次您好!看起来您可能需要一个寻路算法来确定成本最低的路径。它们很难实现,但您可能有幸建立了一个节点网络,并使用它们来确定最短距离。在Netlogo中检查或查找一些成本最低的实现。