|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
$ U* m& _* U& w4 Q3 J, a1 p3 tto go9 |# W0 n8 p* j
if not any? turtles with [not stopped? ] [ stop ]
4 }! W2 v1 n! Mask turtles with [remainder who 5 = 0] [
/ I8 T; |' c; fset close-mates (turtles with [self != myself])with[/ k: O% g7 x3 t& h6 g) {, v* U
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* n$ M7 E# u0 o" {$ x/ e( Kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . m$ x0 x0 N% x
and remainder who 5 = 0
+ x/ V6 N0 t6 ]/ i% H]
5 ~! p1 f3 k( ]0 M2 `( Xifelse any? close-mates
. d2 j! @; }$ X8 F) w. `% A[ 9 b8 ]9 c1 M9 s
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]1 B# r' J$ h+ T2 b2 o/ Q. U. e
face closest-one G& G# y7 H( \% G% s" e8 B5 V- G
rt 180' j0 M9 d$ [# S8 _5 R1 r, Q: y V
fd random-float step-size
9 F# ?/ @1 w9 J4 ?! ^avoid-walls
* o" o3 u; v) `; r) p2 Hset stopped? false]
8 F- ?( \& a4 E; G. C. [. S: C/ F[set stopped? true] , q: T/ ^5 J q7 A' K7 W, G% v% n
] |
|