|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
4 b8 C! N h i0 Z, t$ z, b5 R p5 Jto go
, P$ B4 y1 l, a( _& Sif not any? turtles with [not stopped? ] [ stop ]
2 e3 d% G/ t4 |3 Oask turtles with [remainder who 5 = 0] [' E5 u2 N6 K6 z& [9 R5 f5 i
set close-mates (turtles with [self != myself])with[" d3 E; E! N/ ^8 F% t
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
3 ^5 [ l! l( [) f% i# K3 e- n' Jand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - I5 y# _, @7 p6 ^4 z
and remainder who 5 = 0 % `7 l4 F: {9 Z; D/ N W6 R" d/ k
]
. {! V4 T: h+ ?) [; B: f6 T Difelse any? close-mates 3 F' C" L0 M( i! \, s) ^6 L
[
! s; k. M; U$ S, [set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
) r4 t6 q' l) d2 Z3 y5 J2 Jface closest-one5 t8 J( \4 q) G% Q8 n
rt 1804 B9 J0 P' N/ ~3 K5 q
fd random-float step-size0 t2 z( R5 F, F- _0 u
avoid-walls
( h. B( L! o% }set stopped? false]5 ? N4 e/ w5 E
[set stopped? true]
4 q7 G: Z: l/ g7 P: x8 ?] |
|