Reputation: 924
I'm attempting to make turtles move based on their score (0-1 continuous scale) such that the lower the score the earlier the movement. Unfortunately I've completely failed on coming up with something that works. The code to make the turtles is:
breed[a]
breed[s]
turtles-own [score]
set population 100
to make_turtles
create-s (population / 2)
[set color blue
set size 3
setxy random max-pxcor random max-pycor
set score random-normal 0.75 0.1
if score > 1 [set score 0.9999999999]
if score < 0.5 [set score 0.50000001]
]
create-a (population / 2)
[set color red
set size 3
setxy random max-pxcor random max-pycor
set score random-normal 0.25 0.1
if score < 0 [set score 0.00000000000001]
if score > 0.5 [set score 0.499999999999]
]
end
and I have them moving properly, I just need them to move in order of their 'score'. Thanks in advance for any tips!
Upvotes: 2
Views: 149
Reputation: 3806
You may want to sort the turtles by their score and iterate over the resulting list asking each turtle to move.
foreach sort-on [score] turtles [ ask ? [ move]]
Upvotes: 1