|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false5 }4 |3 a7 a3 `' W' B
to go, M* [0 l# T. F2 L: Z
if not any? turtles with [not stopped? ] [ stop ]
! j. h+ m6 S% Z9 Y. t+ rask turtles with [remainder who 5 = 0] [
" r. U) q3 z& {4 D+ Y9 \set close-mates (turtles with [self != myself])with[6 h+ S9 N7 h U. [; e& M9 h
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
# _ y) A, P5 s8 x% ?and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
. V3 C7 C+ o( Oand remainder who 5 = 0 8 y8 R/ Y) ~4 O. [
] # g5 E; h5 _9 j# q- W7 V
ifelse any? close-mates * l! k& C+ y; t' a7 R
[ 3 U& I1 @' U) m5 q; o
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
( ?% {: ]) k. b; N9 L' U/ Dface closest-one, k C r) m; E Z. U. X# M
rt 180
+ i: Q, |4 M. r& L) G% j6 xfd random-float step-size, v9 P) p( ]0 J& X( V& Y- i% _- W
avoid-walls9 A9 G" h. Z( t# G
set stopped? false]
4 ~& c% t4 B" p, B[set stopped? true]
' p% b& @ v2 q0 x6 i' k0 {] |
|