|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) w3 _& h3 c# R; e' i1 Oto go7 n3 ?2 `8 I. t6 x
if not any? turtles with [not stopped? ] [ stop ]
& ]+ x, @/ \6 n, l6 [7 z0 }ask turtles with [remainder who 5 = 0] [
: i& O7 H. Y" ^2 k3 j/ W9 N$ ]set close-mates (turtles with [self != myself])with[
+ U; B7 q W, V( p+ X; K) V(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 7 T# f/ b( f) B) {3 j
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 D5 D8 X! A1 |" t
and remainder who 5 = 0
: \- o$ B5 l% B+ A8 e" E]
; |/ X1 b* ^# e& D5 Hifelse any? close-mates - c$ G/ y" W0 y5 Y5 U2 f5 L }* W% n
[ * v% h6 F0 B9 j' a' J( `
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]+ f- T' _5 W7 n) m2 _3 b8 z' o
face closest-one
9 E1 W v( g, d% b2 S6 j' `* t) n7 `rt 1805 |# {, H5 v$ V' k# j' W9 E
fd random-float step-size/ s( m8 E' d6 e
avoid-walls/ Y6 F) S9 h5 b3 A4 W# o' Z
set stopped? false]
# X/ ^1 r) K9 R5 e[set stopped? true] $ a. u: F" \: K, G1 [. V- S( \
] |
|