|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false7 |2 Y3 f! T( G9 {+ L
to go
5 r& C" p3 ?8 _if not any? turtles with [not stopped? ] [ stop ] " ^! S# ^6 T f9 r
ask turtles with [remainder who 5 = 0] [
' X* ]( I# [0 `( fset close-mates (turtles with [self != myself])with[9 B; z9 f/ U2 ^$ U5 O
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 7 H' `$ y: S" h' D8 Z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ! v% V6 E( p/ s1 f0 }$ o
and remainder who 5 = 0 # ?. r/ P& L( p2 c6 U( ]
] O! W8 G8 Q# t" v6 a8 v
ifelse any? close-mates * c1 z0 | A3 P- a# U
[
% Y0 Y8 V S3 l$ C) r! W, ^set closest-one min-one-of (close-mates with[self != myself] )[distance myself]# C0 ]9 Z, r; G' G
face closest-one
; Y! B: V$ t; p3 O1 `4 `. H5 Jrt 1803 M3 f& ?3 m. r0 X2 w7 E9 p
fd random-float step-size' d R0 h! t; p( Q
avoid-walls
' H: V! G! }- m1 f( p' Y1 Oset stopped? false]0 {; x5 _* {: N) R6 O& b* z
[set stopped? true]
4 u# o2 a, Z8 c/ P] |
|