|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
6 i3 \2 D% E6 j' {- sto go
, e2 E" R7 G. qif not any? turtles with [not stopped? ] [ stop ]
8 M0 y, A- r! b& O8 d) Dask turtles with [remainder who 5 = 0] [
0 T7 k- T) \$ ~' |. Q' z% G1 O6 u/ Wset close-mates (turtles with [self != myself])with[( p& W4 U' P4 f0 z' V
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
q) ~: ~& _/ C) iand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) . n" `7 ]9 k5 k5 o* D b
and remainder who 5 = 0 5 ^. ]- N- R1 d* x1 B3 p
] * {/ l0 c" L! x6 B5 D; t, G3 e
ifelse any? close-mates 6 Z! a4 n- s" W$ B8 x4 t K
[ ) G6 a* ?) Z9 y$ I( Y ~
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' o) x; [$ @3 }; G. g& j3 Iface closest-one
2 M( S ~% q2 P" irt 180
4 s4 R* _# j% I' D( g, pfd random-float step-size5 \ v0 j1 M% R% j3 A
avoid-walls
! H" T0 K2 C" j5 mset stopped? false]* b& k0 _& t/ }! q( m
[set stopped? true]
( L6 @: ?% e; @! h" R3 \# p] |
|