|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ W. f% F* d8 H- F' m
to go. }, X8 P" S( w: [& I$ b- R
if not any? turtles with [not stopped? ] [ stop ]
9 i$ `. N- `3 @ @ask turtles with [remainder who 5 = 0] [
2 x3 R, x2 P f" M; d4 P: E; y$ R8 i7 Gset close-mates (turtles with [self != myself])with[
& h& T% r- e+ Z(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( k' w. i4 r% d0 ` d: {! N9 wand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
7 k( ]# p6 c# b: Z: ^and remainder who 5 = 0 & Z4 \1 ?# K( s9 m
] 8 k" M8 T$ Y" B& \+ n* C6 S) [1 A
ifelse any? close-mates # |! O5 T; Z9 ^+ t g; [
[ # ?9 r. ^/ v( P2 H
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]. H# L8 X: D0 O
face closest-one
& U+ N. d2 f( ~4 S) X: Rrt 1809 N5 a& P n$ _2 n: {& H% k" ~6 o
fd random-float step-size
3 z3 M2 ? k5 m$ l: pavoid-walls/ o8 M, l W% p' L! S* c) C2 p3 p
set stopped? false]8 D3 V7 ]- E' f
[set stopped? true]
' n5 M/ b* \( A" u] |
|