|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
2 a% j# p. X; J' u) T2 Bto go
$ V' u2 O3 Q8 S- qif not any? turtles with [not stopped? ] [ stop ]
. _# @, u. h! {% @9 r" T3 C7 }ask turtles with [remainder who 5 = 0] [
* }# [* V; E" U# rset close-mates (turtles with [self != myself])with[
) ~6 X! f, b+ e! O) c; F: |(abs(xcor -(xcor-of myself)) < X-Dist + Wid ) " \ Y( n8 f! F
and (abs(ycor -(ycor-of myself)) < Y-Dist + Dep )
" t8 b* L* Q4 J6 @and remainder who 5 = 0 5 H1 _) x2 u2 Y* e$ @
] 6 n% E9 Y) b! l1 [* ~0 |/ z3 L
ifelse any? close-mates
" V9 N& N2 M1 [[ % Y$ T5 x. [( Z6 k1 Q) q( ^: W
set closest-one min-one-of (close-mates with[self != myself] )[distance myself]
# E( K! x, f V0 o( y% Qface closest-one% n4 E! P, a6 T& [, d( }
rt 180; S+ o' `* H+ h
fd random-float step-size
. t% b7 r; R' m* [% Z) Qavoid-walls
0 R; H. G; {( F9 V. U" [6 Y5 kset stopped? false]( [- L" E2 a: ?$ L4 {7 g/ e5 G" x
[set stopped? true] 8 ]9 u1 o; b2 p% J! _" ]
] |
|