|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false1 K% L9 m y8 ?( y) h. |/ O
to go* o; f8 @ c* p& i, f2 S* j" @
if not any? turtles with [not stopped? ] [ stop ] 4 r/ D: j Y- {$ w" A
ask turtles with [remainder who 5 = 0] [
v- }- H* X- S$ zset close-mates (turtles with [self != myself])with[5 ?: N, _0 G# ^/ Z$ E
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
! N G) q2 \, k+ G- D5 d" \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
) l) R& G8 Y" m- w/ P7 |$ \7 [4 Band remainder who 5 = 0 $ _9 t+ b0 }; n m; A+ u
]
3 ?5 n6 ~( W$ D7 s* h: `5 pifelse any? close-mates
2 J. D$ o5 B: y( [0 A$ t: R[ 0 c; n" n" ]- s: Y L! U
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]! E- w. N& S/ }" T
face closest-one
+ }) C' h5 Z7 `& ^rt 180* g o4 P m8 o4 [) t$ K$ {
fd random-float step-size9 ^4 ~; u/ \" ?3 H1 R% N
avoid-walls/ V* M! X. m# ]
set stopped? false]- F0 V8 J6 q! f/ B, r1 f
[set stopped? true] " W k. a$ [3 U) s
] |
|