|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false' I1 O; F$ G3 k6 T! }. N
to go
; b) J) Y8 i& I9 }if not any? turtles with [not stopped? ] [ stop ]
' k" U' W4 X; Wask turtles with [remainder who 5 = 0] [, E0 u$ K# |3 D: @6 ?
set close-mates (turtles with [self != myself])with[
. U( n2 }2 [% W9 O& h) g0 |(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; x3 X! O& W( |- l" m/ n. C# I7 ?% Band (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " H' N! K3 ]5 X) |5 K
and remainder who 5 = 0 6 i8 |7 v0 a3 v
]
/ p) W- v. t4 Q; D) ?# ^: P, |ifelse any? close-mates
% |& l8 x( p0 X6 k[
$ O* g5 [0 S% nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& w+ c+ F) p5 K& W& V/ L9 Vface closest-one% `) \; s; X0 h0 W+ [
rt 180, i1 _ [7 p' s1 l. l. f _. o
fd random-float step-size \6 D8 M9 ^8 p2 [6 T3 F
avoid-walls
8 V3 R0 p4 q9 rset stopped? false]
( C* n! Y' h' Q[set stopped? true]
* j3 } ~& D2 x: f' v* `+ f7 D2 s] |
|