|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
' Q: b0 ~5 ?3 U! J4 }/ `; q) ato go
# }9 v; J0 V8 N& {if not any? turtles with [not stopped? ] [ stop ] 5 x" o3 H" W' f4 ?6 p" ]5 y% F
ask turtles with [remainder who 5 = 0] [0 j# S0 N- x( _) s
set close-mates (turtles with [self != myself])with[# H: a# U" K V
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- P" c$ m" K* F) E9 sand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , H# E! L v6 z
and remainder who 5 = 0 2 X) k) \8 l% O @% @1 b
] ( b' M$ {1 Y$ H! k1 I# I
ifelse any? close-mates 2 L# h) Q6 M4 D+ A$ a
[
, G4 I8 w( S1 Kset closest-one min-one-of (close-mates with[self != myself] )[distance myself], }/ k% a( H2 B- m
face closest-one, x i% _- h$ V4 o! ?1 z9 b) s, f
rt 180
8 p1 C+ p) w& S5 T( Wfd random-float step-size
! S1 t9 h4 T9 e# z r5 W8 savoid-walls
$ s3 z! U( U0 C5 Y6 e# Q2 ^% xset stopped? false]+ C: t0 _9 P) P: e( y C2 q4 V
[set stopped? true] 8 T5 z. o- Z/ y
] |
|