|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ Y( f( c+ @, b. g ?to go
8 s9 D2 @( F7 @" W6 W. B+ zif not any? turtles with [not stopped? ] [ stop ]
3 L- i. h- k. Q$ u4 dask turtles with [remainder who 5 = 0] [5 n Y" X$ V5 U5 Y4 i2 _
set close-mates (turtles with [self != myself])with[
" k0 v2 `. a% m) v7 ~. Q(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 7 o/ [) Z I2 U$ y$ j
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) + _) d6 ]" h8 Y- ?1 Q1 F T, w
and remainder who 5 = 0
B8 g' ^+ s) D. f( K% J( [] ( n/ a6 K, v% }: {. s" y9 I# M7 J3 r
ifelse any? close-mates 0 b) X0 f$ m& B
[ & X3 z+ p$ l ?7 @4 I1 S* B
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]( Q9 i/ Q8 J, m( k) p' T8 k
face closest-one! D/ J3 l& S6 r2 @( H
rt 1807 x" I6 W' [" G- s, h }
fd random-float step-size' l4 H/ C0 L5 X4 y6 P( \/ q
avoid-walls) {8 g d3 X4 E
set stopped? false]
, V' J7 }8 q4 n- g[set stopped? true] ; n* ^- U4 [4 k8 E2 Y
] |
|