|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false! W5 i, L- \0 I
to go
: _6 Q L3 e' H. P% f! Pif not any? turtles with [not stopped? ] [ stop ]
: D& `9 Z, [1 ~$ |: u, Lask turtles with [remainder who 5 = 0] [
; w' H7 |9 Q: t5 `% Bset close-mates (turtles with [self != myself])with[* E: ?6 L2 I7 m& w( V, Q4 y. Q
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) , h4 }1 G: |4 f4 u/ D9 D- @
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
- a. `- K4 p- h7 ^% w, l: k7 C% t/ f4 `and remainder who 5 = 0 $ c4 b, E0 Q5 {4 |
] # Y( _: K. }0 T) L) W4 g
ifelse any? close-mates
$ }' _) g3 x8 z8 D. a: K; e[ : r, l' A3 c+ i0 U+ c4 H! n7 L# W
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. g7 O1 T5 h; {( D6 o8 q9 J! ~face closest-one! V! e9 i; t$ \( L
rt 180 L' Y3 N; [- K4 N2 T! k& ^
fd random-float step-size3 s+ _' _+ D# [: P6 G
avoid-walls, {; M( w9 d* s8 W+ {3 h. x0 l
set stopped? false]
% w1 O: g3 X# F[set stopped? true] ! h& l4 z( V5 `; Y, R& C+ A, [
] |
|