|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
( V9 n. f: f2 M1 zto go
. y( E8 S% r& v0 {3 A9 lif not any? turtles with [not stopped? ] [ stop ]
% c: E$ B- O3 x5 V8 V6 {ask turtles with [remainder who 5 = 0] [
7 t* F$ I8 K& y, ?, p8 ~# Oset close-mates (turtles with [self != myself])with[: S: k9 c+ Q! _; [
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 4 y5 o3 H/ H A8 w% z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 y) N2 i5 r$ C8 G
and remainder who 5 = 0 / S4 {; Q7 i b
] . [; h3 ]4 l' @) i. `
ifelse any? close-mates
9 }# B& J0 X# y0 w1 Y[
+ N) ^" @* m, ^ J! m2 L: A6 _set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
- ~# ~, u5 J) n9 Q Zface closest-one% A# ?( m$ Q- g6 }
rt 180! h5 j& p4 b3 j
fd random-float step-size
$ Q4 }6 o+ Q* d. I( navoid-walls
5 o5 a. @4 v0 Y2 ` p: i5 hset stopped? false]0 ]. M5 d$ U& K3 O/ ?. s
[set stopped? true] , e) j" M1 B7 G E2 G
] |
|