I have two breeds of turtles, call them mobiles and immobiles. In my model the mobiles visit one immobile and then move to the next immobile and so forth. My problem is when both breeds are set with:
setxy random-xcor random-ycor
some of the turtles are partially or wholly off the grid. How can I set both breeds so they are off the walls and completely visible?
Thanks, RB
It’s worth noting that NetLogo is not a grid like we tend to think of a grid… the patches centers are the integer locations.This means that for a world with the min-pxcor of -5 and max-pxcor of 5,There are 11 patches acrossThere is a line of patches at xcor = 0The minimum xcor is -5.5.The maximum xcor is 5.4999…The world-width is 11But (Max-pxcor - min-pxcor) is 10So, placing turtles at random xcor and ycor means some of those turtles (drawn with size 1 shapes) may hang over the edge.If you want them at patch-centers, use random-p_corIf you want them at random locations except for a border around the edge, so none hang over, useSetxyMin-pxcor + Random (world-width - 1)Min-pycor + random (Workd-width - 1)If your are using a turtle size other than 1, to get the same visual effect you’ll have to adjust the above to account for size.E.g.Let gap (size - 1) / 2SetxyMin-pxcor + gap + (random (world-width - 1 - gap - gap)… and so onNote that doing this means your turtles are no longer evenly distributed, in that a .5 patch border is always empty. Be aware this can cause undesired biases or other artifacts in some models.Hope this helps~~James
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/49f7e06c-1b4b-4f5c-9f9d-9fa81bcd4364n%40googlegroups.com.
It’s worth noting that NetLogo is not a grid like we tend to think of a grid… the patches centers are the integer locations.This means that for a world with the min-pxcor of -5 and max-pxcor of 5,There are 11 patches acrossThere is a line of patches at xcor = 0The minimum xcor is -5.5.The maximum xcor is 5.4999…The world-width is 11But (Max-pxcor - min-pxcor) is 10So, placing turtles at random xcor and ycor means some of those turtles (drawn with size 1 shapes) may hang over the edge.If you want them at patch-centers, use random-p_corIf you want them at random locations except for a border around the edge, so none hang over, useSetxyMin-pxcor + Random (world-width - 1)Min-pycor + random (Workd-width - 1)If your are using a turtle size other than 1, to get the same visual effect you’ll have to adjust the above to account for size.E.g.Let gap (size - 1) / 2SetxyMin-pxcor + gap + (random (world-width - 1 - gap - gap)… and so onNote that doing this means your turtles are no longer evenly distributed, in that a .5 patch border is always empty. Be aware this can cause undesired biases or other artifacts in some models.Hope this helps~~James
--
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/CADiHOG61RrToRECCkDMPUw5jfWQ4ZsrteKUdeZWonUD4EyZOvw%40mail.gmail.com.