|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- O) ?- P' M; M* K6 Z8 l; Nto go2 ^# i' z; G' B
if not any? turtles with [not stopped? ] [ stop ] $ z/ `- n. ?% y; k. e; |
ask turtles with [remainder who 5 = 0] [
( w2 u5 N+ v/ n! v8 t- e0 n) iset close-mates (turtles with [self != myself])with[
1 o5 v" b: \0 x$ T8 n l(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 s# _% p) i- a& M
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 6 c5 z/ j9 p- c
and remainder who 5 = 0 ) T4 b( |, i: `1 y
]
4 \) a9 I+ Y; c7 Zifelse any? close-mates
, T+ t4 z1 D, w# {* E4 t[
) W0 W/ q7 t1 L0 Rset closest-one min-one-of (close-mates with[self != myself] )[distance myself]: F. D/ [! T+ `: S! _2 e' c
face closest-one
( v# Z! L7 U* i' u- r8 Prt 180
+ I$ L' _! n5 N2 \0 O* dfd random-float step-size- k; C7 L, H0 F" O1 J
avoid-walls
4 u7 q. R# p2 B1 N3 ?% Sset stopped? false]
' W. E, P1 p, ?1 Z[set stopped? true]
2 @$ j; u$ {$ v0 N- [# y+ E] |
|