|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
/ I" g& ^5 o7 {9 \" Tto go: C- G# d- J7 k7 [0 M' v* ~
if not any? turtles with [not stopped? ] [ stop ]
- `' ]+ Y! x) S. V; E5 m. vask turtles with [remainder who 5 = 0] [
# \6 f3 f4 ~2 v7 L0 c3 [set close-mates (turtles with [self != myself])with[, j( s: r" m# P- V! ~
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) + G0 `# m0 e1 ?& t6 R( m
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
" }- }9 B3 f7 y% T( r* Mand remainder who 5 = 0 ) T6 `( } x7 M* m6 q( O, M+ T
]
$ ?! c; c9 y G5 Y3 z; `% Z) mifelse any? close-mates : Q+ S+ F, L- Q( n5 z k
[
: o- L& E/ R3 W7 Lset closest-one min-one-of (close-mates with[self != myself] )[distance myself]7 j0 Z9 l8 N/ [& Z# S6 z, U e
face closest-one! \$ i5 B5 t8 b6 K8 b
rt 180
5 U7 @2 ]+ p( N( D) x: H, A* i& u0 Ifd random-float step-size1 Y( z4 _3 {8 X& f' C
avoid-walls
: I R( u3 \6 S) T: ^) U# t9 ]set stopped? false], S- Q& d' q; z
[set stopped? true]
6 t) U k0 h* G& q+ d) O- H] |
|