|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- W3 J6 o: R+ K# E8 A% G5 Z) Mto go2 ?$ B9 e2 \/ `( ^
if not any? turtles with [not stopped? ] [ stop ] - T. [+ v' j, C9 O- s
ask turtles with [remainder who 5 = 0] [+ \* ^# ]: l3 i F; _9 v; f" V
set close-mates (turtles with [self != myself])with[. H$ I# \5 A* ?
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 1 E4 T' ~! O# b- G# D! H
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
( I& X% L" L( K9 y1 xand remainder who 5 = 0 " v2 D/ e( Z. P, O
]
! d4 U: ?" D! c4 o+ Sifelse any? close-mates 2 a/ q/ f6 m- r7 A( f @
[ / I5 l7 u3 Q/ g0 q; h1 X
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]& ]4 @. t6 F9 O" q
face closest-one
. L0 v9 m' N! j+ Yrt 180
( c( r2 y0 b- Sfd random-float step-size
' e/ e5 o( K/ x4 h. wavoid-walls
7 M$ M+ M! D0 c# W9 Pset stopped? false]
9 ]2 ^7 R( t( r, k, H3 c[set stopped? true]
$ V) `+ G' ^, k) ^, f& `& W V] |
|