|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 }+ W* c& v2 U" uto go
+ d' f; B! }) Z6 s7 Gif not any? turtles with [not stopped? ] [ stop ] 0 |! S: z: }0 E1 H6 j% R" } B. J
ask turtles with [remainder who 5 = 0] [4 f8 h, c* r2 M" j5 H( a7 l3 z
set close-mates (turtles with [self != myself])with[
' [3 X# p8 ]3 s6 P H! w(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( K' s B3 F, i9 hand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
8 J1 Y. y1 u: X$ \, @7 P- h5 Vand remainder who 5 = 0 ) n) @' r1 f7 C5 t1 D- @: j# n
] 7 @9 h) v$ R- {9 F/ g# O
ifelse any? close-mates
% [7 v6 ~0 ~$ [4 Y% p% _[
3 t% m: y n/ Y& i3 fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 q) S7 N! S( {+ k; s8 ]" _1 w8 wface closest-one
f) B7 O9 X, W- H. g8 g Grt 180
+ U R" p: E: _& ~- s, cfd random-float step-size
" f0 h4 x7 F5 ^1 C3 `: ^0 Wavoid-walls
' w4 Z) t$ B: P( hset stopped? false]
5 T/ W' b x+ q& N" v/ b/ O[set stopped? true] + k% b. D- I% K% G3 p g
] |
|