|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false' _- @' M, `$ R* @% M; t
to go
, T" M# F: E8 ]/ m9 T5 Eif not any? turtles with [not stopped? ] [ stop ] : Z# s3 ~8 O4 M6 D9 @6 m9 C: E
ask turtles with [remainder who 5 = 0] [
& P* N4 {( x, q; _$ ]- P( pset close-mates (turtles with [self != myself])with[
) `+ P# C! W: Y3 f0 w(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
, i: ]! m3 Z0 _& O* Iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! C: G2 c; p/ }and remainder who 5 = 0 3 v( s3 P! r% ^( `" u4 g% W0 w/ N# }6 x
] 2 a9 |$ A, a" Q
ifelse any? close-mates ) @. Q; T. V6 Y1 K& o% d) h0 F
[
7 q/ u6 E( H9 ~1 V; a' Qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# e1 s. G/ q# `0 h8 R( Qface closest-one; d8 c+ v1 W/ N' H8 G& r
rt 180
T: P$ T1 j. j" U0 {fd random-float step-size H) _- e$ R; \! C
avoid-walls! b3 l E/ g; q2 o
set stopped? false]' {/ J" U5 u) H# j
[set stopped? true] ) q+ [$ W0 r; u; r# a0 o' X, k
] |
|