|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false$ L3 H0 Y- s& }8 |8 R
to go
4 I* e' p6 R1 Z! N' y7 z8 H1 iif not any? turtles with [not stopped? ] [ stop ]
' t4 F% M5 ^9 m9 T3 Aask turtles with [remainder who 5 = 0] [' u+ U$ [* Q+ M! I5 c
set close-mates (turtles with [self != myself])with[, j: e" z& ~# }. M1 B" G
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
; s) `# ?& I/ n- Iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) # z$ a6 T( v' P' n$ L7 d5 |
and remainder who 5 = 0 ( z8 {/ \) A( L. S" L& w/ X1 C' D
] $ b, f' t5 P! X) p
ifelse any? close-mates
" X& ^* s* b. K4 R8 S1 h a+ U[
$ B1 P; x* T$ W$ q0 ~' @set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
. @- C! q8 l5 wface closest-one7 [; a$ s( n2 e5 S7 b' e: O
rt 180
% A; w/ E% u. H$ U; Ifd random-float step-size% B# d' ^ n/ F( w2 \
avoid-walls% x1 z/ J# h& u$ G$ C/ J% K0 e4 |
set stopped? false]7 S1 \ ^ I, _, c1 R* o) D/ J
[set stopped? true]
+ K. b7 U$ `; [] |
|