|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
7 Y( f! u: x- c6 v4 _to go
, I* C: [3 R1 U6 {% y2 g1 gif not any? turtles with [not stopped? ] [ stop ] # j- ]) X5 W0 c3 D6 z' Z. x3 |
ask turtles with [remainder who 5 = 0] [: d8 Y3 E9 F! y; ~
set close-mates (turtles with [self != myself])with[) Z) V) w6 ^: ^" I/ G
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 8 u+ q' ^% u- W, h) K% F
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( D$ I& }/ J# aand remainder who 5 = 0 . J: A ^: n7 V% c( ?
] 4 d2 X( J# u( k9 a, A0 r- w* N4 `
ifelse any? close-mates
e, B6 X: [! Q& K% C[ " S/ T; R7 j3 {9 c4 G
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
" W I: P* A" p) ?, \- {+ Pface closest-one
& Q b) r6 l9 i" Z4 I t' ?rt 1801 e1 j: s- Q2 t, }9 T7 T0 e' D
fd random-float step-size
$ z6 }* b4 ?- ~; \avoid-walls
3 ?" r# C. S9 y% s7 h* }0 sset stopped? false]
" @9 b; j5 {1 |5 Y4 x6 m4 J[set stopped? true]
# G2 M0 U8 G4 z; ~4 E] |
|