|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- o( {3 _) g6 L# i0 zto go
7 i! \) l1 i9 C7 _/ \if not any? turtles with [not stopped? ] [ stop ]
: m1 l/ @$ Z9 M' b( cask turtles with [remainder who 5 = 0] [2 J4 @, X) _7 H$ U5 D# k( L4 Z( I
set close-mates (turtles with [self != myself])with[, R$ T, L8 {- F! X; r' O0 V
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ' R! O' L3 }% P( @
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
3 c, L; b3 @% P' O- Qand remainder who 5 = 0
% D3 D. @' |! |) o. t]
( a$ A3 o2 q# G( bifelse any? close-mates , u9 f" T& O+ g% {$ Y
[ 0 f0 |; ~) U9 X% N! H" W( h2 X
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. _7 u- y7 Q. o; e& p+ [2 {face closest-one
% B3 g- u# {( Q, Yrt 1808 j6 a; L% ^+ f$ z! N
fd random-float step-size+ d) l; l9 `9 n/ Y0 p
avoid-walls4 ~* j% F, q- K* m! l
set stopped? false]
, P; S5 N. a5 r9 `! J& x9 X[set stopped? true]
$ ?& D! b0 x( o+ Z] |
|