|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false7 ?. b8 M S! R) Y% E
to go" R' P8 U/ O1 T: N& E
if not any? turtles with [not stopped? ] [ stop ] 5 p/ N s# t& u$ D0 X
ask turtles with [remainder who 5 = 0] [
8 Q. P- Z5 J6 G9 l, y/ h8 [set close-mates (turtles with [self != myself])with[0 a4 j8 V. `) {+ n3 f: M
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ! o) e2 u' `( x* j' ]7 {' y
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " ?' i( @& |, d6 n2 s. Y+ S
and remainder who 5 = 0
+ B) n( j5 ^2 Q! w9 z/ V8 z]
/ s/ c( j: U& i& _5 Iifelse any? close-mates
' p$ N7 M% F6 v. W1 \- B8 |, y6 G[ 6 z/ i' U" F/ \. t; v+ G3 K
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]( t0 B7 z9 A! U# _1 c! m
face closest-one/ f$ E( {* }) x5 A* S
rt 180, }, w f. E3 F. B; j
fd random-float step-size5 h3 [; o9 i3 A; p* j# t$ L
avoid-walls0 [4 m- b3 W+ q4 w/ V
set stopped? false]/ g* i G# J4 B$ q- i5 Y. U
[set stopped? true]
7 K; J+ r& {( v- b, t& B3 L] |
|