|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
. W$ R- u% _- P0 c& L4 r, d5 z. ~to go6 u7 i" I/ o. U# c; I1 P/ \
if not any? turtles with [not stopped? ] [ stop ]
8 S. X" P/ E$ l% w4 sask turtles with [remainder who 5 = 0] [
3 }5 }/ H# K( U7 x3 Tset close-mates (turtles with [self != myself])with[
0 H( |- c4 S6 X A(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
4 _2 {2 V* A9 B9 K& `7 x& A0 b, jand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
; _% y: v7 E6 `. V' V5 t9 Band remainder who 5 = 0 & H- n3 i% h; ]$ ^( k# l! Y
]
* z, y) C9 }$ u1 c! Jifelse any? close-mates $ F# d5 K5 F4 B0 M, x; i1 F
[ 8 N! m w1 t- Q$ t
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 c& R7 x6 J% Z& k' I, w# H5 z
face closest-one" T6 j/ o8 Z1 a
rt 180
2 L7 h, R" _, lfd random-float step-size
( ^/ E. N" l0 iavoid-walls
W8 b; q/ T% ]" e* Q( Eset stopped? false]
9 C; K; i$ W, ? t* U* |[set stopped? true]
7 V& S' o9 e" _8 e] |
|