1

I'm modeling territory colonization in Netlogo. Turtle 0 selects a territory center, then builds a territory by adding patches in order of value. Value is based on benefit / cost, where benefit is amount of food in the patch and cost is the distance from the territory center. Turtle 0 finishes building its territory once the summed patch values meets a threshold. Next, Turtle 1 sprouts and repeats the process to select its own territory, then Turtle 2, and so on. Importantly, new turtles should avoid traveling across other territories and cannot picked already-owned patches.

The Problem: Turtles need to travel around patches that are already owned. A patch's value (benefit/cost) should account for costs accurately based on the real travel distances required, not euclidean distance.

IMAGE: As a visual, here is one result from running this model. The turtle in lime green has a huge territory that required traveling over other territories and did not account for actual travel costs around what should be considered obstacles.

How might I code this to account for actual travel distance required (i.e., around obstacles of the existing home ranges) to have turtles pick patches in order of real value? Some code is below. Any ideas? Thanks in advance!

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
User847462
  • 81
  • 10
  • 2
    Hello again! It seems like you might need a pathfinding algorithm to determine the least-cost path. They are tricky to implement, but you might have luck setting up a network of nodes and using them to determine the shortest distance. Check [here](http://geospatialcss.blogspot.ca/2016/01/path-finding-model-using-a-star.html) or [here](http://modelingcommons.org/browse/one_model/4079#model_tabs_browse_info) for some least cost implementations in Netlogo. – Luke C Mar 21 '17 at 01:20

0 Answers0