|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! y9 H( W7 j1 n5 L4 {to go
. [7 X3 e( ]' u4 c( Wif not any? turtles with [not stopped? ] [ stop ] % G; C- `# k; h- t9 [7 Y5 O5 [( ]6 M" Y5 O
ask turtles with [remainder who 5 = 0] [
6 B+ O. b5 ]1 W& P, u/ W, oset close-mates (turtles with [self != myself])with[ Z9 b+ I. p: p+ K6 f
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) # M* H5 D, y/ ^" B: u
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: P, }" [1 Z7 b I' z/ W! fand remainder who 5 = 0
% q' y! f# r6 k5 J& W8 N] * [0 l& |2 y+ ^- r" x8 _ u
ifelse any? close-mates ' F8 B8 x9 [ k$ d: c0 h
[
% q- n/ q" P3 w+ H4 Yset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
* V* ?) V3 ]2 C; @' Xface closest-one
2 |" v, q3 l* W5 Brt 180
0 o0 V4 ?. I2 K2 Z! |fd random-float step-size
5 L8 }7 M! L f+ d7 Savoid-walls
9 U9 L+ Q2 [" q+ [9 w( qset stopped? false]
* t* y" i8 ]6 u) O' h[set stopped? true] % s' @( m: I/ z
] |
|