Reputation: 651
So I'm writing a short programme in net logo where I want to color code my turtles based on a variable that they own view
which varies between -1 and 1. I tried using color-scale
in netlogo to define the colour, but it doesn't do quite what I want.
I wrote this to describe what I want, but netlogo seems to be getting confused when I pass the col
variable to the set color
command.
to colorise;;------------------------------------------------------------
; this changes the agent's colour based on their current [view] score.
; We could use the color-scale in netlogo, but it only works for one colour
; and it's easy to end up with a colour so dark we can't see it against black patches.
moderate ; resets any agents which have somehow ended up with a view score outside -1 to +1
ifelse view > 0
[ let col ( 1 - view )
set col col * 255
set color [ 255 col col ]
]
[ let col ( 1 + view )
set col col * 255
set color [ col col 255 ]
]
end
does anyone have any ideas?
Thanks!
Will
Upvotes: 1
Views: 284
Reputation: 9610
Assuming you have correctly limited the range of view, you will just run into a list creation problem: you cannot use the bracket notation with variables. Instead try
set color (list col col 255)
etc
Upvotes: 3