|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! T% Q9 o% _4 ato go; h) v# @: M$ {
if not any? turtles with [not stopped? ] [ stop ]
( u3 E0 _# k1 `* Hask turtles with [remainder who 5 = 0] [' m0 D+ K: }+ c) n( P$ l
set close-mates (turtles with [self != myself])with[0 q3 ~2 Q; V7 }0 p5 n Z( T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
+ S7 }* H3 q' d; z8 `2 nand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 3 d B6 T/ A% C9 I: o9 v4 K
and remainder who 5 = 0
( @1 x1 \! E+ ^ P# ?, D]
4 F9 W& h; D4 i7 `, {: _9 wifelse any? close-mates
, J. j* h C3 D8 p3 H[
5 @9 N( v0 N6 U0 zset closest-one min-one-of (close-mates with[self != myself] )[distance myself]/ O2 V/ G* q/ l
face closest-one. {5 L; F- M6 m
rt 180
. G8 z( i; w- ?) s& K: s% j$ X* Afd random-float step-size
" B- J( v- b* Z" _& lavoid-walls0 `* N! c- f# I( E) n
set stopped? false]5 m0 Z: n: q5 t" S n& U
[set stopped? true] 4 |( U* L2 ?' D3 L, }4 M; Q9 W8 H
] |
|