|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
8 b! A" C" e6 r' D5 Y! D9 hto go; y! M% Z0 i5 F: V2 p9 d
if not any? turtles with [not stopped? ] [ stop ]
% A( `# k: \1 {- k; i% Z6 v' yask turtles with [remainder who 5 = 0] [
. f% M# g( z4 X* ]. z( [set close-mates (turtles with [self != myself])with[3 a/ N1 W4 n" P1 l. S0 q% r
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
, X! M1 }) Y' ~% M* p* b8 n" ]% J7 aand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
9 i. T. V3 ^. [( s. S1 n2 ^2 Tand remainder who 5 = 0
% _. ?2 V& u$ p5 f] / m- Z' o5 H' F" p
ifelse any? close-mates
* v6 J7 z* a9 G, b5 Y[
/ \1 c6 M2 J. u: E9 Zset closest-one min-one-of (close-mates with[self != myself] )[distance myself]/ ^9 F/ m4 r$ B' `
face closest-one& m7 G' M3 k$ l. }) e
rt 180
" V4 K- @6 b0 `fd random-float step-size. W" F5 r+ g+ P/ H/ w+ g/ b8 I
avoid-walls# y. s* X; E) Q0 F; b4 L
set stopped? false]
, b' i: G. g# u! q4 h9 H[set stopped? true] 2 d/ y5 {1 A# y
] |
|