|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 t1 W: a/ @, _) d
to go
) B5 }7 I" Y' \+ e( Jif not any? turtles with [not stopped? ] [ stop ]
( Y5 |+ P1 \1 Y) {6 Cask turtles with [remainder who 5 = 0] [
7 I6 e4 H k% Z, X) F0 Nset close-mates (turtles with [self != myself])with[6 z, L4 j) ?& l
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
4 o, p. |/ I. pand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( N% b4 Q1 q: Xand remainder who 5 = 0
+ i+ i# K- P" m+ M]
" k, D, N# B' Z+ G# p3 d& Nifelse any? close-mates
9 u. O4 M1 {! x0 I[
7 t3 [7 `1 |( |' \5 K6 vset closest-one min-one-of (close-mates with[self != myself] )[distance myself]0 l }/ I1 f3 v% C% J6 G
face closest-one; H. G5 P5 H; n% m1 b
rt 180
3 i4 {4 l# j! e& H% |% S9 dfd random-float step-size# `8 s& I% U) ?% Z% D! M @1 k# _
avoid-walls
+ S: J( @% y8 k# Iset stopped? false]0 y. I1 X* l) T* M, r& {9 y
[set stopped? true]
$ x) ~. }( e. m8 x" o0 L] |
|