|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 G. k1 i2 W# E9 fto go
+ ^/ \ r/ \: ^6 ~4 nif not any? turtles with [not stopped? ] [ stop ] ; t4 a1 t# D2 o( {% u" f5 j+ R
ask turtles with [remainder who 5 = 0] [
( }! d p1 S4 y: b% E4 @. yset close-mates (turtles with [self != myself])with[. ]7 f3 Q( O! s0 f F, I
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 @2 _+ K0 \* A
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
6 g5 F$ D4 b+ m- y; T3 Fand remainder who 5 = 0 - H6 g# M e& ]) s% v, D
]
; d* q, W/ ^7 H$ d* M, J' {$ A* Pifelse any? close-mates ( [/ K6 G( L% k6 Q. e! C6 v& a: G
[ 8 V; K! \; h* L/ t9 G! }( R
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
( R2 j7 }& i& g5 R$ H& e6 wface closest-one
! c) `5 Q4 \. Crt 180* K1 }- y* O5 L) j5 G/ u
fd random-float step-size# c" J' Q: |/ p7 V2 Q' ^. [
avoid-walls: J9 \1 z5 N7 C/ l
set stopped? false]
) U8 y# J4 l% k6 I8 B3 P& y7 I[set stopped? true]
5 O- A7 q0 p1 s& {] |
|