|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
# e/ O! c5 h7 n; |" Qto go
* f& Y, m' O6 n7 k& Z" mif not any? turtles with [not stopped? ] [ stop ] % D, j( P" g6 {$ \. y; j' D
ask turtles with [remainder who 5 = 0] [9 l( J8 w+ P- A
set close-mates (turtles with [self != myself])with[
$ g- y i r# }* J, n(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
, H7 z) C) @1 M& u% oand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) # K j+ j( l' a; B
and remainder who 5 = 0
2 H7 R/ w9 j/ f] 0 W3 r/ r+ k7 Y7 Z0 u
ifelse any? close-mates ' F5 x+ c+ S- [: d/ ?
[
! H3 c. s7 h" E! Q1 F d& Rset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
+ l6 h( \+ s3 N2 lface closest-one
8 m8 t5 ?' k" S Yrt 180( b, x+ X& t# N7 _( ]& m' u; F
fd random-float step-size
) Y4 a' Y9 F1 c Q1 _avoid-walls
) r! t+ k+ a4 v+ X1 zset stopped? false]
# `( j% b" D, x. ~[set stopped? true]
4 X- h2 U" C, l% Q+ E] |
|