Reputation: 71
I need to set a turtle variable in a range of values randomly, the range must go from 800 to 1000.
I wrote this code:
turtles-own [income]
to setup
create-turtles 100 [
set income range 800 1000
]
end
The code is not working.
I tried ramdom-float but the values range from 0 to max value.
Upvotes: 0
Views: 1321
Reputation: 3806
range returns a list of numbers between the start and stop, where you want to choose a number from a range---these are different.
I didn't find a random-range or a random-uniform, so these are some approaches:
You can do a random number between 0 -200 and just add 800 to scale to your range.
turtles-own [income]
to setup
create-turtles 100 [
set income (random 200) + 800
]
end
Alternatively, if you want to create a list using the range function and choosing one of them.
turtles-own [income]
to setup
create-turtles 100 [
set income one-of (range 800 1000)
]
end
Upvotes: 4