|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
& o( S5 u3 Z* m1 D* o) t" qto go0 H5 M1 @2 R4 }% C8 S; L3 A5 D7 r
if not any? turtles with [not stopped? ] [ stop ]
# O$ |/ T( d& w* r$ Fask turtles with [remainder who 5 = 0] [
: r+ ~( M7 n' p" i5 p+ j/ W0 h) R/ Iset close-mates (turtles with [self != myself])with[
) A7 F- w# n, u. i5 I: x(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 5 `" ^0 J# `, }6 d7 f, [/ S- V
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) : N! Y. D9 ^, f1 L
and remainder who 5 = 0
6 D' N9 I8 ?9 a$ O% J]
/ V3 B- g& o4 z0 ?* \ifelse any? close-mates 0 l7 l% y' X' b$ u' I) k4 M6 ]
[
% f/ w6 z+ ?9 A p2 }0 ~set closest-one min-one-of (close-mates with[self != myself] )[distance myself]" x& H* T* [" \3 G+ c; O: c
face closest-one
) [" l; T; T! |/ p3 S# y% T8 c# q$ Art 180
0 E. g* V& W+ k# S: p/ ]fd random-float step-size
$ O" l# b- _1 @; S- Eavoid-walls
1 h' n5 I$ _* jset stopped? false]
2 o* Z, Q+ W/ S# P$ L[set stopped? true] . y+ w6 e1 T; n# _
] |
|