Reputation: 823
I have the following code in the setup procedure in netlogo
set-default-shape Mappers "target"
create-mappers MappersCounterSlider
[
set color red
set size 1.5 ;; easier to see
set label-color blue - 2
set xcor 10
set ycor random 11
]
I need to change the random 11 to a specific value for each turtle I create, for example if I have 5 turtles I want to have 5 turtles in diffrent 5 fixed positions.
Upvotes: 1
Views: 1099
Reputation: 17678
You can also specify the position during the create process by incrementing a global variable. Like the following:
globals [posn]
to setup
set posn -10
create-turtles 5
[
set color red
set size 1.5 ;; easier to see
set label-color blue - 2
set xcor 10
set posn posn + 3
set ycor posn
]
end
Upvotes: 0
Reputation: 1445
If you need specific y coordinates for each turtle I am afraid you are going to have to set them yourself.
If you don't care about which turtle is at which y coordinate, you can have a list of possible y coordinates, which each turtle will then remove from to determine their y-coordinate
For example, if you needed the turtles to start at y coordinates 1, 2, 5, 8 and 9, create a list:
let y-coordinates (list 1 2 5 8 9)
Then when you create your turtles, set their y coordinate to be a random element removed from the list.
let remove-index random length y-coordinates
set ycor item remove-index y-coordinates
set y-coordinates remove-item remove-index y-coordinates
That way, if you want to add any more fixed y-coordinates, you can simply add it to the list.
Upvotes: 2