|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false- H* P, E) T- u
to go
( t5 l. ?& `2 x, P, yif not any? turtles with [not stopped? ] [ stop ] + t5 i2 Z4 @5 X# }6 _2 H) ]
ask turtles with [remainder who 5 = 0] [
! N6 f$ b' p4 H: t( v0 Qset close-mates (turtles with [self != myself])with[* x; d# I* X2 ^. o+ |; a, e. i
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) : y8 ~' V* w$ r' p' L9 ~1 S
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / q8 g8 w! b; o4 F! Y! a$ S
and remainder who 5 = 0
; [9 e V! k. F* r2 w [( k" o/ M]
. T! ^# y; k7 ]" O1 R$ ]& A' vifelse any? close-mates 3 N) O+ ?" q( W. \
[
7 T/ s/ t: ]1 S# cset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 V6 E2 @& N! ]0 V/ X& Dface closest-one
/ M: h, m$ e8 }& wrt 180
5 [6 z$ z# B2 j) s& o @0 |fd random-float step-size* B- u s1 m! Z; b8 t
avoid-walls
( p. K: @6 u% Y) wset stopped? false]
7 ?& t8 z7 i( t; c% O3 g2 C5 T% {[set stopped? true] 1 |4 |0 f3 e8 G$ F3 Z/ v% ^; J9 Z
] |
|