|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
" M# ~; \' Q* P5 {4 k/ U2 ?) K! |to go
: B _, V, Q1 U; s5 j# Zif not any? turtles with [not stopped? ] [ stop ] / T! }/ D" ]+ T; s+ P6 F5 G4 W
ask turtles with [remainder who 5 = 0] [" s/ W9 L$ \: [: Q2 u
set close-mates (turtles with [self != myself])with[
' ^* C3 {5 G+ o& l$ A(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
. y+ t' N! w5 ?7 r6 [and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 d G$ |( T: x, l1 x5 @- V Z, O
and remainder who 5 = 0 2 Z- J4 S% `" v# b( {. f H
]
3 t! |* ~5 W- \! @7 K* C g: ^ifelse any? close-mates
& V1 \1 M/ ^4 c$ ^" O- @[ ; Y5 F6 u$ ]% Z0 I
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
$ ?$ r) d/ }* [face closest-one/ X. H0 ?% M, _5 i5 v8 l ?& s; s
rt 180
5 \# d' X* I, ~) u% Q/ c: d) tfd random-float step-size
- b! L! Y9 ?1 I2 ?" ?0 [avoid-walls
1 K5 n3 `* p! r8 K; o1 l0 v r! Y# e$ Aset stopped? false]
$ [( P, M% s% P- ~3 F[set stopped? true]
. o" s9 M, q# k% ]) a2 }] |
|