|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false1 X, ]+ W1 f! J$ s4 k$ ?
to go
7 p0 t* f9 T7 a' [7 k: d$ L0 T8 Fif not any? turtles with [not stopped? ] [ stop ] ' } g. R* E) H1 @
ask turtles with [remainder who 5 = 0] [
1 M! ~( _" N1 s5 [% }5 A7 O0 pset close-mates (turtles with [self != myself])with[% z! ?# I/ S. P; U
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# a4 g) @- f9 aand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 1 `. j; M$ u, q! T) l2 {2 o( V" {1 d' T
and remainder who 5 = 0
2 s# j4 S8 p3 O( x3 M( C] . N1 a8 i% Y3 s# Y
ifelse any? close-mates
$ L9 y) P( x0 X- v4 b! R[ 4 l! B4 z* |( S
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]6 I- ?; Y2 m. o: z0 i
face closest-one+ X7 V8 ~& h% ~9 g' g7 V% p, N q
rt 1808 t1 d3 Y3 C/ _1 j' |3 g
fd random-float step-size
4 ^8 u" }1 f5 s* V$ c/ S4 i' yavoid-walls
; B! A3 Y0 Y+ _; lset stopped? false]+ h8 E8 U, S3 T; S! y
[set stopped? true] % S) |9 L3 Y/ M
] |
|