|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
7 B( n7 b0 c! N3 s8 W' {: @$ Bto go$ X9 |. J+ X% c8 s3 [- J3 \/ {& {
if not any? turtles with [not stopped? ] [ stop ]
: k. m. a( [& E8 Oask turtles with [remainder who 5 = 0] [7 ]. J, v& G G
set close-mates (turtles with [self != myself])with[3 k% R( x) ?4 f/ a, K8 r
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 9 u* p/ O. r9 ?! i- n- r1 {0 a; R+ U
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
% F. A& \; a/ j3 Q: |8 Rand remainder who 5 = 0 * ~' @: t9 m E: @0 k* F
]
& L- y6 I. A. j9 r) ^ i p5 yifelse any? close-mates + X5 m& P$ y5 K
[
2 [) ^6 I# d% ?* `) ~+ [set closest-one min-one-of (close-mates with[self != myself] )[distance myself]! {5 R" O1 A. u: Q& M3 T; c
face closest-one$ i, P4 ^+ \3 e( g: Y$ s; A
rt 180! I2 D+ w% ^. I% Q4 r& E
fd random-float step-size
3 a! P" Q; c# M2 G9 eavoid-walls4 O9 F% a, u- ^7 w' s
set stopped? false]0 d) @9 P8 `: z" ^
[set stopped? true]
! b' A0 l. a9 B" V] |
|