|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
) I6 O% Q/ L3 Q: V2 t3 p$ t2 _' L7 bto go
0 F, K+ F8 ~- M# l" v6 m+ v' aif not any? turtles with [not stopped? ] [ stop ] 4 b: E R9 h% i" |# p3 d; ]" a
ask turtles with [remainder who 5 = 0] [% G- M/ z5 Z( G# A' r
set close-mates (turtles with [self != myself])with[6 \1 [' t0 P' M( r2 Z
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) ! g/ d6 d |- {7 |$ ^
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
7 A5 G ~/ g" o0 `" w4 i0 `and remainder who 5 = 0
! [/ `) r: b, Y( m/ Z, R] j- R0 ]) b- V1 I u9 ]
ifelse any? close-mates , m2 }- ?; ]" P" _ C
[
2 f+ \& z9 A8 i+ w& a2 l. Q% x Bset closest-one min-one-of (close-mates with[self != myself] )[distance myself]& e- X; ?2 o- z5 a( @; L$ R0 X
face closest-one
( }2 y* a6 {1 B$ g! Nrt 180
" g; v8 y1 n2 g' Z; r7 Nfd random-float step-size$ Y8 P; A7 T5 |9 E# x# C
avoid-walls
, w) s0 Y! H+ e4 ?- z# C& Mset stopped? false]
( `3 }* k1 Q0 Y' \5 u[set stopped? true]
7 q3 h5 e& D# `& J] |
|