2015-04-02 43 views
1

因此,我在網絡標誌中編寫了一個簡短的程序,我想根據他們自己擁有的變量view對我的海龜進行顏色編碼。我試圖在netlogo中使用color-scale定義顏色,但它不完全符合我的要求。在netlogo中動態更改rgb

我寫了這個來描述我想要的,但是當我將col變量傳遞給set color命令時,netlogo似乎會感到困惑。

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 

沒有人有任何想法嗎?

謝謝!

請問

+0

http://ccl.northwestern.edu/netlogo/docs/faq.html#listexpectedconstant – 2015-04-02 14:11:37

回答

2

假設你已經正確地有限的角度範圍內,你會正好碰上列表創建問題:你不能用變量使用括號標記。相反,嘗試

set color (list col col 255) 

+0

謝謝!我只是在學習,我認爲這只是一個相對容易解決的問題(不適合像我這樣無知的人......) – Will 2015-04-02 13:48:04