|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
4 R. [% Y" \6 L; Fto go/ g6 Y5 e) R. Y F
if not any? turtles with [not stopped? ] [ stop ] 0 R. w% u8 T& ]8 ]- j
ask turtles with [remainder who 5 = 0] [
, T: j+ H. X; @2 H6 G8 D) hset close-mates (turtles with [self != myself])with[) P3 N ?/ U6 w3 z0 w
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 |: I% ]) a; C: C9 M% H. wand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 2 S' s2 f3 a# L( q* }0 @: S) v
and remainder who 5 = 0
- a K$ j+ o2 F$ p] / j: b7 |# f x4 |
ifelse any? close-mates
: D: t4 q4 X4 b4 H- J[
+ l. ?7 X6 J' Vset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
$ z, T) i X g5 Nface closest-one
; F; r( w; j& r, Q4 _* i5 |; ert 1805 ?; Z. [4 |! w" z" {# W
fd random-float step-size
( n+ @0 L* ]3 Zavoid-walls
' c+ { K0 C' hset stopped? false]
+ k2 G, v# h- q$ O' d: G; j; }! `0 G[set stopped? true]
# V: [' t+ S5 y, E8 o] |
|