Ok!
So one idea that may help is that most things happen one at a time, and that there's an idea of "what agent" is running any particular piece of code..
So if you're using a patch variable, then a patch or a turtle needs to be running the code.
Also, some folks seem to get lost around ask turtles, and forget that if code is running "inside" an ask turtles code-block, thats a turtle running the code, so there's no need to ask turtles again ... That would be one turtle asking all the turtles to do something...
So, you might do something like
To move-turtles
;; Comments help you and your helpers understand your intent
;; Writing the steps out in human language helps you be sure you know what you are doing--that it makes sense
;; It helps helpers to let you know if your intent was fulfilled by the code
;; Every turtle does this
;; If the current patch elevation is not within a certain range,
;; The turtle does not move
;; The turtle moves forward 1
;; The turtle turns the new current patch red
;;.the turtle subtracts 1 from the patch safety-level
Ask turtles
[
If elevation > 0 and elevation < 730
[
Jump 1
Set pcolor red
Set safety-level safety-level - 1
]
End
This is probably not what you actually intend
Maybe you mean for the turtle to not just stop but turn away from the elevations that are out of bounds.
If that's the case you need to think hard and write out exactly what you want to happen (in human language terms, like you are teaching a child how a game is played)
Once you have that figured out, you can try to code it.
Hello,
Thanks James and Stephane for your responses.
I am trying to make turtles move with a constrained elevation range (patches in my model have two variables patch-safety-level and patch elevation)
so what I am trying to do is:
to first make turtles move with a constraint patch elevation range
then make that turtle change its pcolor
then reduce safety-level of its patch
Thanks once again and really appreciate your help
Souzan😊