|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false- J0 C3 t% n9 Q7 q. U
to go8 v! g i3 p4 `' \* ~ \2 o N0 C
if not any? turtles with [not stopped? ] [ stop ]
3 s- x, p( T3 Z- m! kask turtles with [remainder who 5 = 0] [1 }+ }! r6 K( x+ G* \
set close-mates (turtles with [self != myself])with[. F! `' [/ r% m8 M8 y; J
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 v, c1 i- H' {
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
' K) \$ E$ y' ^; ]and remainder who 5 = 0
5 b/ l0 |( t6 m] d9 A9 B( ^; H" C
ifelse any? close-mates
: I2 }; z5 e- h[ , `5 `1 P$ ~7 |# E
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) C, D& y! Q7 H, M% n7 }face closest-one" ^8 T9 k% E' e! D# W I) f, o
rt 180
# G+ r1 V! L7 U# zfd random-float step-size5 b: D8 R7 [. d2 y- U+ L
avoid-walls
# b) |" b* Q! F6 a; Jset stopped? false]6 b! `( S7 v) F# Y% `: V
[set stopped? true] 5 g9 S- T- D8 c( B$ k
] |
|