|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) W# s2 ~% |( O8 [9 |to go$ A/ C6 i4 @, G, D) b" @
if not any? turtles with [not stopped? ] [ stop ] c5 ^3 h6 N, e! ?) ?/ ~$ C* j Q
ask turtles with [remainder who 5 = 0] [
. H4 C- L# D/ C& a$ jset close-mates (turtles with [self != myself])with[! B" e* f4 l! I# e e
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ) f0 a* [, N; q5 o1 w
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . q7 m3 C& q8 b3 L# w8 a' W$ l
and remainder who 5 = 0
! _! M7 x% ~; ^3 T] ; k$ X! ~ T9 ?, G1 Q; n
ifelse any? close-mates
( Z( T- c, l! ^[ + `* c/ ]0 N' G; W
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]5 l- Q/ J d3 Y% x( P+ j
face closest-one
& W. d U7 @) I' S% [7 ^" f4 krt 180
5 V! H. z7 S# ^- f" {: t, S" s6 Wfd random-float step-size; f, _. _" z; n9 ~2 v- e% [- x- w6 q
avoid-walls2 E+ [( }% | y% Q
set stopped? false]
% y! D: E, I+ S. k& Z0 ^[set stopped? true] 5 Y/ q. C% ~# S
] |
|