|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false5 }" y* [: D" c0 b Q1 u
to go4 T9 q4 k- d; w
if not any? turtles with [not stopped? ] [ stop ] * N8 h# I/ j1 m" G
ask turtles with [remainder who 5 = 0] [
) u& o' G6 w5 \5 d+ Iset close-mates (turtles with [self != myself])with[
5 G! z, |" I- S; g+ ]4 |(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
2 t, H8 x5 c$ F+ x; f/ c1 oand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , c. X/ m, P M% ]! \) s
and remainder who 5 = 0 5 P6 R6 ?* n+ o. U0 v
] # o2 Z2 l. a4 r1 F
ifelse any? close-mates
; J/ y& y& l o; j' J/ R6 ?( \) w7 Y/ Q: h[ 4 n- T7 X, P& A& i4 o* ] \- G4 y
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]8 L$ Y5 ?$ e' d- ~% p" O N
face closest-one+ C5 d# R* G6 C, J; A U3 Z# e
rt 180- T6 l+ H0 j' \6 r7 F8 ~9 e# }9 c
fd random-float step-size4 O( j0 _8 i# {5 H3 q2 a5 X
avoid-walls S; z+ P6 R' k& b: D' C. ~% a
set stopped? false]
/ r5 e+ {( j1 P[set stopped? true] 8 c, K* R+ `" S7 m. s" V% |
] |
|