|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false/ ~& p6 `6 Y: G7 O: z: s
to go
% e" D; [2 {1 h8 f: m, U0 @if not any? turtles with [not stopped? ] [ stop ]
1 L: R# K3 j9 e# c& dask turtles with [remainder who 5 = 0] [
2 J+ F& g. p" b/ a" [9 S# h) Tset close-mates (turtles with [self != myself])with[
- o, b! j3 e- ^/ k2 M' h; @7 Y(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) / d' Q7 q( G! ~5 k' B
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
4 w/ S e6 F" t: H! p% {0 j" Xand remainder who 5 = 0 4 x- c" @; O2 U6 n8 V/ K8 d6 q! e
] , _8 l C. \5 b' b$ \. B' c% {% F
ifelse any? close-mates
2 q; h% m& @1 H: \( Q# V) S[
" z3 f Z) Q" \& G5 w* ?set closest-one min-one-of (close-mates with[self != myself] )[distance myself]1 _. H& W$ D# }: B `& L
face closest-one8 _$ ]6 P9 N* b3 d" R* m
rt 180
, G& A7 d/ L, u6 x; r; w( Xfd random-float step-size; }' V8 V) G: ?$ i- x4 } Y$ L
avoid-walls
! W; i; Z. y7 E! O: w% J! [% `; Vset stopped? false]* j9 p3 N: t$ S- C/ J9 w
[set stopped? true] 2 j% W1 R. S4 R5 B/ G7 K! A! |
] |
|