|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false6 ^- E6 J, Y1 o8 o' B7 I
to go
" R4 f' ?) w4 z* ?* Dif not any? turtles with [not stopped? ] [ stop ] * I6 }5 i% M- I0 l! B
ask turtles with [remainder who 5 = 0] [
+ [! p J4 b, P, rset close-mates (turtles with [self != myself])with[' i$ j, N5 u# P7 M% E3 D( `9 g
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 V: x) t+ [% T' T7 H! }% Y6 Fand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
3 [! V# Q' Q1 W! Uand remainder who 5 = 0
! H0 N: m; `2 @$ x n] $ y& a# U# ?& x' d; x- _
ifelse any? close-mates
8 x6 S; F- b/ L6 w[
4 B# j( Q0 v a$ }# Fset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
& y: E9 f0 Q/ Q/ T6 ^$ lface closest-one
e9 c! d) L' T/ v5 E5 ert 180
; K3 S- v0 t: X$ O: C! Yfd random-float step-size
( V' g ~+ [" Javoid-walls
5 S# \! Y( n4 hset stopped? false]
' e7 A, P4 l, w0 }[set stopped? true]
* H7 j- [! j5 u) @] |
|