|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: |' B$ L( ?% S* Q
to go. W0 N/ h: j6 K( k( f9 \0 p3 r7 S0 ~
if not any? turtles with [not stopped? ] [ stop ] # T2 Y4 f' ]/ r6 P# W1 o3 A% Y
ask turtles with [remainder who 5 = 0] [* f7 h$ ]$ I' a( o( p
set close-mates (turtles with [self != myself])with[
; _$ m; V. U) }. A4 N/ i' i(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% @. P0 ?+ S2 g7 O* x" f7 {and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! K% Q+ u n* Y! b v8 gand remainder who 5 = 0 9 J$ @2 j. Z& q
]
9 k, |4 U- e: T; {, n3 N0 eifelse any? close-mates * v" x" F( I1 m: i
[
! Q/ C: k" X& w+ S, ]set closest-one min-one-of (close-mates with[self != myself] )[distance myself]- F& ^+ d) O0 Z: ~0 l: @5 f
face closest-one
/ U ^0 u# ^& k/ @0 R* I2 Lrt 180
' W1 M) e/ l( o9 W; ?# S" I8 ufd random-float step-size" |& P* n$ e% x8 @# Q( R
avoid-walls9 h( b+ C- X& ` k- e" \; j3 d
set stopped? false]& }4 O1 u" c% b3 e* X0 z
[set stopped? true] - w# G R+ l9 \% Z
] |
|