|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false. `: O9 H# O, G7 B
to go
( q" L7 _" u, @. h$ a& {2 a2 Dif not any? turtles with [not stopped? ] [ stop ] " i) i; M* c" a0 I
ask turtles with [remainder who 5 = 0] [
6 E7 a5 Q4 d% B/ Xset close-mates (turtles with [self != myself])with[: u' I3 A" T8 r; W: w$ [3 ]8 h9 @
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- E. ^, b/ v F0 U/ Y# p' @& Z* S& ?# Aand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - y9 L- W" F; q/ b' J: J
and remainder who 5 = 0 , T# R r5 E2 E' n' O9 v* Q
] " j/ ^5 _# F3 M5 K
ifelse any? close-mates
/ w0 z6 m5 A( Y, D[ ' \0 d2 K9 c, u2 S6 J0 v
set closest-one min-one-of (close-mates with[self != myself] )[distance myself] C+ h, q$ j( L( i( T
face closest-one
4 B- u: N& F* Z( q* q( Xrt 1806 `0 a! Y) F' J; n: d% |1 c- k
fd random-float step-size
1 N, G0 `* ?5 b2 S8 Savoid-walls6 }: v7 F* c2 s
set stopped? false]
6 \1 P# E4 X8 T, g4 e$ I' R[set stopped? true]
- G. G/ y6 M' g; Y8 s] |
|