|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
4 ]% a# j G' ?to go
) v5 X: w; b) ^+ _" G" q5 _if not any? turtles with [not stopped? ] [ stop ]
/ k; z! f: t! r; ?& ^ask turtles with [remainder who 5 = 0] [- w1 g6 ~# D8 Z5 f
set close-mates (turtles with [self != myself])with[/ y& M; s1 C; j
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
, P$ V7 h' I" q" _and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % V2 F& Y2 g+ W
and remainder who 5 = 0
/ E7 f% w' b/ j] g4 X1 A* o. W
ifelse any? close-mates # v; D# D; \* j$ F
[ m: M6 C3 c9 N# n7 w+ S3 x) b
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]" _2 }; S, b1 }0 |8 n
face closest-one+ Q: G. i0 J* D/ i$ d) ~
rt 180
. }! i5 ^. r$ s) x9 Gfd random-float step-size, A) W7 s3 q5 N, n6 q7 h& q/ b8 i/ u* Q1 z
avoid-walls
! T1 P. t! a% A5 g8 sset stopped? false]
! f, ]& o; u4 Y& h/ _6 r[set stopped? true] ) X( ?7 q7 S. p& E
] |
|