|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false; F3 W- U& D, t
to go& Q4 S- i' V& n
if not any? turtles with [not stopped? ] [ stop ] 9 [5 O, J* P6 u0 Y+ f( B
ask turtles with [remainder who 5 = 0] [
" ~; h. f4 _ yset close-mates (turtles with [self != myself])with[
, Y7 G" l- Q, N% P) g(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ! O: w* L- ]- F0 W9 \$ L
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) " t3 L- K5 W. D$ e/ d6 j; l
and remainder who 5 = 0
" j% K- q; |* m' k/ o# P) []
# i% F8 ]+ x. S5 w& e5 T# Difelse any? close-mates
2 |4 r& d6 [0 f" t$ V. x5 u, l$ o[
. b2 r: r% j5 y# N1 `. |4 Nset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
: _# C* e0 Z6 l6 I6 `face closest-one
. s- R' z, F7 brt 180- H9 W2 k/ _( i
fd random-float step-size0 d% i _4 }" u7 p" W" n
avoid-walls
6 C" y/ U# H% S. Wset stopped? false]
7 g) L4 i+ z# i" r7 n* r[set stopped? true]
) J. J( s4 m1 B' t] |
|