|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
8 ]8 y: N2 Q+ c/ e5 j4 T6 ^to go$ \) u: C* z; u: J7 h4 J+ P
if not any? turtles with [not stopped? ] [ stop ] # \& s: ?/ g; `9 Y
ask turtles with [remainder who 5 = 0] [
" @2 {# `; s8 V5 yset close-mates (turtles with [self != myself])with[
$ F$ r9 \ g: u( h u(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
4 }( M) I% y; k2 |- `and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
6 k* Z+ O5 B0 r0 v m3 M8 z8 l4 sand remainder who 5 = 0
2 }3 p0 F8 o. m" _1 V( C+ Y]
/ f g7 f3 B3 J W6 t& k4 Uifelse any? close-mates
/ u- I. W, P. v u+ d. r9 v[ 8 b2 P: L0 z; Z* h7 ~
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]; s8 J- s, |3 q
face closest-one* l, v# I7 W0 B& z# {
rt 180; B' z, N8 Z9 t" [7 |! S v
fd random-float step-size
8 }: Y8 N$ \- g/ E I, m; Zavoid-walls) y* ~0 H o/ F& z1 S
set stopped? false]" P: @0 v3 o7 @5 Q1 f1 C
[set stopped? true]
( \& p( H0 ?& h3 B g1 T] |
|