|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false+ D! N8 [( [& T$ r* h
to go
7 J8 Z# V9 `' d9 R4 d/ \if not any? turtles with [not stopped? ] [ stop ] 8 q: D2 Y' l6 X* Q* A
ask turtles with [remainder who 5 = 0] [
- r4 O, I/ J& {set close-mates (turtles with [self != myself])with[
" I7 y" ~3 _9 S(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) : h- M6 W3 i( z4 w: l+ @8 q2 ^
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
; O- c A8 ]; p5 L+ Nand remainder who 5 = 0 * b+ _ u$ r8 c( v% k1 A6 _" c
]
7 g j0 q4 Z' j8 K. kifelse any? close-mates
( G$ f/ t; g: ~) Q0 c# ?+ B[
- i$ `& j9 C1 c5 [3 B/ e% d; tset closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ N7 ]3 I6 J7 f9 z
face closest-one
, d1 @8 x' }! c5 irt 1802 R) L4 l& K$ U/ O% ~' `* N
fd random-float step-size. `7 D) q" u4 s% D8 Z+ f7 \7 o6 R
avoid-walls5 u- K- s. v6 H2 |7 q, _
set stopped? false]
5 ^& R# W/ |. N[set stopped? true]
- h4 q1 r1 x* U1 q2 C W+ W] |
|