|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false5 k4 X0 r7 m! J- |
to go
( W$ v% ? V$ U/ qif not any? turtles with [not stopped? ] [ stop ] 1 T0 M1 M, o' L* [! u% a
ask turtles with [remainder who 5 = 0] [
3 X! g. `9 F" Sset close-mates (turtles with [self != myself])with[* W- M+ y h" i6 k" Z
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) - }' c. J& T' f8 ]3 ^6 x
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& w9 f. V' h; T" ]and remainder who 5 = 0 $ w' r c( \( q" P2 }
] # O5 x# {/ x9 [! W: Z; D2 j! p5 k
ifelse any? close-mates # w7 @1 k- e9 |' t/ d
[
' }: {' F# E) m( T" C& S9 Uset closest-one min-one-of (close-mates with[self != myself] )[distance myself]" g( e0 j7 W$ N d6 e3 ^. P' }: g Y
face closest-one
8 p, b1 G$ k1 e5 k6 r. D7 S' |: _! Prt 180, Q1 U2 ^. ]: @7 S
fd random-float step-size
/ N" n5 R* T6 s- tavoid-walls
0 e! r9 T. Q# h) r. fset stopped? false] N% Y- f, I/ H* d' M1 ?; A
[set stopped? true] ! B4 s; O$ |* p3 T
] |
|