|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false! c4 o. G+ u! g, g& J
to go4 Y: I) v8 W. n1 j
if not any? turtles with [not stopped? ] [ stop ]
, |2 j3 K+ s6 }1 Y6 ~% | ^ask turtles with [remainder who 5 = 0] [3 P# A6 V; K$ L7 K9 \$ ?
set close-mates (turtles with [self != myself])with[) g* J8 l' n$ Y7 N, N! e5 h
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
|7 D& G: n7 H+ `6 mand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 r/ j9 f0 ]9 a/ J2 O$ k7 {9 H
and remainder who 5 = 0 ) G" _8 n/ F) T5 u- B( M
] ' @3 ~# H- o! D, U4 k9 @" Y b
ifelse any? close-mates ) @& O# {6 S& a6 Z, B# H" s
[ ' r$ P* d1 Y0 E5 r5 U" Y& R2 o
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
3 A& O! p( I0 g- u& M+ M1 Nface closest-one4 K b1 \$ V" A8 x6 q( {
rt 180( X9 W p- E; Y2 I
fd random-float step-size
6 w# v0 J0 D; z2 Y0 e# e, Oavoid-walls, o5 M3 |+ c& A8 R+ ^9 c
set stopped? false]7 o1 r* C+ d& v2 i U+ _5 k
[set stopped? true] ; a5 R Y9 q& Q
] |
|