|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
: e4 C6 ]' X& u% xto go( c( {4 G( B7 v% ?4 x8 ~( Y3 ?
if not any? turtles with [not stopped? ] [ stop ] - L& a( I7 A5 Y3 U" T. ?3 P$ B0 f
ask turtles with [remainder who 5 = 0] [; r- I3 y) P Z% L6 W0 K
set close-mates (turtles with [self != myself])with[: K2 k" p9 A& [5 {# N
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# q& t: j/ _5 ~, P: Eand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
" G# Z9 w' B8 B4 g C5 }4 {$ fand remainder who 5 = 0 - n% Q' ]3 h& y6 }) M4 {
]
8 i8 b; R: n- {" y Jifelse any? close-mates # {0 P5 m! |" r; ? m
[ ; w- l1 `7 h6 I
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]0 N' r3 o7 s' W, }8 g. p2 x
face closest-one
+ `! N) r3 Z5 d& }! Rrt 180
* {3 K7 j" r8 Q' y( ?fd random-float step-size
! l" B5 X' |8 n& Iavoid-walls
& l9 Z- t) y9 u) K, J t* l; zset stopped? false]7 k* e& {* n1 U! ]( p
[set stopped? true]
: y- U+ K/ u1 w p4 g] |
|