|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false3 W' C* S. M! N3 Q
to go& V, }# B3 ~/ J- s, i' N
if not any? turtles with [not stopped? ] [ stop ] ' k/ W+ b _5 |2 t
ask turtles with [remainder who 5 = 0] [, \$ |3 k/ @1 v, m' z0 e3 i& ?# [
set close-mates (turtles with [self != myself])with[
1 O V5 h$ \' Z* y6 N(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) 0 p$ w" `) _, h$ s1 O
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 0 q6 D) X# T% n* y
and remainder who 5 = 0 - R4 T% U& p8 v7 ~% D
]
1 T1 F. ~$ I8 D# \3 X* fifelse any? close-mates ' U6 n3 n! q; V1 k
[
. q: y& R& ~, o* S/ kset closest-one min-one-of (close-mates with[self != myself] )[distance myself]/ ~, E/ K9 F+ a) C# n' T z) U
face closest-one6 `3 R& T) C; C8 }( l
rt 180% s( l, H" u) @* l! a/ ]2 ]
fd random-float step-size4 t$ h* W; t. O8 x1 v* H. F3 Z
avoid-walls/ ]0 u. L& @3 Z- m, f6 n: @
set stopped? false]
8 x; |. f. h4 t; ~' j# b4 O[set stopped? true]
% E9 Z+ q% F7 P& G; T] |
|