RubElias
RubElias

Reputation: 11

Netlogo Random Number of 750 turtles should change color after 40 ticks to red

I am new at here and a total beginner in Netlogo :) I am working with the Schelling's segregation model in NetLogo. Currently, I want to change the color of 750 randomly choosen turtles to yellow. This should be done at the 40th tick.

Following you can find teh relevant part of the code.

to go
...
  if ticks = 40 [
    ask n-of 750 turtles [
       set color [yellow]
    ]
  ]
...
  tick
end

If I run the model, it stops at tick 40 and give me a runtime error with the following content:

"An rgb list must contain 3 or 4 numbers 0-255 error while turtle 2036 running SET called by procedure GO called by Button 'go' "

So, I would like to know where my faults are and if my idea is right to address the task.

Thanks a lot ;)

Upvotes: 1

Views: 134

Answers (1)

JenB
JenB

Reputation: 17678

You are very close. You need [ ] to get the value of a variable, but you don't need them for setting it. Try this:

to go
...
  if ticks = 40 [
    ask n-of 750 turtles [
       set color yellow
    ]
  ]
...
  tick
end

Upvotes: 2

Related Questions