|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false1 k) P6 ^/ M+ b& x; d: V4 f+ Q
to go
; W* q7 U, I9 {/ L+ U" P' S0 x. ~if not any? turtles with [not stopped? ] [ stop ]
' S( D- j1 y! S- M9 L4 G6 uask turtles with [remainder who 5 = 0] [# V3 k% Q6 r$ v5 v3 Y4 k" q! [1 G
set close-mates (turtles with [self != myself])with[; u) M5 Y& ^0 [
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
0 H' ^ e, `$ u. F) ]; e$ G+ U/ x& Zand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
2 ]; Z( H R- h% \; \6 [9 e9 jand remainder who 5 = 0 4 n2 L4 S' x" [( d
] + S* a( M- t% E1 J$ m3 N* H
ifelse any? close-mates * ]; ]" J; @- T( [2 x$ I$ B( c
[ . ^! I" A1 B1 g+ V& g7 v6 n
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# B$ ]3 e9 ~9 c* x$ lface closest-one
3 p2 F! G7 H( f$ T) Qrt 180. p6 B; b- W, A l) G2 i, L
fd random-float step-size
3 \- K9 n$ T: b# I* U4 B* D+ w7 C aavoid-walls, U. A0 {1 _( _& w* U
set stopped? false]
! J+ K9 |5 T% K( Q[set stopped? true]
/ K6 F2 l5 U! S @8 e] |
|