Reputation: 896
I am trying to place turtles of type beacon (a type I made) on all patches that are Red in Netlogo with one beacon placed per red patch. Here is my current code, but I can't figure out how to get the coordinates of the current patch, or to just place the turtle on the current patch if it is red. My code is below.
ask patches [
if pcolor = red [
sprout 1
[
set breed beacons
set size 3
set color blue
]
]
]
Upvotes: 0
Views: 662
Reputation: 14972
Well, aside from minor stylistic issues, your code is basically correct, and I am not sure where you find fault with it. I would go with:
ask patches with [ pcolor = red ] [
sprout-beacons 1 [
set size 3
set color blue
]
]
...but it does the same thing as yours, which is to "place the turtle on the current patch if it is red", like you say you want.
And to "to get the coordinates of the current patch", you can just ask a patch for its pxcor
and pycor
variables, e.g.: ask one-of patches [ show (word pxcor ", " pycor) ]
.
Upvotes: 1