|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- h; R! B% E: i; q' }to go
2 P* M$ t" r6 kif not any? turtles with [not stopped? ] [ stop ]
( I; e, \9 U& s! d, Q" T2 Aask turtles with [remainder who 5 = 0] [
. I) s% u L7 u* k; sset close-mates (turtles with [self != myself])with[, D# U- `6 S0 X( q4 [8 B; \7 k* g
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ; w5 q9 ^/ z% O6 D
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - g7 b; s4 H9 b% x9 ]# k
and remainder who 5 = 0
9 `9 |1 ?( D0 x8 u) W1 C] : a/ x6 X( X7 P7 g- i/ K1 s! p l
ifelse any? close-mates
! M& ?2 M$ f# \8 Z& J5 `, e[ 7 K; t' d* H) J% s
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
$ I! u3 t% l7 L* b9 h8 \. i) D7 jface closest-one. [2 ?$ F7 `7 q/ a
rt 180
5 M9 l, y% [* _' A7 J$ Gfd random-float step-size) J/ k9 ~, z0 d d; O% z
avoid-walls
* C4 q3 L; ` Z9 n4 e# fset stopped? false]8 I( R! \ @ n# b+ v; K. `; r
[set stopped? true] ; h7 o( v2 a7 @
] |
|