in a NetLogo model, I have some "plant" turtles in a space. The number of which is 5, and will always be 5.
set-default-shape plants "plant"
create-plants 10
[
set color green
set size 2
setxy random-xcor random-ycor
setxy random-xcor random-ycor
]
At the moment each of these plants randomly spawns in the world. I want to be able to set the point at which each of these plants is placed.
Something akin to:
setxy plant-1 25 25
setxy plant-2 25 25
Is there any way to achieve this?
Currently, the line setxy random-xcor random-ycor
is setting the x-coordinate and y-coordinate of the plants to random values. Note that you seem to have that line in your code twice. The first instance of it gets overwritten by the second. Anyway, you can also use setxy
to move plants to particularly coordinates, e.g. setxy 25 25
. However, replacing setxy random-xcor random-ycor
with setxy 25 25
would put all the plants at that location. I assume you want multiple plants in multiple specific locations. To do that, you can just ask the individual plants to move:
ask plant 0 [ setxy 25 25 ]
ask plant 1 [ setxy 10 40 ]
and so forth.