|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) Z4 M( H4 V. y, ?: vto go( w% N3 G9 ^4 Z* Z6 _+ J
if not any? turtles with [not stopped? ] [ stop ] 0 I$ V0 z" i% ~* F- P/ d7 @
ask turtles with [remainder who 5 = 0] [
( `& t0 m6 l- A1 q2 D' Y# oset close-mates (turtles with [self != myself])with[
0 `- | v6 A ?2 B(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
- O, ~; t$ \( K5 [ iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
" v9 T' f( n3 g' t( I" i$ J# gand remainder who 5 = 0 " o3 a1 W9 A9 `+ P! \
]
3 r3 d4 L( D. }ifelse any? close-mates & z7 K6 q- }8 M* S1 ?5 s
[ ( c! j& q6 D+ X% r3 b
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# D! B& i) ]! E5 h( p: |" `face closest-one7 R |& N& V& Z' k
rt 180% L- p) J) S; L) ]' `
fd random-float step-size4 R, ]$ M% T% X& k. y4 e* g
avoid-walls/ b. c9 |- a2 H$ \5 \6 G7 t
set stopped? false]
* b1 q: z7 `; ~! d7 c9 y[set stopped? true]
( K: z' h5 G$ {4 W# h% Z9 j] |
|