|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false: x- |. O% a C- o
to go
3 ]* b1 V) T' f0 P: L. Lif not any? turtles with [not stopped? ] [ stop ] ) l G. k1 M2 C. M( v! w$ Q
ask turtles with [remainder who 5 = 0] [3 E2 o$ e- A" d3 [! b
set close-mates (turtles with [self != myself])with[7 H3 c1 o) v* D! b4 B$ O+ ?, U
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
* t: c7 ]0 J, |! ^$ W& _and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 b- d7 L' E6 d+ [and remainder who 5 = 0
4 Q2 Y3 X, X. W# l1 L; }( ^# `+ t" |]
2 C' v, e4 g. Y3 ?: W' g+ f4 lifelse any? close-mates
3 o8 x; c$ B* m6 H[
' z7 w- K! f: T4 ]% Y8 z9 cset closest-one min-one-of (close-mates with[self != myself] )[distance myself] W" L+ P. S5 |9 U% S# P
face closest-one
( P% S, T9 k& Hrt 180
; ~) i% Y3 i/ afd random-float step-size2 X5 p! C: R0 `+ z# N! u# e5 p
avoid-walls! W' f/ P) H) N7 C
set stopped? false]' Y) t; @( G. l+ Y5 j7 r0 |& s
[set stopped? true] 6 I" P# J0 f9 P/ D5 Z
] |
|