|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
6 M1 P0 `- v2 t: S0 ^to go
& c4 U5 U Q+ r/ g6 ^+ hif not any? turtles with [not stopped? ] [ stop ] - x. s" `5 p3 |2 k* l2 @) @
ask turtles with [remainder who 5 = 0] [0 C+ n2 s- S- L% K- {3 G
set close-mates (turtles with [self != myself])with[; ]0 V7 d9 B' G" `9 d3 u8 L
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 f( F7 K0 F9 {: S$ w+ gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ! w8 y) ] L' R" o1 Q# W
and remainder who 5 = 0 k ]+ b" \( T0 E
] 4 @: R6 K, V7 p" V
ifelse any? close-mates 5 [. j% I3 x% O5 z. S" ]
[ + |1 R- `: L% R3 M
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
7 E0 a, y* G0 D c4 nface closest-one: _4 g$ q1 Q; x6 x( k) X
rt 180/ w5 E7 K/ O: L8 e- q! z
fd random-float step-size ~5 S- Q% Y6 b- i
avoid-walls7 g' i3 Q! B# e* ]/ g7 X# T
set stopped? false]
B0 X4 v3 b( w- q$ R3 D$ p[set stopped? true] ( {7 w4 T, g; R6 w3 O. N" k" `2 X# a
] |
|