|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 H5 q$ I5 ^1 c9 H+ cto go
/ D$ z+ w4 |2 W! K& d% [if not any? turtles with [not stopped? ] [ stop ]
7 f/ H4 _$ J" ^$ K( C; bask turtles with [remainder who 5 = 0] [" {8 X1 ]1 x# D8 D; ~& o
set close-mates (turtles with [self != myself])with[
# s/ d7 t4 a6 X# a1 P- j(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 7 _% S- K5 j& F- r A ^8 D% |
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) + J7 K7 e- D; T- {
and remainder who 5 = 0
0 c) Q! d5 i) [$ P6 @- v; c]
1 Z! Q. |9 l5 q6 c" O8 o: D2 |ifelse any? close-mates
8 R9 g- r+ U+ t[
; d, }5 u# x! i: S5 q" rset closest-one min-one-of (close-mates with[self != myself] )[distance myself]; L% o9 B+ D" a# b7 E
face closest-one; z5 c5 ?, K' w5 Y' p
rt 180
- l+ q0 A5 ?. zfd random-float step-size+ ~$ R% G. l. a J% [- q9 K$ [6 R
avoid-walls
" h6 @' j2 |) c; B7 s9 d; V$ Z" [# t. Wset stopped? false]
; V, u& C' x' D6 O' _[set stopped? true] 1 ^/ @6 K6 \8 \, i! O
] |
|