|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 F( S4 O r3 m. jto go
9 P, m. A: ^ z0 |4 }& `if not any? turtles with [not stopped? ] [ stop ] ; ~" \, m& A; J3 O( U4 P5 W
ask turtles with [remainder who 5 = 0] [
* H" K5 P1 j6 U$ Z9 \set close-mates (turtles with [self != myself])with[3 O/ J9 M; |# e; t. a& |; }
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- B) H9 l: I+ W/ M0 f* D* Zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
f; I7 O6 i- ]- \6 Q) rand remainder who 5 = 0 & @; o* A0 j; q3 I! X+ q
] / |0 y, P- B) g; }
ifelse any? close-mates
! F# T7 `, b' B7 f[
; `# Y# j4 j" _" A3 X& f- }set closest-one min-one-of (close-mates with[self != myself] )[distance myself]* m3 ^! u) E" z3 h4 L9 m
face closest-one) R" `- l9 [0 Q
rt 1803 e$ E6 \( O4 @1 k' J
fd random-float step-size
' _5 g, f$ R5 Y( uavoid-walls
0 z3 M9 P6 l# ~3 K g3 H z; Kset stopped? false]% H# b+ y# ]6 J# H2 \
[set stopped? true] # I, P0 A9 G( y( }, K+ `
] |
|