|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ [& e) v, n! r6 V2 }, Q. H
to go% |% V, `& b& q9 W$ }
if not any? turtles with [not stopped? ] [ stop ]
5 l( V0 G' ]$ P" m$ n% ^ask turtles with [remainder who 5 = 0] [
/ J( p. {* Q- V2 w$ J6 R eset close-mates (turtles with [self != myself])with[# s: f- i; W- F7 O+ O) v7 b
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 2 d3 ?3 y w) R6 \
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 e/ ~! j5 c& J9 E6 ^and remainder who 5 = 0
8 P7 e) ?) P8 ~/ ^$ C] ! a' r/ c! g! J$ v) |) }
ifelse any? close-mates
& Z6 D8 g5 }: J! l( ]. k% o9 N3 L[
" s! ]! a3 i0 u. |$ Iset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' w6 O4 U9 m1 wface closest-one4 ?1 F2 U3 N( y: I1 W) j
rt 180
& L" z- O% G! F' n ]9 Nfd random-float step-size2 x1 l2 x( C5 @$ S3 W* a3 g& Y. H
avoid-walls
; \/ F' S2 g- vset stopped? false]) N4 e! \6 D6 E0 G6 J7 f: a
[set stopped? true]
+ A9 K, q: l/ A/ d E] |
|