|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- |5 O( x" B' o* S& eto go1 s5 [( a; ], _, q: \
if not any? turtles with [not stopped? ] [ stop ] # q+ \8 ]7 c- O k" ?5 M
ask turtles with [remainder who 5 = 0] [
) P6 X( W5 P. Y2 l3 o6 Q' T, l' Qset close-mates (turtles with [self != myself])with[
' L/ D4 {( w# g8 a1 E- w(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
. ]" x5 Y$ @/ f$ x' z# A, q% y8 [and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% q3 Z# K# R) n7 S uand remainder who 5 = 0 : f7 J* R3 X& q
]
( L8 b9 z. C& q3 j( Sifelse any? close-mates 3 N3 A; u# ^. l* d; |1 f: Y
[
: `3 s8 H" ~' _set closest-one min-one-of (close-mates with[self != myself] )[distance myself]* b$ ^8 Y9 m& A- A2 o* e4 X; ^* M
face closest-one
* B0 ]; S$ p9 y- H4 ^rt 180
* s- F: H/ q& _- _$ T5 ^! Dfd random-float step-size
" \) D0 t3 j0 F/ |7 W' [* ~avoid-walls1 |4 W, f* c0 F3 f& c+ X' m
set stopped? false]9 z( W# E" M; u: ~: S% `
[set stopped? true] $ t4 A" ~. V& U+ U( ]* W
] |
|