|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ E- w/ S5 |3 _; W" _0 S! c' hto go
f2 b; w* G: s$ gif not any? turtles with [not stopped? ] [ stop ] / K0 H* I1 ^" w% x6 v1 _
ask turtles with [remainder who 5 = 0] [: V7 _3 y0 o7 {* J6 P) d! E
set close-mates (turtles with [self != myself])with[
- Y' ^! z* G' F* M(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( I6 C5 Y6 C* S. s$ v, r1 Zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 D- h) R6 @1 ^0 Z! k" }8 ]: Z" I. n
and remainder who 5 = 0 6 ]6 M4 j" {* G
] + `+ `7 x# q, C8 i: k1 o
ifelse any? close-mates 9 I% r5 v$ Y% r9 H- [5 C# o; u
[ , B& Y0 x; Z* g/ u1 i" ^( { p
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 \4 e) p( |4 h& v! Rface closest-one
6 d- O) u) M/ H+ Frt 180
/ W% w/ p3 k: }- x# G; Hfd random-float step-size
1 I3 ?+ P( P+ r- g! D+ h4 _/ Uavoid-walls7 k, z C; ~( t4 ?2 Q( a6 Z
set stopped? false]4 n7 o% M/ l. H+ ~
[set stopped? true]
) r1 n( w' @- z] |
|