|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false" q& m0 `1 d; p1 ?% y
to go
. i1 H; Y; R: q! D+ f9 Iif not any? turtles with [not stopped? ] [ stop ] ! S/ N1 K0 S# Y3 m
ask turtles with [remainder who 5 = 0] [9 c! _5 Y0 d' k! A2 j( o
set close-mates (turtles with [self != myself])with[" m3 t, T* ~+ K
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( X6 Z. _! r$ Z4 F: K Nand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % S/ P& N) ~5 f, e) K6 g
and remainder who 5 = 0 : l2 `1 b3 B* U) r; v" @8 \& u
] * \, E: Q$ a7 L* P/ P
ifelse any? close-mates " a7 D7 b! x) T0 a" \
[
7 u( v, ]; r1 V( H8 ]; y7 Wset closest-one min-one-of (close-mates with[self != myself] )[distance myself] l1 x& ^! C* A0 G% X/ m
face closest-one
1 Z* g: `# I1 U* \rt 180
* a: A( T4 F' W* R, |fd random-float step-size# i& {# h, l; C* Y& s5 T$ I& r
avoid-walls( L0 f* y* B9 w+ z; t
set stopped? false]" U9 n7 }' V: c) f/ H" w& |4 @
[set stopped? true]
. R8 _1 B5 _: g5 A2 Q6 w+ @' H] |
|