|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false( ?( Y5 n# A. d5 f8 L
to go" ]3 F% S( J) `4 c# V8 L% X8 p
if not any? turtles with [not stopped? ] [ stop ] ( [9 ~, b% Q$ ?4 R4 _8 d5 W
ask turtles with [remainder who 5 = 0] [0 o2 s$ H0 G I9 c" e; G% q
set close-mates (turtles with [self != myself])with[5 S2 V" a- x+ D* e1 i; R
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ! }& q( O! i' o
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: M% X3 a0 k3 C E4 i3 R. t7 nand remainder who 5 = 0
6 C* S0 u3 j1 e) V& a] 0 r8 {: A6 Y: e; J% i$ t# A0 c2 L3 O! N
ifelse any? close-mates 4 |' k5 P+ S! H' V* j, W
[ 3 c' w8 Z8 G m# X9 C; ^1 j
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
/ i) c. m$ N0 @6 A! J1 R' Oface closest-one
' n( U/ Q4 w' ^8 [: C1 y' ?' }rt 180 A5 F6 w0 Q& {. |. _
fd random-float step-size7 f) B5 `3 Y& Y0 V) N8 E
avoid-walls8 e& |$ j; n1 d" ^' {2 E! S/ Y8 G
set stopped? false]
+ }% J- n; e1 v1 |! Q9 o! b[set stopped? true]
/ Y: P# I3 k8 s3 Y2 \6 l- D2 s, o] |
|