|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
% Q, g8 {3 V8 c* Kto go- N0 [! V2 G' X3 f- N
if not any? turtles with [not stopped? ] [ stop ]
% |. f6 F( O+ M+ A3 B7 Eask turtles with [remainder who 5 = 0] [, G, Y# ]. T" P* b4 ~1 \2 [
set close-mates (turtles with [self != myself])with[$ x) ]5 D/ x5 p/ g7 c, {$ [
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 _# b3 k: D; p% n& k
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , [& x2 Y& _5 X" p" [& z+ [
and remainder who 5 = 0
1 t9 }3 e! b- [0 J]
+ z0 [2 E) {5 L: G( Hifelse any? close-mates 6 |9 N: c3 G( m% M4 f% I# {1 ]
[ % Y& B9 x3 j3 [3 F' q# M: W
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
+ o/ B' Y$ t. m3 Mface closest-one+ U2 F* v( V* V) H5 S, a6 U
rt 1802 o4 @* z3 w" {4 Q9 U
fd random-float step-size
+ D% P$ U- S) U- q( [avoid-walls
& r, i4 V2 d: j s, aset stopped? false]
9 j: u, P6 h' E1 d* O[set stopped? true]
/ z4 j& w4 |! _; a0 `] |
|