|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) |. E! y) u7 r8 j$ P" J* _6 Vto go
, x# F0 q% w. `2 Z. oif not any? turtles with [not stopped? ] [ stop ] + d* O4 R9 N/ d( ^8 F H
ask turtles with [remainder who 5 = 0] [
8 M" j5 o7 w3 w# oset close-mates (turtles with [self != myself])with[3 L3 l6 @8 A7 Z' {4 |% Y
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# i8 o, a0 M" l0 \and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 8 w6 Q0 B5 k5 I5 l P9 r* B: R
and remainder who 5 = 0
5 u$ E# t' `% A$ T/ L% o]
+ A& p0 M# m+ d {, U0 I; nifelse any? close-mates
( I, w& f! J* ^( W: W: R, d[
5 G4 m2 g9 o: n. Q. B( Uset closest-one min-one-of (close-mates with[self != myself] )[distance myself]- `# l7 S7 P' I2 w
face closest-one$ [1 g8 c* x& e q. u" g8 V
rt 180
0 X% c5 s& t& s' f4 e* Gfd random-float step-size! B% `0 Z7 E) q# i
avoid-walls
/ x- X R) M& R0 dset stopped? false]- Z l4 U2 l2 P) \3 O
[set stopped? true]
4 C" o7 b, T z% [+ h] |
|