|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false, T1 ?4 }. k) h
to go4 v3 l. @0 V' f
if not any? turtles with [not stopped? ] [ stop ] ' N; |# ~0 F" Y# J
ask turtles with [remainder who 5 = 0] [: ]! g" Q( G" M" u* J
set close-mates (turtles with [self != myself])with[5 J. d3 _( G6 K& I
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) J& G: c1 C+ I% m- W9 r4 _+ N
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) & V% G: B \1 ?- S- N$ _
and remainder who 5 = 0 " k I0 a z- n* i2 V6 b# _9 d
]
, V# ?# |) r' B1 _$ s2 s% ^$ jifelse any? close-mates
# i- ?4 X- S( [$ C4 i( x8 l[
2 ^7 j# ?; _) ~2 F# gset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
/ c! L* P. H6 Jface closest-one" y+ N( l" e! p: Z' _+ j% H
rt 180
' @4 X1 @# v' s' Mfd random-float step-size/ s, G4 Q7 e( }( o8 Q1 T1 L
avoid-walls5 I4 u' s# O+ W, \4 ~
set stopped? false]
' q, K, L4 N: S- j) `4 ][set stopped? true] # R9 N' W' g7 r/ O8 I& z! u+ k+ V
] |
|