|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
; U$ A, Q( L+ j+ }to go) v; z: ?6 F0 V) l4 ]' X) [
if not any? turtles with [not stopped? ] [ stop ] : R! _: R& h3 f4 n" h9 i
ask turtles with [remainder who 5 = 0] [' S2 j2 a0 Z! x
set close-mates (turtles with [self != myself])with[
^/ o5 ?1 S+ b7 `(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# B {, C8 r/ ^and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . l. t" g" s' r9 q7 x; `
and remainder who 5 = 0 2 g" P; h; n6 A; ~
] 6 d8 q' q( h+ k8 N7 g+ l) Z
ifelse any? close-mates
% X G$ I$ O# l% s r! M w$ ?[ 8 v0 P3 I$ A% l/ _
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]% g- o& b+ `8 Z/ m0 k+ e8 d- H
face closest-one4 { b- i! X& U( C9 h/ G
rt 180
% n- m% e1 s& bfd random-float step-size, h& I! n9 c" R7 M
avoid-walls
: R" @. L: N# Kset stopped? false]
" e( P9 x' q; M/ s1 q/ ]' Y[set stopped? true]
# Q4 y/ [) w. A+ V: p] |
|