|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
+ Q! d, H, O/ Y$ yto go5 N' x( F8 D( X/ k t; x* W+ O6 V
if not any? turtles with [not stopped? ] [ stop ]
2 K* f4 H0 c& Eask turtles with [remainder who 5 = 0] [
* W" Z+ O% U/ Z' o1 E2 C. h* nset close-mates (turtles with [self != myself])with[
& O' ^5 O; v2 _(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; M5 B1 N% r; W O7 Q/ R6 v; Pand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / a0 o" X+ ]- D/ e
and remainder who 5 = 0
' _ |: O+ X4 I; H& r]
0 N3 M2 i6 d& ~1 g, xifelse any? close-mates n7 v- L+ Z$ ~& W" Z P
[ 6 m9 c9 ~/ W' p. _2 J8 q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]! U7 ` J4 h4 p; z
face closest-one& s, @6 i; C- Z9 d; T) H% A
rt 180 \# z, g4 A( e) t0 C
fd random-float step-size1 C% h. }) w& T1 P' W) i% x
avoid-walls
' g1 s# Z2 h- hset stopped? false]* d2 o1 L% [) @, s, M- ~1 f( r
[set stopped? true] # F5 u; A* q, {
] |
|