|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" F4 o/ Y& U# s5 e' n: q% U" {0 Bto go+ Z* p% |7 J4 B5 M& r; }" s
if not any? turtles with [not stopped? ] [ stop ]
' f2 d- i5 y& X; c$ Oask turtles with [remainder who 5 = 0] [! ~! I* c8 r% _2 c3 l: E% U2 k
set close-mates (turtles with [self != myself])with[# N& w3 ~6 \9 q+ G' C: R @
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* y! F& o' P. L: Gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
, }$ n9 j. u) }& L( D, hand remainder who 5 = 0 2 n4 L5 @/ S6 h# A! M: J
] 4 Y+ `. _: w* s9 l. Q" U) K
ifelse any? close-mates
' Q. {) N$ N6 q[
, j# C5 {8 n: C7 m0 nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]! y. o4 ?2 K- @. `
face closest-one
( P' M! t- i6 m; Z9 vrt 180; c/ F* z3 V+ m" o0 [' F8 q
fd random-float step-size( u! @. ~6 a0 ]5 W: [* j
avoid-walls
4 u6 R% J/ P# `set stopped? false]
3 F$ S( ?6 {. A3 c7 p2 O[set stopped? true]
: m4 f/ N: x& Z0 N/ ]( ]5 l; U2 y] |
|