|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
. m$ N4 K; u& {to go Y: K9 J! E; h6 C% X: u
if not any? turtles with [not stopped? ] [ stop ]
1 I6 }9 G/ N% A8 iask turtles with [remainder who 5 = 0] [
" s% |/ N1 |8 ?4 jset close-mates (turtles with [self != myself])with[6 R. C$ V% O+ E: r
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) X2 v' D7 Y- L9 b% ~/ [0 [4 ~; H0 zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ; q4 L$ K0 J2 H; b; D3 B$ w7 f7 {
and remainder who 5 = 0
# p( m- ~& `1 t] " Z( F, ~# Y5 s9 H
ifelse any? close-mates 8 F: N, V7 ?2 U& D
[
# g& [/ v7 j& I% @4 Aset closest-one min-one-of (close-mates with[self != myself] )[distance myself]' b/ ?, t9 }3 U4 g8 ?0 t
face closest-one
' v( v4 ^$ A5 S) z$ g9 a; yrt 180
5 C) z! j( |& Pfd random-float step-size( ^) F# `" k2 [
avoid-walls3 t0 u' t2 T8 [
set stopped? false]
+ e7 U& l, Q# A; l) a[set stopped? true]
3 ?0 K6 C6 z2 q$ p, [] |
|