2

I have an agent-set of all the turtles. I want to randomly pick 5 turtles from this agent-set and assign a value of 1 to them. The other 5, ones that were not selected should take the value of 0.

I tried using the random function but it's not working.

Raj
  • 1,049
  • 3
  • 16
  • 30

1 Answers1

3
turtles-own [attr]
to set-attr
  ask turtles [set attr 0]
  let my-agentset n-of 5 turtles
  ask my-agentset [set attr 1]
end
Alan
  • 9,410
  • 15
  • 20