|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
1 ?5 j- b# J- X" a) w/ Qto go
" r# V9 i2 k/ {# j4 F3 [& w) ~if not any? turtles with [not stopped? ] [ stop ]
/ j4 o% G3 A2 zask turtles with [remainder who 5 = 0] [! Q- `5 l2 t% _' a9 n! [7 D
set close-mates (turtles with [self != myself])with[+ [. ~2 k; b" J! o+ v
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
5 h# s9 z {# o7 a9 I) Z$ s( wand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , }0 H1 D" `( e2 ]5 q w
and remainder who 5 = 0
" z4 m# l) s8 X] ; E) O& o; H" P* @2 B) r; I1 A
ifelse any? close-mates ' T6 u/ ]# t) f; i( X5 {
[ ) c/ `. g% Y' P( S
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]% H, J t, T8 a* P0 n4 ]
face closest-one8 b- Z( e4 X- A$ @
rt 180
# S0 z: w2 u! D9 m* U- N3 efd random-float step-size& N$ O O9 p4 d) w& h5 w2 x! m8 _
avoid-walls8 r8 R" H, S9 z& O" f" x2 R9 a9 o
set stopped? false]5 j; a3 C. \4 a. v
[set stopped? true]
4 p. Z3 ^0 I- U5 @2 y: `6 o7 |] |
|