|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
o' B9 h; d( x6 M) @5 U. zto go
/ R- M$ Y" p+ Nif not any? turtles with [not stopped? ] [ stop ]
4 G4 D. t# H( S) w" Qask turtles with [remainder who 5 = 0] [
) m' }1 l# Z* i4 L6 u. L9 Eset close-mates (turtles with [self != myself])with[
# j# G/ M, e' ^& r) A(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) $ F" r/ g7 \! L) v# p
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
6 V* L& a% b+ [9 ~, _! J9 Z; U9 dand remainder who 5 = 0 * c, P5 u% F" ~& N
]
) R6 r- T6 s/ |$ Tifelse any? close-mates
1 Q( P& k J3 |: h9 T7 A" [$ P[ ! |# F4 P# e y/ c
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]! F7 Y3 Z: F7 z @4 l7 v# a
face closest-one3 ?" X- w: e+ u# R: [7 c
rt 180. _ ~% q$ a) t% E0 ^
fd random-float step-size# W; F; D5 ?& ~: z1 B1 @
avoid-walls. k+ J) F6 A+ `3 t, Y1 }) p1 }
set stopped? false]
) R9 b' |' B/ O6 z1 |6 n) W% e[set stopped? true] 0 {5 l7 S) @( Y! R; u7 Q
] |
|