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   

      if patch-here = _destination  ;; add the patch once reached
        [ claim-patch _destination ]

      if patch-here != _destination   
        [ if owner = nobody [claim-travel-patch ]]  ;; add a travel patch while walking to selected patch
        [ if owner != nobody [avoid-obstacle]]  ;; or avoid the obstacle of existing territories
    ]

    [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 claim-travel-patch [_patch]
     ask _patch [set owner myself]
     set pcolor [yellow] 
     ;; etc....
end

to avoid-obstacle
     ;; need to identify some means of going around owned patches
     ;; ideally this will use the shortest route possible....
     ;; but even if not shortest route, any ideas for identifying a new path
     ;; to avoid the obstacle and reach the destination patch?
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 patches with [owner = nobody]  
     report max-one-of available-destinations [benefit-to-me / cost-to-me]          
end

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

to-report cost-to-me
     report distance myself   ;; later, this will hopefully account for actual travel costs (non-euclidean distance), including around other territories. I think this is complicated, so ignoring for now in this question.
end

这可能会给你一个想法:如果你在这里没有得到太多帮助,可能是因为你的问题太大太广了。真正帮助你完成你所要求的一切可能需要我30分钟或更长时间。试着问一些小问题,一次一个问题?这些问题回答起来容易多了。谢谢,我把这个问题稍微简化了一点,以重新关注避障问题,并添加了一个指向一个单独但相关问题的链接。这可能会给你一个想法:如果你在这里没有得到太多帮助,可能是因为你的问题太大太广了。真正帮助你完成你所要求的一切可能需要我30分钟或更长时间。试着问一些小问题,一次一个问题?这些问题回答起来容易多了。谢谢,我把这个问题稍为删减,重新把重点放在避障上,并添加了一个指向一个单独但相关问题的链接。