|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
! b$ [) `; |" s, @# Hto go
( Z. t2 y( Y$ vif not any? turtles with [not stopped? ] [ stop ]
% ?! N u8 v+ m! Task turtles with [remainder who 5 = 0] [6 Q& A. L. V9 S r6 s( f4 O4 J( P+ w
set close-mates (turtles with [self != myself])with[1 |! e, h! g0 S+ @1 h
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 2 |% e/ O J4 B% S
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
! O7 W" `8 y& I- C M1 ]and remainder who 5 = 0
% x: x! T- @3 W* B/ P]
1 V, h8 X7 t: T1 [ifelse any? close-mates
" T: G6 S+ ~0 h, T2 m! `2 {( d m0 [[ ' O. j5 p" h$ P1 _, ^7 h9 L8 r* D
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
/ B' X* e0 ]5 o! v8 ]+ ]# lface closest-one
* j/ T+ ?+ @6 X# @8 D$ u trt 180
* }* D' ^; J/ o, u3 Jfd random-float step-size
, O" ?! w) J- b$ a/ F) javoid-walls" x* I5 \ O' e4 T
set stopped? false]
4 N: i; v. g* h# c$ g% C G& ][set stopped? true]
, b. ?, j. F s* y2 i] |
|