|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 `/ c. f- w2 q* C/ ?2 ?# \+ v# J
to go
3 j, G9 ?' W! bif not any? turtles with [not stopped? ] [ stop ]
1 q+ K7 I, c( h- m' X. m; k* V! |2 rask turtles with [remainder who 5 = 0] [& S' U: F) J. ?8 J
set close-mates (turtles with [self != myself])with[5 t4 z' a7 K' ?. D
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
% P% f0 Y+ ~0 t* l3 [3 k3 c# I; U5 N7 @$ ~and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 4 c) w. X7 j3 O0 ^
and remainder who 5 = 0 0 w7 O% y2 e9 @, M
]
5 d" E* e2 C4 ^- r7 hifelse any? close-mates
, K J& q6 v0 M9 Y; n[
" z8 _! x, Z M' |$ ~0 e! Xset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
, c3 O4 J' C8 }# `6 l1 y/ D- wface closest-one) _( D# U2 z" V& J
rt 180
( ]1 _2 R/ _8 k1 a1 zfd random-float step-size* i7 ?6 b* s$ P7 J3 j
avoid-walls
" F. c: y8 m" I! o' F5 `set stopped? false]
+ \' T; v7 i9 a' G[set stopped? true]
; s* @+ C- Q7 B2 v+ J] |
|