|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
# S+ U) X3 w: h8 n) V0 Q- h Eto go& B6 i+ T& p+ B' \3 T# j/ B
if not any? turtles with [not stopped? ] [ stop ] , `% r( K. ?1 N5 `
ask turtles with [remainder who 5 = 0] [. e4 h- b/ ? r- v1 z7 B8 ~
set close-mates (turtles with [self != myself])with[2 @+ r: g7 z! v3 @& f
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
( E0 }1 h+ {4 M8 Kand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) - p! s: N9 P' S: k+ X0 Z2 |' e1 B
and remainder who 5 = 0 $ g- L- l, O1 V1 F+ g, M* n
] 6 K* @% R% E- y2 u1 q
ifelse any? close-mates ! s9 H/ p* I+ r @# `) W4 {
[
% ]/ E8 i( k! ^3 q! B7 qset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# b$ ~) m9 b3 C/ Tface closest-one3 ~* f; ~6 E8 z7 z( h b3 }- B
rt 180
3 c" y' V) }; _, J4 }' J- |fd random-float step-size8 E; z, Y0 n- V5 `; H
avoid-walls+ H* B: p) a" Y4 K
set stopped? false]
4 h/ d2 P! n3 O. P. {2 Q& S( }[set stopped? true]
, t, v/ t" U$ o* V! q7 J] |
|