2017-02-21 63 views
0

我有一個列表,其中始終只包含1只烏龜。它是一個膜片僅變量,因此,當任何補丁被檢查看來像best-turtle: [(turtle 1)].如何將1的列表轉換爲單個烏龜

我參考使用以下代碼在另一例程這個特定龜:

ask patches [ 
set closest-turtle best-turtle 
set pcolor scale-color ([color] of closest-turtle + 2) share 0 10 
] 

我得到以下錯誤:

OF expected input to be a turtle agentset or link agentset or turtle or link but got the list [(party 0)] instead. 
error while patch 4 -2 running OF 
    called by procedure UPDATE-SUPPORT 
    called by procedure SETUP 
    called by Button 'Setup' 

這是因爲最接近的烏龜變量是一個列表而不是烏龜。有沒有辦法將1的列表轉換爲烏龜或其他方式來解決這個問題。

回答

1

如果你確實相信總會有一個龜在你的列表,你可以用firstitem提取它:

set closest-turtle first best-turtle 

或:

set closest-turtle item 0 best-turtle