|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false; I1 p! L6 q* E' e C7 k! u
to go% S7 _4 L. D. W$ K' ~
if not any? turtles with [not stopped? ] [ stop ]
5 ?1 G2 Q, K8 S0 U% d Mask turtles with [remainder who 5 = 0] [: J9 j7 O0 d6 f) r- R7 _" g
set close-mates (turtles with [self != myself])with[
3 e- W5 n3 n+ h% k(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 P: ]+ D$ c, Q' o& Band (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
: U7 A/ W m5 _# ?0 Z5 [% tand remainder who 5 = 0
5 i3 ^6 Q: T- O% h% m2 A/ S]
* C, ~' a |, [; _ifelse any? close-mates ' b( l% p' b' W8 Y8 q
[
% ~& h0 [) K% C, c1 M# Sset closest-one min-one-of (close-mates with[self != myself] )[distance myself]. @* J5 }9 R3 a' V7 E) E- Q
face closest-one" t( d; D* a" S# W: d& ^& \
rt 180: Z+ G0 M7 a" `. Z) I
fd random-float step-size
6 B5 u0 g1 M# j Bavoid-walls3 g: b' p( r+ R+ \+ ]4 H, m+ G9 U
set stopped? false]
- ]' ?( g1 U& V[set stopped? true]
d0 ^: }/ g6 X7 r3 E& J/ {8 N' ?] |
|