|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
5 X+ w m2 d9 c# A8 eto go+ q( F w, W( Q* M9 }
if not any? turtles with [not stopped? ] [ stop ]
. [/ W, }& [% Aask turtles with [remainder who 5 = 0] [* V; l _+ @ l& d2 d4 P
set close-mates (turtles with [self != myself])with[
1 [% U5 B D7 ~/ y* |( \" q(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- S4 L/ }' K8 ~( z0 ?- m/ k. F, @2 H {and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ E/ M0 b4 x( m
and remainder who 5 = 0 ; H1 B& W f) v/ V2 F
]
. s9 F' H; S7 A7 hifelse any? close-mates 7 R' [0 h9 r# F# [* P9 G
[
% d( x/ O% v7 j: H O" j5 h1 \set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) n( z9 ], L7 f3 y* Y1 T- m8 t, s' V2 a' xface closest-one
2 w9 O6 n; G+ g1 s; `( v1 vrt 180
5 l+ c: n" M7 m5 J& K' Ifd random-float step-size
1 g5 `. m: C! {8 e* G9 z+ iavoid-walls: B; @9 g. z, V2 p! V# ~$ _& o
set stopped? false]
+ F [. R) C, t8 W[set stopped? true] t3 Q. |0 ?9 f+ V5 B0 n. h
] |
|