x:=0;
for j:=0 to 10 do x:=x+step_distri[s].manual[j];
for j:=0 to 10 do
begin
step_distri[s].cent[j]:=round(100*step_distri[s].manual[j]/x);
end;
step_distri[s].cummulate[0]:=step_distri[s].cent[0];
for j:=1 to 10 do
begin step_distri[s].cummulate[j]:=
step_distri[s].cummulate[j-1]+
step_distri[s].cent[j];
end;
end;
end;
procedure make_population;
var
i, j, x : word;
begin
clrscr;
for i:=1 to 30 do
begin
x:=random(100);
j:=0;
while x>step_distri[g_shift].cummulate[j] do j:=j+1;
step_len:=step_distri[g_shift].step[j];
max_shift[i]:=step_len;
cell[i].x[1]:=500+random(1000);
cell[i].y[1]:=500+random(1000);
cell[i].angle[1]:=random(180);
if random(100)<50 then cell[i].angle[1]:=-cell[i].angle[1];
if max_shift[i]>=15 then cell[i].speed:=fast;
if (max_shift[i]>=7) and (max_shift[i]<15) then cell[i].speed:=mean;
if max_shift[i]<=7 then cell[i].speed:=slow;
end;
end;
procedure init;
var
j : word;
s : par_typ;
x : real;
c : cell_typ;
begin
step_distri[g_shift].max_step:=30;
step_distri[g_shift].cell_name:='Глобальный';
step_distri[l_shift].max_step:=30;
step_distri[l_shift].cell_name:='Локальный';
step_distri[angle].max_step:=180;
step_distri[angle].cell_name:='Углы';
s:=g_shift;
for j:=0 to 10 do step_distri[s].manual[j]:=100*sin(pi*j/10)*sin(pi*j/10);
s:=l_shift;
for j:=0 to 10 do step_distri[s].manual[j]:=100*sin(pi*j/10)*sin(pi*j/10);
s:=angle;
for j:=0 to 10 do step_distri[s].manual[j]:=100*exp(-j/2);
edit_prob(g_shift);
edit_prob(l_shift);
edit_prob(angle);
clrscr;
normalize;
make_population;
end;
procedure calc_step(i : word);
var
x, j : word;
begin
x:=random(100);
j:=0;
while x>step_distri[l_shift].cummulate[j] do j:=j+1;
step_len:=step_distri[l_shift].step[j]*max_shift[i]/30;
x:=random(100);
j:=0;
while x>step_distri[angle].cummulate[j] do j:=j+1;
step_ang:=step_distri[angle].step[j];
x:=random(100);
if x>50 then sign:=-1 else sign:=1;
end;
procedure make_all_steps;
var i, j : word;
begin
for i:=1 to 30 do
with cell[i] do
for j:=2 to 100 do
begin
calc_step(i);
angle[j]:=angle[j-1]+step_ang*sign;
x[j]:=x[j-1]+step_len*cos(angle[j]*pi/180);
y[j]:=y[j-1]+step_len*sin(angle[j]*pi/180);
end;
end;
procedure print_coord;
var i, j, k : word;
f : text;
begin
for i:=1 to 30 do
with cell[i] do
for j:=1 to 100 do
begin
writeln(i:5,x[j]:9:2,y[j]:9:2);
if j mod 20 = 0 then readln(k);
end;
end;
procedure speed_meas;
var
i,j : word;
z : real;
shift : array[1 30] of real;
begin
clrscr;
for i:=1 to 30 do shift[i]:=0;
for i:=1 to 30 do
with cell[i] do
for j:=2 to 100 do
begin
z:=sqrt((x[j]-x[j-1])*(x[j]-x[j-1])+(y[j]-y[j-1])*(y[j]-y[j-1]));