Search code examples
listcolorsnetlogoany

Netlogo: change turtle color from set of list with condition


I have this set of code. The agent is "consumers", where it has variable "type-of-value". I am trying to change white turtle into one of color on the list of "type-of-value". But I keep getting "expected a constant" error message.

to develop-needs
  if ticks mod 5 = 0 [
    ask consumers [set type-of-value  (list blue red green)] 
    let a count consumers with [color = white]
    if any? consumers with [color = white]
      [ set color one-of type-of-value ]
        ask turtles with [ color = one-of type-of-value ]
      ]]
end

Any help would be appreciated.

Thank you


Solution

  • This code finally work. Thanks to JenB I noticed my mistake.

    to develop-needs
      if ticks mod 5 = 0 [
        ask consumers [set type-of-value  (list blue red green)] 
        let a count consumers with [color = white]
        if any? consumers with [color = white]
          [ ask n-of (random a ) consumers with [color = white]
            [set color one-of type-of-value
             set value? true]
             ]]
    end