|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
' y; j: h2 N) \9 y ~to go g( L6 p4 s+ X$ j6 d6 V
if not any? turtles with [not stopped? ] [ stop ]
$ e# d0 u: m: y6 {' I2 d5 t; g9 `ask turtles with [remainder who 5 = 0] [
: I/ p* Q+ X, j! n6 nset close-mates (turtles with [self != myself])with[) q' K; n, z- o2 w4 M9 S
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
7 e/ V3 f9 i1 r% b2 W0 H5 Rand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - i5 R& c$ }, ?( j1 w& ]' @/ A
and remainder who 5 = 0
3 @% a! Y& r6 L6 u f3 M] $ d; @4 Q5 l+ b e% b8 t! }# [5 z
ifelse any? close-mates
& t0 U1 m3 M) F! c h[
/ Z q- ?1 i* `6 Eset closest-one min-one-of (close-mates with[self != myself] )[distance myself]% h/ N, n M P* X) B. v3 j0 t7 \
face closest-one% q- I* w9 ^" b9 C0 _
rt 180: h1 E/ E( V" \7 h
fd random-float step-size4 O( s# X, V$ r# R! I/ p. U0 \4 ~
avoid-walls
0 f7 E* a7 k: @2 Dset stopped? false]
: A2 }" E6 M0 }! O[set stopped? true]
& t2 d3 e& H! U" R; C] |
|