|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false. R+ \8 Z8 d9 s8 \
to go
# X# F/ x5 r5 |/ e& @if not any? turtles with [not stopped? ] [ stop ] 3 M) _$ H; H+ i9 x3 N
ask turtles with [remainder who 5 = 0] [5 D: a' }$ v4 x+ r: v1 M' M7 {6 ^6 Y
set close-mates (turtles with [self != myself])with[
( R6 p# I8 m/ j+ S; |6 |6 |(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
2 w; N( m: R9 z! eand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) ! ?1 Z/ ]# K U% J
and remainder who 5 = 0 7 O/ j* A% ~! l' W, c: R" w2 f
] ( J+ k! V- v" D( r% ~* P
ifelse any? close-mates % S. H3 }/ \4 _ S8 T3 y) C. Z
[
0 v% h- A' }. i9 h+ G+ M2 L) v! |set closest-one min-one-of (close-mates with[self != myself] )[distance myself], K5 }1 D0 _& K: @6 j+ X# c/ N
face closest-one; l: f8 h8 l: x" g. `
rt 180
& o8 y' c2 [5 H8 q @, ffd random-float step-size
" O4 w. p* z I5 pavoid-walls v2 z- O* `: R8 ?1 s3 @
set stopped? false]& `/ g5 c- M# y1 p" c
[set stopped? true]
3 p2 _+ p B& C* [] |
|