|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
4 Z r1 }. w& K" _' {3 oto go
- V4 h% m/ b3 [% D& j# w9 t9 {if not any? turtles with [not stopped? ] [ stop ] 7 Q" M8 l$ M7 w" b# T# l3 }
ask turtles with [remainder who 5 = 0] [% W& j1 G8 V, V
set close-mates (turtles with [self != myself])with[
+ G& X- ], I% P(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
4 P* c, X% e/ y$ J3 |' v x% H9 mand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) & |/ t, `5 u. [4 b
and remainder who 5 = 0 2 X- U+ T8 l! t& H/ N
]
! E5 |+ `; S4 K! l4 r V) R4 S: Qifelse any? close-mates 6 ] i/ _3 C8 v
[ ) c8 j" q. |$ }2 e* o7 |0 r
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]! N7 f: _) O2 S& y* B! Q* k. Y
face closest-one
2 p( p+ d1 D5 u3 k0 Q* brt 1809 J7 \0 j& x6 Z2 j5 w
fd random-float step-size, I+ d" |0 \/ T% S& [
avoid-walls
% J' U2 C6 g! |" S: n, u. t) [set stopped? false]
6 G- ~. H9 u4 L4 {[set stopped? true]
7 ^! o6 {% d& Y% x] |
|