|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
% H! e, M5 n/ W; p4 i7 I Wto go6 _& m* D8 _ X" v
if not any? turtles with [not stopped? ] [ stop ]
6 Y2 `6 O7 Z3 y/ O9 dask turtles with [remainder who 5 = 0] [$ C# @- e" N+ x$ E
set close-mates (turtles with [self != myself])with[
) b9 G* Q/ s- A! |" n1 m/ u(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 G6 o" p+ ~$ \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
+ d+ E3 v0 X- G1 o& N% Qand remainder who 5 = 0
! h- N7 J F- {3 G5 o]
/ v# u1 i8 Z: x" r* Q2 sifelse any? close-mates ( @) }) r9 S4 `- r) p
[ , }" N! }' q1 U9 w* D
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ l' h3 h' H0 y2 m9 R# _3 e' p
face closest-one
' ]4 y0 ]# ?7 Q' g5 w! brt 180
9 g1 V3 E/ g3 A+ ~fd random-float step-size. S! c* a" w N e6 d4 _
avoid-walls5 H, |0 O: I; r: k
set stopped? false]( |5 ?4 \1 I2 z1 R3 E
[set stopped? true] ! Y/ o* F# t3 p& t
] |
|