|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
/ U9 `; G8 d/ B4 _0 v/ u8 x' w: eto go
5 b2 p9 D) j8 W1 C) a8 }. J* qif not any? turtles with [not stopped? ] [ stop ]
. O! Q$ \4 @: F, ~ask turtles with [remainder who 5 = 0] [/ ^* j% H1 u2 i& F( `" {( I
set close-mates (turtles with [self != myself])with[
3 O' Z M- l8 F/ u9 F' ^# `- H7 U(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* R5 }+ W* n0 @+ P; Y6 U6 }2 Dand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
# k; C0 O% p5 u' a4 D! p, Iand remainder who 5 = 0 : M( ]# x8 t# y; K* b$ G- O7 D
]
; `5 i+ c. T7 M" `1 Jifelse any? close-mates 6 d- v- X! M% Q" }" w; f6 z# b
[ 6 F- s9 Y/ w, E- t4 g1 R
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]2 w4 f. J% \' M5 r1 N2 p
face closest-one) }0 C+ u( B/ T2 Z i7 | `" l
rt 180
9 m3 q5 a: }0 k$ Y+ [/ w+ g* q4 F) efd random-float step-size
$ A6 |2 k: [2 ]9 Kavoid-walls$ A9 M; u% M8 N% i" f+ L- H$ R% r- b
set stopped? false]# m9 S5 u: V6 P4 L% [) k8 p, V6 o' P
[set stopped? true]
* @0 u% V: k9 I$ \1 q9 \] |
|