我的所有补丁都有一个名为“温度”的变量,我正试图将所有的乌龟下坡移动温度。但是海龟也是地域性的,因此有一种称为“社会全部”的程序,使得它们在其领土内以最强的“力量”变量远离乌龟。
我正在尝试将两者结合起来,但我不确定什么是最好的方法。到目前为止,这是我的代码:
turtles-own [
rivals
nearest-rival
strength
]
patches-own [temperature]
to go
ask turtles [
social-all
tick
end
to social-all ;;avoiding each other
find-rivals
if any? rivals with [strength >= [strength] of myself]
[find-nearest-rival
if (distance nearest-rival < minimum-territory) ;;a slider variable
[separate]]
end
to find-rivals
set rivals other turtles in-radius (minimum-territory - 1)
end
to find-nearest-rival
set nearest-rival min-one-of rivals [distance myself]
end
to get-cool
move-to patch-here
let p min-one-of neighbors [temperature]
if ([temperature] of p < temperature) ;; could add another if here?
[face p
move-to p]
end
我想在“get-cool”程序中添加另一个“if”,也许就像“如果这里的乌龟[强度]&lt; [强度]自己”。那会有用吗?