|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
9 H( b6 K5 L, V) S2 E( N Ato go1 `* ^* s3 R4 f8 x
if not any? turtles with [not stopped? ] [ stop ] . \( F( a5 l/ H8 Y. K8 V
ask turtles with [remainder who 5 = 0] [
/ C9 u! Y @# S, u2 d# vset close-mates (turtles with [self != myself])with[4 k h- T# z# B5 q+ c: a
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) % l& y% s) O# w/ e0 p. ^# O, D! j
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ! l6 ]" K1 {5 f# D7 z
and remainder who 5 = 0
7 A. {' u. m5 \0 K! n' m$ e] # X `; J. y2 m0 L; N
ifelse any? close-mates
/ e3 P) _) s. t: L[
) @# ?- B. O7 |: ^3 T2 \set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 k: t) Y) K: a9 sface closest-one
! c- O5 A2 V3 L2 S; Z$ C8 P( H5 urt 180& a: h9 l$ {. Z4 Q5 s9 |! G( v7 I
fd random-float step-size- W/ J3 i% V- i6 x3 ~3 e
avoid-walls
# U8 }4 ^. }! O$ o0 ?5 Y1 C1 gset stopped? false]
' o! l% w. }2 N0 t5 Z% }3 v- a[set stopped? true] 7 V' m) C: K n6 e3 {3 A
] |
|