|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
1 T9 l' r7 y4 S- |' B9 V1 Y: Ito go! V$ E( c4 D) y7 a3 |
if not any? turtles with [not stopped? ] [ stop ] ' S/ {5 u7 d9 B( |1 w# H
ask turtles with [remainder who 5 = 0] [6 J1 P' K1 ?/ h- c- t
set close-mates (turtles with [self != myself])with[
3 b6 @% Y- J, K9 O( X- O, ?# G v6 [(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) / f3 b8 i5 K5 d e' A' w, u% U
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " Q; S7 b8 U. F3 I6 H
and remainder who 5 = 0
7 j) x" o1 M! [4 ~% ?]
: |: s5 `, @1 O( Eifelse any? close-mates
0 V5 p0 ]. r( T6 R" _[ 0 S" j |0 R! Q; v# ^% Y# A
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]& }' s& V" Z, ?5 [6 y! y$ J R. l
face closest-one) N9 i3 u& u3 a! a5 g6 [ r8 @$ {- x
rt 180
B+ t( p/ g4 C: o4 h& Sfd random-float step-size9 w E1 J5 u4 W4 F9 v3 c5 v: }7 x
avoid-walls \. N, k# M! V. N3 \* |, l. T
set stopped? false]
, G8 o+ D0 W! K8 o6 G( O ~[set stopped? true]
U: E& S7 v' }( T9 x% k] |
|