|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
5 w' G: f( F" Rto go
& f, B! T3 N- F. vif not any? turtles with [not stopped? ] [ stop ] 8 ]$ P- g. C' D7 E: @6 x& V/ B
ask turtles with [remainder who 5 = 0] [
8 P/ A5 \; \1 g* E( e5 T/ Wset close-mates (turtles with [self != myself])with[
# Y6 A7 V6 B& N4 u2 m, F; m) l" i3 W(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) * e4 S0 \2 \9 D. [
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) $ \9 _, t! {5 e+ M6 P. G/ t
and remainder who 5 = 0 * c; s1 W. Q3 S* T7 F/ B! Y
] : _8 V+ b- f8 s) S7 c& K
ifelse any? close-mates % g5 R! |9 O5 a- W/ i- |
[
: p: B0 Q, A& Xset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
$ t, d4 T7 u$ y% \face closest-one6 |+ j5 n1 ~2 R# w( }! a
rt 180
5 q) X' q& t( g" U( |% sfd random-float step-size
; r% y9 f3 E# z% U& ~# |0 o- wavoid-walls3 U q7 E% t0 P, W
set stopped? false]; D# L# O8 C* {! N H: M! V, m6 Z9 W
[set stopped? true]
8 Z u7 h5 ]0 p7 ]( E" Q. }% C] |
|