|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 y# t# T. b5 I ^% f8 ? p1 Wto go$ F4 A4 A& G9 v9 b
if not any? turtles with [not stopped? ] [ stop ] 9 h. y% N s# r. K9 g4 `7 G
ask turtles with [remainder who 5 = 0] [
7 x0 q, q3 e9 J; V m) [2 Wset close-mates (turtles with [self != myself])with[" j H; f- F6 |) Y6 J/ F# |1 w
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 3 D# `& M7 s& `* f- M
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) w! w+ V8 ]% g2 U3 r3 X: a) S* C/ Y
and remainder who 5 = 0 . m2 i9 ?# B4 e6 i6 `( M8 C
] " s' ~0 k# o, q+ B) U$ z2 N/ h
ifelse any? close-mates
) {3 ~ t8 s. T4 o& V u[
8 c4 Y9 P/ A9 H0 wset closest-one min-one-of (close-mates with[self != myself] )[distance myself]. D* `" J7 O5 o$ I% d* u( l$ e
face closest-one4 G& Z( b, S: [, ]5 N+ a7 s; t& x
rt 1805 \% N8 r8 v/ T6 }* w
fd random-float step-size
, Y' [6 s) O1 @: }avoid-walls# G0 G3 m7 Z0 l+ @' d7 J
set stopped? false]
6 q, Z4 Q) Z1 `# Z+ N2 [0 Q, D8 F$ J[set stopped? true]
7 t+ W# Z, M+ i+ z% r, f+ q] |
|