|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 |" W% u- Z8 ?' ]to go {$ H" y' _9 A o) f. F8 N
if not any? turtles with [not stopped? ] [ stop ] : s$ k! a+ B4 i; z: V) w( Z( j
ask turtles with [remainder who 5 = 0] [' K) w7 L9 U" w k, F% a8 D
set close-mates (turtles with [self != myself])with[/ B: X. L( _3 a% e/ x8 F( h/ P
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
. t: M2 h" e0 Z& L W2 K) n+ tand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ; m2 A9 r2 |2 k/ W3 z& @: ^0 V4 o
and remainder who 5 = 0 . C+ _( V! x6 z, ^/ F6 o
]
9 i5 V j2 J& V, e! xifelse any? close-mates
% B# f) e$ o0 w; ]$ T+ S[ $ j. z! V( v4 J: x# G. O
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 Y: D6 o8 ^5 n8 Z6 c5 Yface closest-one
! R" y" g [( E: _! f9 f* vrt 1800 j) W, |: s/ j9 }( o
fd random-float step-size d$ L- ^5 T8 c6 z: W9 h6 x& |8 |
avoid-walls5 T: `9 U( E+ Z
set stopped? false]0 j P: U. O5 i# l* P
[set stopped? true] - R# R( }9 ]% c+ p, d1 O
] |
|