问题
I have a patchset subtractset
and some of patches have turtles on it.
Now, I wish to create turtles on only those patches which have different x-cor
and y-cor
as the patches.
Note: This is different from below code:
distribute-turtles (population * percent) subtractset with[count turtles-here = 0]
as here a turtle maybe on patch and still have different x-cor
and y-cor
as the patch.
Thanks. Please let me if there is some ambiguity in my question.
回答1:
Patches have integer coordinates so one way would be to check if the turtles coordinates are integers. round xcor = xcor and round ycor = ycor
Is true iff the turtle is centered on a patch
Or because turtles have access to patch variables
xcor = pxcor and ycor = pycor
Which is more pleasing to my eye and probably faster.
You could put it in a procedure.
To-report centered
Report xcor = pxcor and ycor = pycor
End
来源:https://stackoverflow.com/questions/26690556/check-if-turtles-have-same-x-coordinate-and-y-coordinate-as-patches