|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false0 J6 Z/ @" I7 R) g% A
to go7 ?+ D1 C7 }* s1 y
if not any? turtles with [not stopped? ] [ stop ] ! J) n/ R4 d* o I" ^; z7 X
ask turtles with [remainder who 5 = 0] [" j6 a/ `$ I: W+ o3 e+ ~
set close-mates (turtles with [self != myself])with[
9 g" v* ?$ }+ C4 q: }* |(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
, r4 g/ B) h4 M+ b+ ]and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ' H/ ]8 A. a5 j0 Q4 ^1 Y
and remainder who 5 = 0
3 b* ]- J- z, K, A1 N] / c& M' B; L# A8 n5 \
ifelse any? close-mates 6 k% h7 l4 T8 u) {( ], }
[
4 U, K0 C/ l6 A3 W. sset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 ~) S3 {1 q, ^1 z6 u6 Mface closest-one2 x3 u- w$ @. }; d1 E3 @
rt 180
+ F2 V7 E0 W+ N5 v# m& mfd random-float step-size8 j( H. q5 v E- `, L; ]& Q8 @
avoid-walls
1 L: u) A, A7 t! K$ Z2 Y6 kset stopped? false]
4 y- p% `, [, h. P" k( l[set stopped? true] 3 I3 W9 X, d* m4 t# [7 |9 R" W8 R
] |
|