如何将变量设置为每次滴答减少 1 而不会低于零?
How do you set a variable to decrease by 1 each tick without dropping below zero?
我想知道如何编写一段代码,使 "excitation" 在 Netlogo 中每次滴答减少 1 而不会低于零。
到目前为止我已经想到了这个:
set excitation - 1
你的意思是像这个带有条件的递减计数器,"if excitation > 0"?
globals [ excitation ]
if excitation > 0 [
set excitation excitation - 1
]
我想知道如何编写一段代码,使 "excitation" 在 Netlogo 中每次滴答减少 1 而不会低于零。
到目前为止我已经想到了这个:
set excitation - 1
你的意思是像这个带有条件的递减计数器,"if excitation > 0"?
globals [ excitation ]
if excitation > 0 [
set excitation excitation - 1
]