2016-04-14 44 views

回答

1

,你可以這樣做:

let my-turtle one-of turtles with [xcor = a and ycor = b] 
ask my-turtle [ whatever you want it to do ] 

但烏龜座標的浮點運算。所以你不應該試圖去檢查這個值是否等於某個數字。

你怎麼知道它是在(a,b)?如果這是因爲它滿足了一些條件並移動到那裏,那麼爲什麼不在滿足條件時將它標爲你想要的那個?

0

假設的補丁會做(或者,如果每個補丁只有一個)任何龜:

to-report who-at-xy [#x #y] 
    let _candidates [turtles-here] of patch #x #y 
    if (any? _candidates) [ 
    report [who] of one-of _candidates 
    ] 
    report -1 
end 

這就是說,你幾乎可以肯定應該有海龜,而不是直接與他們who號來工作。

相關問題