|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false& x5 H5 N: A0 {
to go
& f( q, a* i, Y/ k$ @ Cif not any? turtles with [not stopped? ] [ stop ]
: _" C; K$ G0 d' X" O9 G! ^ask turtles with [remainder who 5 = 0] [. f- [2 i9 ?# Q$ h. U# S/ q; R
set close-mates (turtles with [self != myself])with[( x3 `. f6 ^8 o
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- Q" Y# F/ A: O, T+ O! P4 zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % B5 a: s5 Y6 V0 O1 w# r3 D# G" p7 W1 e
and remainder who 5 = 0 ) V- X }" A" _# ]
] 6 `) a+ h B/ g) ~9 I
ifelse any? close-mates . U; A; a7 _* j, t' ], S! [
[ # I, c0 |% i1 G7 f u' R
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]9 i: z5 E; \ d! M
face closest-one
; f' @# `- b- s! ?, hrt 180
( l, L5 k1 |. \2 Yfd random-float step-size- ]# o3 I, o# h# H. I2 \
avoid-walls
2 o, h9 l) F0 R, M: w' I4 Jset stopped? false]( `- T- Q. f9 Y; n" h! @" U- ]
[set stopped? true]
, k4 H! O+ v4 J8 t1 `& z] |
|