|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false- h3 a$ Z! L5 z1 z3 L* n; [
to go- g5 Y$ d: S; S% u0 n
if not any? turtles with [not stopped? ] [ stop ]
& J; f2 a ~9 @, h/ P/ zask turtles with [remainder who 5 = 0] [
1 n/ [+ s! B/ T/ m bset close-mates (turtles with [self != myself])with[# c _, K, Y& T( B9 F% v% u
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
6 Y, t5 `0 c* g) D! S, sand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
2 T6 C7 l% Q% n. c8 Qand remainder who 5 = 0
# h. X9 }8 D% T4 G% J]
( N- N9 g( X( X6 |* \& F, rifelse any? close-mates
( m( j1 X# t4 ~[
. \6 ~5 d8 O/ |( h2 B. Tset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# I: R+ ^7 @7 L( Q- uface closest-one9 {1 u; W$ s6 ^3 o8 N: ?
rt 180
* n R' u5 H! P- B9 Y& Pfd random-float step-size1 ^7 i w& J y5 p2 V) C
avoid-walls
" p3 Y$ b6 O: C$ E! o* @set stopped? false]6 C7 ^. `4 N7 H8 w H( d
[set stopped? true]
# {; Y* f2 D+ q1 N. t] |
|