|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
3 v$ H0 [" s$ ?; @" Pto go- U N* J3 E7 M1 `
if not any? turtles with [not stopped? ] [ stop ]
. G' `* |9 O1 E2 u/ g1 ^2 I+ pask turtles with [remainder who 5 = 0] [: d% k# H# D2 I) J1 p9 E
set close-mates (turtles with [self != myself])with[
7 b, Z, V6 i# B& ~(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
" L: F% n. G4 @ Yand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) z3 a ]0 w: B. @9 e$ ^
and remainder who 5 = 0 4 Z6 |- X) n, _, S8 L3 P5 n' h
]
8 @6 l; u0 o+ E& n2 f+ y5 x/ ]ifelse any? close-mates
& D% W- N* w6 ~9 @* ^[ " J7 i! z; ^. y2 C0 W5 {
set closest-one min-one-of (close-mates with[self != myself] )[distance myself] n6 y$ U6 q& E8 Y
face closest-one
% ^3 m' W s$ w# xrt 180
' D- v( {8 ?0 Y/ X W. I, f+ _fd random-float step-size
f# `+ L. s/ c" o* y/ lavoid-walls
" U4 U/ C3 L9 y! |% K* dset stopped? false]
8 p* {" l* W, u5 J8 |4 m, B2 v( m! H[set stopped? true]
4 e: m: }9 _1 G- g) i; O! n] |
|