|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: Y! f3 {) V' s0 W7 P0 U
to go
" V0 y2 ^$ C, K. tif not any? turtles with [not stopped? ] [ stop ] 7 S. d9 {0 w3 j. _$ h. a& h* }
ask turtles with [remainder who 5 = 0] [
$ T l! A$ P- X& j7 _- i, hset close-mates (turtles with [self != myself])with[$ r2 O. o0 \3 g# m7 J; k
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) $ |' b+ t9 M2 F- P' L4 z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
7 I$ S2 v5 w: U! O$ hand remainder who 5 = 0 : t u- p2 t8 f: G9 z3 D
] : k# I5 M, o# P/ R1 t
ifelse any? close-mates . V8 X& @' C4 z6 a
[
) q# D/ }% X8 V" q! uset closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ p# m' O5 B1 X/ X7 c$ s
face closest-one7 S( Z- R6 `5 W1 o1 _1 J
rt 180 y. x. K) g% W3 F# y. C
fd random-float step-size
! Q: E5 f; Q& H( L% Savoid-walls
$ _8 M- B$ X" lset stopped? false]* o' I* P+ d9 |/ a. q
[set stopped? true] ( a0 S% T0 D7 s2 q4 C
] |
|