|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- G- e: w7 d! b. {! S! R& kto go
, x) I1 }/ c' _( jif not any? turtles with [not stopped? ] [ stop ] # ?4 n, ?0 o! V5 l& _' m {$ u
ask turtles with [remainder who 5 = 0] [
" s. Z" k- h$ v3 zset close-mates (turtles with [self != myself])with[7 `& _% ?+ v1 J! p
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
: v$ l% Y3 r. E4 w8 v6 mand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) / d9 W4 x8 N# \
and remainder who 5 = 0 : c, [, h9 E4 h; R$ ~/ ]. h& h
]
7 F6 m! g/ R+ t- e4 `ifelse any? close-mates % j, A* R; i+ [ Q1 e( ^; I- a
[
% h$ s ^. u7 D) S" Z/ b! k4 Eset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
9 c' F( B0 @1 W$ R: i/ m$ {face closest-one
* E9 f# D: X* T/ trt 180
9 x. C9 b( p6 ufd random-float step-size; r2 i3 v5 O5 y% m9 O4 O
avoid-walls
3 \% G7 _: ^) n& ?: Mset stopped? false]
' n3 Z7 s; x3 h: H! n* R V; T[set stopped? true] ' u v# U" G* J$ X( i& h- q& j1 m+ a0 T
] |
|