|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
+ j" B* s- Y9 b7 `& f: ^1 nto go
5 M" R& o3 r" q6 uif not any? turtles with [not stopped? ] [ stop ] & U4 z) E! h/ s. a; U
ask turtles with [remainder who 5 = 0] [0 m( Q. F: G7 p
set close-mates (turtles with [self != myself])with[+ L2 U: h+ N3 o
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# G( A; C# h* |" q8 e' T( tand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
0 X, a! g+ K; N( Xand remainder who 5 = 0
' t$ b1 B& \2 I+ i0 M. h] ( [: M! ?5 ]+ V4 p
ifelse any? close-mates ! h' b& Z; O, H* k; Q: C
[
% q y+ h+ O$ i4 }8 Q7 Tset closest-one min-one-of (close-mates with[self != myself] )[distance myself]) [7 g- l" [ A$ c
face closest-one
- w1 f% h1 s8 W) S* Srt 180. Y0 d' @- n7 n H6 d% D
fd random-float step-size* ?4 W3 r2 Y: E, U6 P* P7 E
avoid-walls) Z5 v) N5 z7 T3 v/ z' s! t
set stopped? false]
! c/ W( x( m9 n' G F1 j* L[set stopped? true]
8 p" S" e3 @9 ?' k+ ~6 A; p) M& p] |
|