|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- X0 ], p" T# e+ B2 w5 A% W9 V& kto go
2 ^, |7 O$ Z" {5 `0 Q' Z( Aif not any? turtles with [not stopped? ] [ stop ] & e2 m/ w0 s, d7 Z
ask turtles with [remainder who 5 = 0] [
1 o; M! R* x( C5 Aset close-mates (turtles with [self != myself])with[: R8 k6 m9 I6 }- t
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) S0 H" S4 Q$ }8 Z: Xand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
$ {* R: W. `0 P4 E0 aand remainder who 5 = 0
0 i% _- @$ M- X6 O( y; w' F] 6 z. ]7 A( x6 `7 k$ \9 P9 q. E
ifelse any? close-mates
7 P# ^; ^, {% {" m; S% j5 N6 {[
8 m; n0 ?1 m+ ~$ v" w* V0 Mset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
% @ i5 u1 y, V5 I2 N+ Q1 w+ x2 ^face closest-one% P7 g; s% ^- Y ?7 B' H
rt 180
' a8 q- _: l* D( ^; G, q) {fd random-float step-size
" D5 S6 e7 h$ B% K: ^" g. c2 C( Havoid-walls" Q9 g; w O' L* s
set stopped? false]
& i& ^4 @' J+ I: t$ I" b7 ?[set stopped? true]
9 K+ c4 U K; e] |
|