|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 W6 R+ o) X0 m2 ]4 Y
to go
9 _1 G5 z7 F/ H. W% P% _5 Aif not any? turtles with [not stopped? ] [ stop ] # t Y; {' E+ `& b, q7 X
ask turtles with [remainder who 5 = 0] [
/ m- X/ Y. J# n$ Q% U* Cset close-mates (turtles with [self != myself])with[
0 V1 V5 ]1 B& Z0 r9 Y1 G(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 m: x$ d: l$ O; q
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) % M: W$ P: f, ?
and remainder who 5 = 0 ( A ^# `3 [$ c& {9 h
]
% @: J1 k8 \/ q2 E' a' p! b! zifelse any? close-mates 0 t! X0 ^( x$ C9 W; m! g
[ , v* v9 P8 ]4 N. v' h& _; R, r% E6 b
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]7 @. d) L) g9 ?+ R
face closest-one: e) W' q0 q% U- [8 y
rt 180
& g5 E" f$ C Ofd random-float step-size
, R( V7 T( X* ?) Cavoid-walls4 H4 t' @( f; ^; N# h4 ?6 i
set stopped? false]
T' w" z" v2 `( y; Z! I; l[set stopped? true]
9 x k6 y0 |+ }' v$ T: n+ T] |
|