|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 ~! p ?8 Q& D' Y
to go- R* X; X; r4 _9 ?# n) M
if not any? turtles with [not stopped? ] [ stop ]
: v3 G* p1 p t' T8 U9 c j3 Oask turtles with [remainder who 5 = 0] [' E, k: u* C4 @* Y
set close-mates (turtles with [self != myself])with[: {1 k$ N7 @4 ? @3 `. S# Z6 K
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
. U6 B7 l6 B: ^0 H4 vand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 7 C# [; L, N; d& r) G7 a
and remainder who 5 = 0
9 E6 P( b5 ]6 N) P8 I]
9 G8 W8 j; p! J; U" P% S! ]$ `ifelse any? close-mates 7 K* @# w7 K$ P+ b, _- X1 h
[
# F3 A8 ^8 u9 {set closest-one min-one-of (close-mates with[self != myself] )[distance myself]$ t/ n7 l0 p2 [; i# b
face closest-one' Y0 u+ _3 E1 H
rt 1807 `1 T# N$ ^; B; ]) i* l* `
fd random-float step-size
0 f5 m5 X+ S2 x& b3 qavoid-walls
) R- c, y, ]3 T% yset stopped? false]
. b" N; m2 S; ` b[set stopped? true]
4 z. ^, T# t8 |6 `* H5 t" _2 ]8 q] |
|