|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
4 l1 f: M+ t4 V% E4 E1 d* U; E) |to go
" k+ U r2 D+ J# @/ Y0 }: p3 O" fif not any? turtles with [not stopped? ] [ stop ] 1 l+ L( M$ R. {! E- G* c
ask turtles with [remainder who 5 = 0] [
% a- _ ^) T7 rset close-mates (turtles with [self != myself])with[
' v; U+ Z3 M3 X$ b. g: D(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% I( F( y% |( Y Gand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) , }* f4 ] n% x! Y5 M
and remainder who 5 = 0
8 H( {7 @. b2 y/ a$ c3 y] # U* @, W S' T- U6 R- B
ifelse any? close-mates ; N. f' n# l9 ?) \. ^
[ 7 y5 P" \' {8 u; c1 B1 ~
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
, A7 {' h- |/ J- q6 q& a5 t! Nface closest-one% v0 {6 ]4 Z$ t8 {
rt 180! H4 Z) t% k2 T8 T4 `& B! i
fd random-float step-size; e* J6 l! c* z, ~$ {6 Y
avoid-walls( X5 z9 R" w/ L9 n O
set stopped? false]0 H7 M9 h, r/ p0 H
[set stopped? true] % a4 z$ l7 ~, u& {/ P3 K
] |
|