|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
6 Q E9 v5 H- ^# {6 Vto go, ~; u" k7 b/ J3 B# v0 ]
if not any? turtles with [not stopped? ] [ stop ]
& N; k O0 v6 q! M! vask turtles with [remainder who 5 = 0] [$ x! _& F$ [* {4 n3 ~' ?
set close-mates (turtles with [self != myself])with[6 s# ?0 `8 o$ R$ g5 P
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( d P! R* R) Zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
5 l4 o% ~) X6 C v0 Y+ _and remainder who 5 = 0
8 [$ W9 D% M8 r* A; O% R4 X]
, p/ j# l% m& M3 t$ Wifelse any? close-mates
" D9 ~6 n) s, b7 h; `& S) p[ * _ r2 s. c" p, B8 G; N
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
z/ ]" E+ _" T/ d2 Oface closest-one) k% \7 {4 H* g4 h G
rt 180
4 z7 {. l, l2 X& C) W+ yfd random-float step-size. h' M% @3 C& V9 P/ g5 q. z
avoid-walls
0 x7 p. J. o7 @+ l2 E6 h) Uset stopped? false]
7 U3 J' x! ~7 }6 p" j+ j {( j* s[set stopped? true]
' c6 E1 E0 I/ J8 l! [' [] |
|