|
|
在这段代码中我设定了一个stopped?变量,初始状态设为false 。运行过程不能输出stopped?为true 。始终为false
- M, F H! t9 r3 @to go! V0 H& _4 ]( h; j' z
if not any? turtles with [not stopped? ] [ stop ]
" S8 R Y$ R0 f% g" E9 V3 jask turtles with [remainder who 5 = 0] [
& r5 ?( A, h6 E* y" pset close-mates (turtles with [self != myself])with[2 _* d$ G* w( ]9 }9 [5 s
(abs(xcor -(xcor-of myself)) < X-Dist + Wid )
) j* I `$ M( fand (abs(ycor -(ycor-of myself)) < Y-Dist + Dep ) 9 o; V1 B1 P/ u' i
and remainder who 5 = 0
& {1 r& Q. _6 P8 i5 c8 J] 4 }. ^# N: Z/ R3 e/ a
ifelse any? close-mates 6 r4 T% O( h$ y
[
$ ~0 Q$ e5 f: \9 Vset closest-one min-one-of (close-mates with[self != myself] )[distance myself]
0 ^! S$ R+ n# D1 P/ F2 D' n3 aface closest-one
+ Y+ U5 z! a& s1 c+ I7 Mrt 180
6 U2 c7 t) l0 k4 l5 m% @/ w. d0 lfd random-float step-size9 V! x+ E3 z& w
avoid-walls
2 J, q `; Q* i% U' [6 \set stopped? false]/ u5 f8 p# a. [; Q* N
[set stopped? true]
F4 o2 ^. ` Q+ A] |
|