|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
, M7 i% R* I! Kto go3 D3 b: ^' v/ ~/ ~+ u" }& F8 X
if not any? turtles with [not stopped? ] [ stop ] % R' _/ Z0 q% z- x/ Y
ask turtles with [remainder who 5 = 0] [4 I' K" V( {9 [; u* B
set close-mates (turtles with [self != myself])with[2 n6 W# u0 E+ M$ Z
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
1 R* y3 I2 k1 q' ?+ o- G4 Yand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
6 N8 d2 f2 v- C7 {0 v# Uand remainder who 5 = 0 8 A, t1 m3 j4 Y9 }
] 8 J; {; _7 q; ^ d8 w5 M7 T
ifelse any? close-mates - M2 _ X- b- L) A
[
4 n7 z; G3 N" R" Tset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
4 V! y4 J& E( e5 _. I' H, T! V2 oface closest-one" K& T4 |& u1 [4 E) b+ E, w
rt 180
; B) a8 V3 l5 _fd random-float step-size
* e! D6 D) L$ U" I5 Yavoid-walls
/ \. ^1 u0 ?) g- R7 u+ ?set stopped? false]
: H1 U, f7 ~+ d[set stopped? true]
4 ~3 B1 z9 r- \" t] |
|