|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false) {7 A+ N. t: d0 e! [$ C
to go
/ s% M2 n6 b. Y mif not any? turtles with [not stopped? ] [ stop ]
2 H0 @: Y6 l5 {; u' |ask turtles with [remainder who 5 = 0] [) ^( ?+ u6 v# v3 d7 {7 g
set close-mates (turtles with [self != myself])with[$ s0 N, E9 Z- m+ S' @ \! E
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) , S9 d7 N: }% \* [% J1 a! x5 q
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
, j7 s7 h. w/ b* I5 G4 cand remainder who 5 = 0 $ o4 K5 }* i' D5 X2 {- q( F! z! O
] ) i+ L) D3 d& g0 j6 {
ifelse any? close-mates
+ ^5 H$ T H5 W( `" E) w[
' ?% E+ N( B' U( a/ }, wset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
3 Z9 G3 J" t4 l' u- g1 hface closest-one
0 E2 g! p% W: R' \0 o8 i$ Trt 180
$ [( e1 a9 ?1 ], lfd random-float step-size
' D! A- ^9 ^" n8 u4 cavoid-walls
: G% A- L4 L, _1 \4 G2 q* }* nset stopped? false]. d5 B3 W( I" a- `' P r. d
[set stopped? true]
" Y* k1 U" O. l# X F0 K] |
|