|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" j% y! Q% P( {to go
. a( p% i' c1 o/ Aif not any? turtles with [not stopped? ] [ stop ]
/ W( }0 r( q, D$ d% M% `ask turtles with [remainder who 5 = 0] [
) V) |0 I$ |2 o ~6 uset close-mates (turtles with [self != myself])with[; y+ X. a0 t! Q$ |- y- O
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
9 @( r ?7 \) k8 h: b1 z$ |6 nand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
) x. i2 ~5 W; s* y$ g \and remainder who 5 = 0 ' Q& H7 _; ]8 A" k6 k8 v
]
- _! X; L+ w# qifelse any? close-mates 5 P" Q% c( a: ^- z. r
[ / I1 [* `+ p9 r5 x' Q0 l/ t; ~
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: t6 ?4 o! Z- G9 ^face closest-one
5 N7 N g- ~! Q5 @' o# T4 F" Trt 180
% B- ~4 G. _( {fd random-float step-size3 X% h& S2 \, a# \ ?, S
avoid-walls% l, j7 q, r8 x0 r' }
set stopped? false]
" H% z9 \- L- h% ?[set stopped? true] 6 t7 }" S% w$ l9 U
] |
|