|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
1 t1 J: M/ u b8 r8 y. W1 V5 M- tto go+ b8 L. |: i9 m3 [5 D
if not any? turtles with [not stopped? ] [ stop ] " U' }* p! l8 O- Z. a
ask turtles with [remainder who 5 = 0] [
; Y I' M/ w" T5 X; O7 B6 cset close-mates (turtles with [self != myself])with[9 r1 U6 H3 `, K( D" a8 W
(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) , e# U1 O# Q# \# i. H! n |& q/ z
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
+ D! w( q7 K0 \& e3 ?+ Land remainder who 5 = 0 V$ n/ p5 w9 ~
]
% A+ p2 x" i+ d" x+ U B7 W- i7 J# Iifelse any? close-mates 3 Q, x( u# K8 l- q/ M
[ 9 w: V' b$ F3 H
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
' m* E' _2 d3 n( w9 f& ?- |! sface closest-one9 t: E' D( j: C* o+ b0 Y1 a! n
rt 180
5 x1 }( K/ i% l9 U2 R& kfd random-float step-size
6 ~# E/ B. M1 P+ e- S7 L% ?avoid-walls
) V0 ~0 W4 j4 K# b4 J2 pset stopped? false]! m y4 V, t W. F
[set stopped? true]
6 ~, N2 \3 [: q% n& r" [] |
|