Search code examples
positiondistancenetlogomin

Netlogo-initial position + measure minimum distance between a patch and a turtle/patch


I wrote this code, however, I don't know if it is correct (it is technical-grammatically correct). If you have any break time from eating Christmas cookies, please have a look and comment if my code is correct and Netlogo will do what I need.

My intention: on a map, create 6 subway stations, measure the distance from any patch on this map to the nearest subway (dt-subway), measure the distance from any patch on this map to the nearest patch with color green (dt-park)

breed [subways subway] 
patches-own [dt-park dt-subway]
to set-patches 
   create-subways 1 [set shape "ubahn" set size 2.5 setxy -14 -17]  
   create-subways 1 [set shape "ubahn" set size 2.5 setxy -50 -13]   
   create-subways 1 [set shape "ubahn" set size 2.5 setxy -27 -26]   
   create-subways 1 [set shape "ubahn" set size 2.5 setxy 20 11]     
   create-subways 1 [set shape "ubahn" set size 2.5 setxy 48 -20]    
   create-subways 1 [set shape "ubahn" set size 2.5 setxy 55 -35]  
   ask patches [set dt-park min-one-of patches with [pcolor = 64] [distance myself]] 
   ask patches [set dt-subway min-one-of subways [distance myself]]  

Will this do what I want? Especially with the dt-subway?


Solution

  • Maybe you can take a look at the Voronoi Model in the library,... essentially you are trying to do the same...