我想節省烏龜運動的計算時間(這裏發佈的問題:NetLogo: how to make the calculation of turtle movement easier?)。在原來的移動龜過程作者使用許多「讓」 - 局部變量。我想我可以用內置的NetLogo原語p.ex輕鬆地替換這些「let」變量。這裏:NetLogo:使用局部變量「let」保存或增加計算時間?
; original code with "let" local variables
let np patches in-radius 15 ; define your perceptual range
let bnp max-one-of np [totalattract] ; max of [totalattract] of patches in your neighborhood
let ah [totalattract] of patch-here ; [totalattract] of my patch
let xcorhere [pxcor] of patch-here
let ycorhere [pycor] of patch-here
let abnp [totalattract] of bnp
ifelse abnp - ah > 2 [ ...
可以用這個條件代替嗎?
; make the same condition with NetLogo primitives
ifelse ([totalattract] of max-one-of patches in-radius 15 [totalattract] - [totalattract] of patch-here > 2 [ ...
請問,利用「讓」局部變量節省計算時間還是會花費更多時間?我怎樣才能輕鬆驗證它?感謝您的時間 !
(PS:以下評論我剛纔的問題我想是原語的變量將更有效率,我只是喜歡更肯定)
謝謝@JenB現在更清楚了! – maycca