|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false5 r I7 @& W I- C* m- }
to go
# E6 j( @ e' m; g+ }: Wif not any? turtles with [not stopped? ] [ stop ] - s" B. x: @) X
ask turtles with [remainder who 5 = 0] [+ i) q4 |: O1 {! Z4 Z
set close-mates (turtles with [self != myself])with[
- d# A( [. N2 N(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) * E" D& L+ o. J( i; d5 ?- z- u A
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
, ]: z4 |" D. C# Y, rand remainder who 5 = 0 ! q9 v) M1 Q: z0 }0 s
] 9 Z$ N o5 ^; {& @
ifelse any? close-mates . _9 ?0 \$ v0 }2 i& l) X( D3 |4 d. ]
[
/ D- t! m3 b- ~( u# C4 a9 [% ]set closest-one min-one-of (close-mates with[self != myself] )[distance myself]) v* ?) C8 i* k' x+ L
face closest-one
2 d7 V" c) Q; m& F1 Urt 180
' y7 r( p4 F' }( `fd random-float step-size
! ^0 S* C t* B8 U9 M" v& H: oavoid-walls
5 R0 a& r4 p9 L* t; Q2 }# {set stopped? false]5 h$ l1 w9 h2 l- a& O y( N
[set stopped? true] , @0 {+ ^5 N) b: p0 p" V
] |
|