|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false. j" \: U! E) `* \
to go4 r. E, J6 | K
if not any? turtles with [not stopped? ] [ stop ]
! a9 {4 N$ q! ^% K' X9 H3 L. ^/ |, |ask turtles with [remainder who 5 = 0] [$ _2 X) V8 C* l* D: ?8 @
set close-mates (turtles with [self != myself])with[, a1 T4 F \. L8 |) s6 X
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
& u) L; e# _5 D! e0 }: R0 qand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , B: H( N7 G7 v6 U& U! k! `0 o
and remainder who 5 = 0 / _) z$ S# C! W" f' R
]
: n# ~- \0 h7 O1 s3 hifelse any? close-mates ) x4 M0 Q# ?3 m( h* m" n
[
* N# J& i& R) ?& q+ ]# S, x7 Mset closest-one min-one-of (close-mates with[self != myself] )[distance myself]0 @3 X" \% z/ H0 v4 ~7 c$ V
face closest-one; u# ~. A9 w3 g" j
rt 1801 o9 t+ e# l6 l) ~ I
fd random-float step-size
2 p0 N5 G" W( X# Iavoid-walls
5 D" Y1 v0 ?4 ]$ ^# Kset stopped? false]4 R" H4 @1 u7 T4 u( w
[set stopped? true] # ~ |/ b: {* O) \$ Y% m5 T
] |
|