|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- ?9 M7 k4 H1 c- e0 zto go+ ] y5 q7 H5 T- p5 w" T
if not any? turtles with [not stopped? ] [ stop ]
( l: L1 q c% z* N0 g* }+ K" n! Hask turtles with [remainder who 5 = 0] [
$ P0 L1 N+ e, Tset close-mates (turtles with [self != myself])with[: x0 [! ^* w3 L
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 y$ x" T; M# _5 w) E
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
{ ]3 ~+ f1 g. U& K+ band remainder who 5 = 0
% r. a3 R! h% m; C* o7 S]
3 e' O! Z1 R5 o3 @; m7 sifelse any? close-mates
% E; x2 v+ X7 S! N. o[
9 P! M Q* k0 F1 q$ E- m5 h8 x9 O* lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
" b# [& V9 H+ }- G8 j8 Z! `; Tface closest-one
7 g9 a9 k+ G: K7 q2 }4 crt 180
3 s1 Z, v8 }6 o. l% {# g7 @& bfd random-float step-size1 c& L5 L: E0 q
avoid-walls
! t; r5 i" |/ _set stopped? false]. Q) `' [' \2 b* V2 i, Z
[set stopped? true]
! H# R* e. n u1 ~' Y" Q6 i& u1 ?] |
|