|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, f& Q2 r' Z1 ]9 a% ^to go- Y9 U0 F! g, A$ G2 J. w
if not any? turtles with [not stopped? ] [ stop ] + M! P) X$ g& T: k( r
ask turtles with [remainder who 5 = 0] [
; B1 o* E. R, l& g% _5 D% xset close-mates (turtles with [self != myself])with[" Z* X, V2 [% L7 \" Z* ~
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 [3 P, K+ l1 R! h, [
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 6 [% }0 C: D2 h% h5 I6 p
and remainder who 5 = 0
+ Z9 G$ E; y& }/ u7 P, l, \$ E* e] . G1 R T% L: ?: g- H
ifelse any? close-mates 1 A1 e( E, c; t1 K- |" B% j
[ + k6 C2 \* l6 h j
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]: m& ?5 Z% B& o4 {" O# C4 L
face closest-one2 X/ \2 {3 l9 P$ z
rt 180
; }/ O2 j" q6 R4 k9 |. Cfd random-float step-size
2 ]2 M. M4 r, @$ F! T6 aavoid-walls h* b& C0 f8 e' j4 _; f
set stopped? false], B2 b) L* a9 J
[set stopped? true]
7 L8 o! S1 s8 [9 H$ @* Y] |
|