|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false" j7 S7 P' `! @; U
to go
1 O3 j% D7 m; zif not any? turtles with [not stopped? ] [ stop ]
x0 g* Y; {3 y' Fask turtles with [remainder who 5 = 0] [
5 m5 {- w% t' x- g2 g+ z3 wset close-mates (turtles with [self != myself])with[! K- [4 w8 v- T8 e5 R
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
/ F8 ^& b D8 [3 n* K6 nand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
5 I8 r) ?9 O# s1 b, Zand remainder who 5 = 0 7 k5 f+ V% K, P$ b
]
! D8 W1 G5 {0 Q* u1 t( Gifelse any? close-mates
" q4 S2 }+ u5 w u) z! V5 Y[ # M0 u3 q% M& A! _2 P7 \) G
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 i' z. o9 p+ S% v; L3 [5 Q2 |/ oface closest-one- X8 k4 r+ @0 u, `, V
rt 180
4 d, ]' R+ y8 Hfd random-float step-size9 V/ g \6 c2 A
avoid-walls( }- O0 u1 P" G* L: v1 A7 j1 n
set stopped? false]. g& u; s7 v7 h( e
[set stopped? true]
% p/ b! V" N! e& _7 ^] |
|