|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false% S2 w5 j l3 ^$ [. m! g5 s3 e
to go
/ M- v5 s/ F9 K6 vif not any? turtles with [not stopped? ] [ stop ] , p l" @5 ^& q% s
ask turtles with [remainder who 5 = 0] [
4 E1 I' C" E9 f0 t. g! K( Vset close-mates (turtles with [self != myself])with[7 O& z( o, F( D" @6 b
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ( ]4 i- R# ~% u( K$ I6 r; d
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
5 v4 m* B7 r* a. C" ^* cand remainder who 5 = 0 / q3 h# s# N) y8 U% U
]
2 G- X8 j" Q" w1 Q" d! B5 @: U# Nifelse any? close-mates
8 a6 `: Y; ?5 u% n; T O6 g5 D[ 5 E/ X: y N- f2 u/ q
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]; B0 p' R9 V! C; {
face closest-one
; \, n# `. n. q4 e( D- I$ V. nrt 180
6 m1 J5 i A/ Y( U6 i7 A: Ofd random-float step-size3 ~$ W+ C5 h D) x3 W) P
avoid-walls
) l) \2 S; x8 B# D6 K0 @2 F: yset stopped? false]
! H8 k' t. a k3 L+ P* m3 W: [0 H; j[set stopped? true] . U: J+ c9 @6 t/ o% i% a& R
] |
|