|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, T) F. g, c( e2 c( f0 e4 v! qto go! ?0 p3 e1 ^4 _( H# b: G
if not any? turtles with [not stopped? ] [ stop ]
4 D0 G. X( J% Z ?5 Oask turtles with [remainder who 5 = 0] [
! `" ]& a% ^$ T0 j' b" Jset close-mates (turtles with [self != myself])with[1 \6 w8 }; ^. [9 y: g$ J
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
7 J; _1 t/ ~0 K: f$ kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
8 a9 I( y2 u2 G+ }8 kand remainder who 5 = 0
' z- \/ t' M% ^2 `]
4 z3 L) [4 V2 {+ fifelse any? close-mates
4 @# I7 a' d+ o2 s! s[
5 I1 d+ Z5 C# |1 rset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) u- n" N# k5 s8 ^' g& z1 Wface closest-one, k. r6 I. `) c* \
rt 180
5 N) B3 Z9 P4 S; p. Kfd random-float step-size
" H/ p6 H# S' K) @. p' iavoid-walls1 P5 r: r `: a _, t* m. G
set stopped? false], ^9 z1 ~% R$ u S
[set stopped? true]
: X9 U i- z5 t( p6 v] |
|