|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false+ v5 t" i, t2 I. a- E9 `3 D
to go; C- B6 g8 E. k0 O
if not any? turtles with [not stopped? ] [ stop ] ( d6 t9 o, X$ a
ask turtles with [remainder who 5 = 0] [
; b0 }) l0 [- s4 x. zset close-mates (turtles with [self != myself])with[; r) W+ V5 x) P8 H0 L8 v( ]
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* R* O: _' r$ R( @% nand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
) [) F, _& K! r2 F$ J( d3 oand remainder who 5 = 0
6 g. \( X/ o1 u- }9 D& b1 W] " J9 y& L/ f, J2 d& b
ifelse any? close-mates
, V6 Z1 [1 T1 A) |[
3 w/ c4 P6 `& b! _1 j" @1 dset closest-one min-one-of (close-mates with[self != myself] )[distance myself] f: f' @ ^8 j. Y. h
face closest-one. s5 I* r9 v* F; v: t
rt 1803 ^2 t' M. x4 B0 q3 d
fd random-float step-size5 Q1 j8 f1 J. q8 r. c- [
avoid-walls3 i: v. B3 ]2 z a9 t+ g* C$ {- s* w& t
set stopped? false] k+ z) N- e5 V. p9 Y' Q
[set stopped? true]
" o" a9 n# \0 v& w4 p9 e] |
|