|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false8 @8 ]- o; W8 c" ~2 u
to go
. h3 a1 ~- z3 Q- L# m& U& [if not any? turtles with [not stopped? ] [ stop ]
( h/ K; C9 i7 I, W( i6 M& U! d7 ^ask turtles with [remainder who 5 = 0] [
# G% r4 m' i$ K( @) bset close-mates (turtles with [self != myself])with[
' g* ]9 Z) N! T! A# R(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) . ^7 D/ j3 \) N \% C' N
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
) @9 b3 n9 @5 u# tand remainder who 5 = 0
% ?5 h; y# b/ w+ J z" |) B]
- r+ k1 ^7 v6 gifelse any? close-mates 2 S# X' u* K& z$ W8 ^' R/ z {! _
[
: y4 A9 |+ f/ ?9 D! Yset closest-one min-one-of (close-mates with[self != myself] )[distance myself]- E: ~% f! q( Z% f, y0 z
face closest-one
. X8 @5 E- U( }! w- {rt 1804 b; J) r+ J$ ]* O: N0 f! F' j
fd random-float step-size
2 C( l, V6 F" F$ M9 G4 C) B/ Aavoid-walls
5 C* \8 s) v8 W4 b+ z$ l Dset stopped? false]7 ?! D! O; n9 ]9 t# A0 I6 s
[set stopped? true] T( u \+ A* }5 N6 K- K/ I
] |
|