downarrow = #80;
type
gr_descriptor = record
x_0,y_0 : word;
X_len,y_len : word;
X_scale, Y_scale : real;
end;
prob_mov = record
max_step : real;
cell_name : string;
step, manual : array[0..10] of real;
cent, cummulate : array[0..10] of word;
scr_mod = (name_edit, arg_edit, fun_edit, diag_edit);
cell_typ = (slow, mean, fast);
par_typ = (g_shift, l_shift, angle);
scr_adr=record
x : integer;
y : integer;
cell_descriptor = record
speed : cell_typ;
x, y, angle : array[1..100] of real;
var
cell : array[1..30] of cell_descriptor;
step_distri : array[g_shift..angle] of prob_mov;
max_shift : array[1..30] of real;
start_x, start_y, counter : integer;
graph_scale : gr_descriptor;
key : char;
N_line, N_pix_inline : integer;
graph_X, graph_Y : array[slow..fast] of integer;
marker_place : array[arg_edit..diag_edit, 1..11] of scr_adr;
name_place, cell_place : scr_adr;
step_len, step_ang, current_x, current_y, current_a : real;
choose_cell : cell_typ;
sign : integer;
procedure draw_axis;
i, j : word;
bintext : string;
begin
with graph_scale do
x_0:=round(N_pix_inline/40);
y_0:=round(N_line/40);
X_len:=round(N_pix_InLine-2*x_0);
Y_len:=round(N_line-2*y_0);
setlinestyle(0,0,1);
rectangle(x_0,Y_0,x_0+X_len,Y_0+Y_len);
procedure opengraph;
grdriver, grmode : integer;
detectgraph(grdriver,grmode);
initgraph(grdriver,grmode,'');
N_line:=getmaxY;
N_pix_inline:=getmaxX;
start_x:=n_pix_inline div 2;
start_y:=n_line div 2;
SetBkColor(Black);
SetColor(LightRed);
cleardevice;
draw_axis;
procedure readscreen(fname : string; Tcl,Tbg : word);
x, y, j, txt_b, txt_c : word;
i : array [arg_edit..diag_edit] of word;
a : char;
d : text;
assign(d,fname);
reset(d);
txt_b:=Black;
TextBackground(txt_b);
clrscr;
y:=0;
i[arg_edit]:=0; i[fun_edit]:=0; i[diag_edit]:=0;
repeat
y:=y+1; x:=0;
x:=x+1;
read(d,a);
case a of
'.' : begin
if txt_b=Black then txt_b:=Tbg else txt_b:=Black;
txt_c:=Tcl;
textbackground(txt_b);
textcolor(txt_c);
WRITE(' ');
'*' : begin
name_place.x:=x;
name_place.y:=y;
write(' ');
'$' : begin
cell_place.x:=x;
cell_place.y:=y;
'#' : begin
i[arg_edit]:=i[arg_edit]+1;
marker_place[arg_edit,i[arg_edit]].x:=x;
marker_place[arg_edit,i[arg_edit]].y:=y;
'~' : begin
i[fun_edit]:=i[fun_edit]+1;
marker_place[fun_edit,i[fun_edit]].x:=x;
marker_place[fun_edit,i[fun_edit]].y:=y;
'!' : begin
i[diag_edit]:=i[diag_edit]+1;
marker_place[diag_edit,i[diag_edit]].x:=x;
marker_place[diag_edit,i[diag_edit]].y:=y;
else
write(a);
until eoln(d);
readln(d); writeln;
until eof(d);
close(d);
procedure readreal(var value : real; a : char; len : word; ad : scr_adr);
var LI : array[1..10] of char;
x,y,old : integer;
st : string;
write(' ':len);
gotoXY(ad.x,ad.y);
LI[1]:=a; write(a); y:=2;
if a<>#13 then
a:=readkey;
if a=',' then a:='.';
if ((a='O') or (a='o')) then a:='0';
if ((a>='0') and (a10 then j:=10;
if j='0') and (astep_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)=15 then cell[i].speed:=fast;
if (max_shift[i]>=7) and (max_shift[i]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];
if x>50 then sign:=-1 else sign:=1;
procedure make_all_steps;
var i, j : word;
for i:=1 to 30 do
with cell[i] do
for j:=2 to 100 do
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);
procedure print_coord;
var i, j, k : word;
f : text;
for j:=1 to 100 do
writeln(i:5,x[j]:9:2,y[j]:9:2);
if j mod 20 = 0 then readln(k);
procedure speed_meas;
i,j : word;
z : real;
shift : array[1..30] of real;
for i:=1 to 30 do shift[i]:=0;
z:=sqrt((x[j]-x[j-1])*(x[j]-x[j-1])+(y[j]-y[j-1])*(y[j]-y[j-1]));
shift[i]:=shift[i]+z;
begin shift[i]:=shift[i]/100;
procedure write_shift;
assign(f,'treck.txt');
rewrite(f);
for j:=1 to 30 do shift[j]:=0;
j:=2;
j:=j+1;
write(f,j:3);
write(f,shift[i]:9:2);
writeln(f);
until j=100;
close(f);
procedure write_angle;
assign(f,'angle.txt');
with step_distri[angle] do
for j:=0 to 10 do writeln(f,step[j]:10:2,cent[j]:10,cummulate[j]:10);
procedure write_disp;
shift, loc_calc : array[1..30] of real;
assign(f,'disper.txt');
for j:=1 to 30 do begin loc_calc[j]:=0; shift[j]:=0; end;
j:=1;
write(f,ln(j):10:2);
loc_calc[i]:=0;
for k:=j+1 to 100 do
z:=(x[k]-x[k-j])*(x[k]-x[k-j])+(y[k]-y[k-j])*(y[k]-y[k-j]);
loc_calc[i]:=loc_calc[i]+z;
shift[i]:=loc_calc[i]/(100-j);
write(f,0.5*ln(shift[i]):10:2);
until j=98;
procedure write_distr;
z : word;
shift : array[0..35] of word;
assign(f,'dist_sp.txt');
for j:=0 to 35 do shift[j]:=0;
z:=round(sqrt((x[j]-x[j-1])*(x[j]-x[j-1])+(y[j]-y[j-1])*(y[j]-y[j-
1])));
shift[z]:=shift[z]+1;
for j:=0 to 30 do writeln(f,j:3,shift[j]:10);
procedure draw_cell(c : cell_typ; x, y : real);
color, graph_x, graph_y : integer;
case c of
slow : color:=lightcyan;
mean : color:=yellow;
fast : color:=white;
graph_x:=round(x*n_pix_inline/2000);
graph_y:=round(y*n_line/2000);
putpixel(graph_x,graph_y,color);
procedure draw_picture;
draw_cell(speed,x[j],y[j]);
randomize;
init;
make_all_steps;
speed_meas;
write_shift;
write_distr;
write_disp;
write_angle;
opengraph;
draw_picture;
key:=readkey;
closegraph;
end.
Страницы: 1, 2, 3, 4, 5, 6, 7