|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
0 R: U# i. ?2 ^" A. Ato go
; n8 V- N, o; R7 r T2 f1 {/ fif not any? turtles with [not stopped? ] [ stop ] 3 L% ~4 \0 g5 l6 D
ask turtles with [remainder who 5 = 0] [
. O) q% V4 `" g8 e. G7 S9 R4 Fset close-mates (turtles with [self != myself])with[* k+ K7 K% U7 G
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 5 L& `9 B, u& b9 A3 ]
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
& v% w7 G! y; Xand remainder who 5 = 0
& }5 r+ f" M( Z9 K+ B] : F' k* ~0 W, \# S
ifelse any? close-mates 0 [7 W2 q. I; b; M: e6 w
[ $ x6 S) q# E( E5 Z! E% c$ x
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) h; f# q- O! ?5 n* _. {9 ?face closest-one
2 {& j8 v# a1 K* S. l4 Drt 180
- B. p" H$ H" ? pfd random-float step-size
, `" m3 ?( p: _; L9 A' ^avoid-walls
# D% t" g7 a3 S% `' Fset stopped? false]
1 Y2 T" U7 j) Q: D% S2 q* ^2 V% p[set stopped? true] 1 C& h" K; s) }) s" O
] |
|