|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false* S3 d v4 T7 K5 ^$ i3 L$ y
to go
+ v$ Y- i' q/ N0 ?3 h* T0 lif not any? turtles with [not stopped? ] [ stop ] 8 ?/ a3 w2 d- e$ Y6 H
ask turtles with [remainder who 5 = 0] [
/ q( \4 ]0 U+ p5 u. lset close-mates (turtles with [self != myself])with[) o- r& [2 [/ \# T
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
5 V, T7 q% L3 T) ~! Oand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
1 W8 e) s# c" v& ~% t0 N3 ]' wand remainder who 5 = 0
0 L5 b) Y o# y4 k: d]
# G6 t% _0 {" Q, f* Sifelse any? close-mates
+ E( `3 g, i- J& F( v: V[ * z) ^$ t E+ g8 D2 N) h3 U' h5 s
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 r7 U! ^+ K2 a. {# cface closest-one
5 s$ G8 `9 }) [# {. D: W% Grt 180
( D" e0 D6 {$ w1 l/ S- G% n/ ~fd random-float step-size6 J7 c2 G+ P' C" E% Y( ~+ b
avoid-walls
/ F1 M7 U0 m* {* Z' pset stopped? false]
& U$ r1 G! L8 w[set stopped? true]
; F6 B9 I" S' z5 Q] |
|