2

I'm fairly new with coding and Netlogo. I hope someone could help me. I have tried and checked different models in the models library and samples in the internet. I still can't figure it out

So, my question are as follows:

  1. Is there a way to set a value to a certain patch color? to be able to attract the turtle to that patch color eg. I want the pcolor = orange to have an attraction level of 5 and 10 for pcolor = yellow

  2. If the value of the pcolor is already set, how to make turtles stay on the patch? eg. since pcolor = yellow 's attraction level is 10, let the turtles stay for 10 ticks), so turtles will stay on patch longer

I can already make the turtles go to the patches with orange and yellow.. here's my code:

to go
  if turtles = 0
  [ stop ]

  ask turtles   
  [ 
    navigate 
    attract 
  ]

  if ticks > 120 [ stop ]
  tick
end


to navigate
  facexy exit-x exit-y 

  if any? neighbors with [ pcolor = gray - 3 ]
  [ die ]
  ifelse any? neighbors with [ pcolor = gray or pcolor = orange or pcolor = yellow or pcolor = red or pcolor = black ]
  [ 
    facexy exit-x exit-y
  ]
  [ rt random-float visitor-view-angle lt random-float visitor-view-angle ]
  fd .5

end 

to attract
  ;; awareness zone
  if pxcor >= -4
    and pycor >= 9
    and pxcor <= 4
    and pycor <= 15
    [fd 0.5]

  ;;attraction zone
  if pxcor >= -4
    and pycor >= -8
    and pxcor <= 4
    and pycor <= 8
    [ rt random-float visitor-view-angle lt random-float visitor-view-angle ]
     fd 0.5

  ifelse any? patches with [ pcolor = orange or pcolor = orange or pcolor = yellow or pcolor = red ]
  [set heading towards one-of patches with [ pcolor = orange or pcolor = yellow or pcolor = red]]
  [fd 0.5]

   ifelse pxcor >= -4
    and pycor >= -15
    and pxcor <= 4
    and pycor <= -9
    [facexy exit-x exit-y]
    [fd 0.5]    
end
Lyne
  • 51
  • 4

0 Answers0