|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
6 i1 E# X5 o1 ito go4 {" N6 e5 h3 p. o- D$ l& z
if not any? turtles with [not stopped? ] [ stop ]
V% n& b3 L$ N$ t# H. |2 kask turtles with [remainder who 5 = 0] [' y0 o7 {5 ~5 q. `& p
set close-mates (turtles with [self != myself])with[8 ?$ `& E5 M& _
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* h% V$ p# A" c, @/ Jand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
* R2 o: t: l$ I/ l# Yand remainder who 5 = 0 6 h% Z3 U$ E" G9 \% ?( j* b% m
] " Z4 ^" C" n( T. d) K2 C+ n
ifelse any? close-mates
9 @+ v) U$ M$ R[ 7 ~7 @. n2 t& f% x) Z$ l- r
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
6 e+ ?. Z8 o! x% F* L0 }- J) N& s; Nface closest-one3 c7 }9 n8 e+ c* e
rt 180
8 j8 T6 f8 K! ^0 A8 @fd random-float step-size+ h: b" D* ?1 }4 h q0 p
avoid-walls, h$ z/ ?% Q, l( m
set stopped? false]
; Q1 ~. |) s$ R[set stopped? true]
! L+ \( m& C4 a* P/ {6 v& ]& Z5 J% ]# m] |
|