|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
. d/ ?( X, P p; rto go
5 n4 v9 _: s0 Z1 q& h& [4 oif not any? turtles with [not stopped? ] [ stop ]
3 ^# d$ a" C$ x9 T: \+ S# ~, e, y& V: Zask turtles with [remainder who 5 = 0] [0 F! U6 K0 K& z7 r5 |7 b: b
set close-mates (turtles with [self != myself])with[# b3 c3 n: F6 L: h3 B! B
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; ^" J, p. ~3 E3 ^and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
4 C% s# q- V# Y6 R9 i( }* _/ U6 X! K! Qand remainder who 5 = 0 , Z9 x* k0 }7 s" y. ^: f; C: n
]
0 T4 c# E) @% D( b1 o, mifelse any? close-mates
. {6 H0 C2 d, I4 f+ Y[
/ N u0 ^# c |) |- Lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 i$ @, x2 g$ z6 D
face closest-one6 X' X& ]7 m- h4 _: H
rt 180
! b6 _0 |3 E xfd random-float step-size% J0 d' M8 @; T7 h, H: ^& d
avoid-walls
4 k' f( B- u) P% r$ k' Aset stopped? false]
1 ?+ K N# X% r; W! Q# n[set stopped? true]
8 |7 j4 W% Z! d] |
|