Модели сложных систем

Дипломная работа - Компьютеры, программирование

Другие дипломы по предмету Компьютеры, программирование

,{Mutate_Nach} Canv);

Mas[x1,y1].Xish^.Life:=1;

inc(AmountOfXishnik,1);

i:=i+1;

end;

end;;rasp='гауссово' then begin

i:=1;

while i<=AmountAtTheBeginingK do

begin

x1:=(2*(random(4)+MAXSIZEX div 2-1)+random(8)+MAXSIZEX div 2-4) div 3;

y1:=(2*(random(4)+MAXSIZEY div 2-1)+random(8)+MAXSIZEY div 2-4) div 3;

if Mas[x1,y1].Creature=nil then

begin

new(Mas[x1,y1].Creature);

Mas[x1,y1].Creature^:=TKosiak.Init(x1,y1,random(8)+1,{Mutate_Nach} Canv);

Mas[x1,y1].Creature^.Life:=1;

inc(AmountOfKosiak,1);

i:=i+1;

end;

end;

i:=1;

while i<=AmountAtTheBeginingX do

begin

x1:=(2*(random(4)+MAXSIZEX div 2-1)+random(8)+MAXSIZEX div 2-4) div 3;

y1:=(2*(random(4)+MAXSIZEY div 2-1)+random(8)+MAXSIZEY div 2-4) div 3;

if Mas[x1,y1].Xish=nil then

begin

new(Mas[x1,y1].Xish);

Mas[x1,y1].Xish^:=TXishnik.Init(x1,y1,random(8)+1,{Mutate_Nach} Canv);

Mas[x1,y1].Xish^.Life:=1;

inc(AmountOfXishnik,1);

i:=i+1;

end;

end;;rasp='обр.гаусс.' then begin

i:=1;

while i<=AmountAtTheBeginingK do

begin

if random(2)=1 then begin

x1:=(2*random(3)+random(4)) div 3;

y1:=random(MAXSIZEY)+1;

end

else begin

x1:=(2*(random(2)+MAXSIZEX-1)+random(4)+MAXSIZEX-3) div 3;

y1:=random(MAXSIZEY)+1;

end;

if Mas[x1,y1].Creature=nil then

begin

new(Mas[x1,y1].Creature);

Mas[x1,y1].Creature^:=TKosiak.Init(x1,y1,random(8)+1,{Mutate_Nach} Canv);

Mas[x1,y1].Creature^.Life:=1;

inc(AmountOfKosiak,1);

i:=i+1;

end;

end;

i:=1;

while i<=AmountAtTheBeginingX do

begin

if random(2)=1 then begin

x1:=(2*random(3)+random(4)) div 3;

y1:=random(MAXSIZEY)+1;

end

else begin

x1:=(2*(random(2)+MAXSIZEX-1)+random(4)+MAXSIZEX-3) div 3;

y1:=random(MAXSIZEY)+1;

end;

if Mas[x1,y1].Xish=nil then

begin

new(Mas[x1,y1].Xish);

Mas[x1,y1].Xish^:=TXishnik.Init(x1,y1,random(8)+1,{Mutate_Nach} Canv);

Mas[x1,y1].Xish^.Life:=1;

inc(AmountOfXishnik,1);

i:=i+1;

end;

end;;;TOkean.DrawGrid;

i: integer;

with Canva do

begin

Pen.Color:=clGray;

Brush.Color:=rgb(236,233,217);

Rectangle(0,0,MAXSIZEX*CELLSIZE+1,MAXSIZEY*CELLSIZE+1);

for i:=0 to MAXSIZEY do

begin

MoveTo(0,i*CELLSIZE);

LineTo(MAXSIZEX*CELLSIZE,i*CELLSIZE);

end;

for i:=0 to MAXSIZEX do

begin

MoveTo(i*CELLSIZE,0);

LineTo(i*CELLSIZE,MAXSIZEY*CELLSIZE);

end;

end;;TOkean.GetCanvas:TCanvas;

Result := Canva;;TOkean.KillKosiak(tx,ty: integer);

mas[tx,ty].Creature^.Done;

mas[tx,ty].Creature:=nil;;TOkean.DivisionKosiak(tx,ty: integer {n:vertype});i: integer;

if mas[tx+1,ty ].Creature = nil then

begin

tx:=tx+1;

end else

if mas[tx+1,ty+1].Creature = nil then

begin

tx:=tx+1;

ty:=ty+1;

end else

if mas[tx ,ty+1].Creature = nil then

begin

ty:=ty+1;

end else

if mas[tx-1,ty+1].Creature = nil then

begin

tx:=tx-1;

ty:=ty+1;

end else

if mas[tx-1,ty ].Creature = nil then

begin

tx:=tx-1;

end else

if mas[tx-1,ty-1].Creature = nil then

begin

tx:=tx-1;

ty:=ty-1;

end else

if mas[tx ,ty-1].Creature = nil then

begin

ty:=ty-1;

end;

if (mas[tx,ty].Creature = nil) and (tx<=MAXSIZEX) and (ty<=MAXSIZEY)

and (tx>=1) and (ty>=1) then

begin

new(Mas[tx,ty].Creature);

Mas[tx,ty].Creature^:=TKosiak.Init(tx,ty,random(8)+1,{mutate(n)} Canva);

inc(AmountOfKosiak,1);

end;;TOkean.KillXishnik(tx,ty: integer);

mas[tx,ty].Xish^.Done;

mas[tx,ty].Xish:=nil;;TOkean.DivisionXishnik(tx,ty: integer {n:vertype});i: integer;

if mas[tx+1,ty ].Xish = nil then

begin

tx:=tx+1;

end else

if mas[tx+1,ty+1].Xish = nil then

begin

tx:=tx+1;

ty:=ty+1;

end else

if mas[tx ,ty+1].Xish = nil then

begin

ty:=ty+1;

end else

if mas[tx-1,ty+1].Xish = nil then

begin

tx:=tx-1;

ty:=ty+1;

end else

if mas[tx-1,ty ].Xish = nil then

begin

tx:=tx-1;

end else

if mas[tx-1,ty-1].Xish = nil then

begin

tx:=tx-1;

ty:=ty-1;

end else

if mas[tx ,ty-1].Xish = nil then

begin

ty:=ty-1;

end;

if (mas[tx,ty].Xish = nil) and (tx<=MAXSIZEX) and (ty<=MAXSIZEY)

and (tx>=1) and (ty>=1) then

begin

new(Mas[tx,ty].Xish);

Mas[tx,ty].Xish^:=TXishnik.Init(tx,ty,random(8)+1,{mutate(n)} Canva);

inc(AmountOfXishnik,1);

end;;TOkean.Step;

k:integer;

dx,dy:integer;

i,j,m,l,a,b:integer;

nx,ny:integer;

flag:boolean;

for j:=1 to MAXSIZEY do

for i:=1 to MAXSIZEX do

begin

if mas[i,j].Xish<>nil then

if not mas[i,j].Xish^.IsHodila then

with mas[i,j].Xish^ do

begin

flag:=true;

for m:=1 to 8 do begin

k:=random(7)+1;

l:=k;

nx:=i;

ny:=j;

dx:=Raspozn({Vector[VecWas,l]}l).dx;

dy:=Raspozn({Vector[VecWas,l]}l).dy;

if ((nx+dx)=1) and

((ny+dy)=1) then

begin

if (mas[nx+dx,ny+dy].Xish=nil) and (mas[nx+dx,ny+dy].Creature<>nil) then

begin

New(mas[nx+dx,ny+dy].Xish);

mas[nx+dx,ny+dy].Xish^:=TXishnik.Init(nx+dx,ny+dy,VecWas,{VerMas}Canva);

mas[nx+dx,ny+dy].Xish^.life:=mas[nx,ny].Xish^.life;

mas[nx+dx,ny+dy].Xish^.syt:=mas[nx,ny].Xish^.syt;

mas[nx+dx,ny+dy].Xish^.gol:=mas[nx,ny].Xish^.gol;

KillXishnik(nx,ny);

nx:=nx+dx;

ny:=ny+dy;

flag:=false;

break;

end;

end;

end;

if flag then begin

k:=random(7)+1;

l:=k;

nx:=i;

ny:=j;

dx:=Raspozn({Vector[VecWas,l]}l).dx;

dy:=Raspozn({Vector[VecWas,l]}l).dy;

if ((nx+dx)=1) and

((ny+dy)=1) then

begin

if mas[nx+dx,ny+dy].Xish=nil then

begin

New(mas[nx+dx,ny+dy].Xish);

mas[nx+dx,ny+dy].Xish^:=TXishnik.Init(nx+dx,ny+dy,VecWas,{VerMas}Canva);

mas[nx+dx,ny+dy].Xish^.life:=mas[nx,ny].Xish^.life;

mas[nx+dx,ny+dy].Xish^.syt:=mas[nx,ny].Xish^.syt;

mas[nx+dx,ny+dy].Xish^.gol:=mas[nx,ny].Xish^.gol;

KillXishnik(nx,ny);

nx:=nx+dx;

ny:=ny+dy;

flag:=false;

break;

end;

end;

end;

if Mas[nx,ny].Creature<>nil then

begin

inc(Mas[nx,ny].Xish^.Syt,1);

Mas[nx,ny].Creature^.Gol:=Mas[nx,ny].Creature^.Gol+3;

Mas[nx,ny].Creature^.Syt:=0;

Mas[nx,ny].Xish^.Gol:=0;

end else

begin

Mas[nx,ny].Xish^.Syt:=0;

inc(Mas[nx,ny].Xish^.Gol,2);

end;

if Mas[nx,ny].Xish^.Gol>=MaxGolX then

begin

KillXishnik(nx,ny);

AmountOfXishnik:=AmountOfXishnik-1;

end;

if Mas[nx,ny].Xish<>nil then

begin

inc(Mas[nx,ny].Xish^.Life,1);

if Mas[nx,ny].Xish^.Life>=MaxLife then

begin

KillXishnik(nx,ny);

AmountOfXishnik:=AmountOfXishnik-1;

end;

end;

if Mas[nx,ny].Xish<>nil then

if Mas[nx,ny].Xish^.Syt>=PoraDelX then

begin

Mas[nx,ny].Xish^.Syt:=0;

Mas[nx,ny].Xish^.Gol:=0;

DivisionXishnik(nx,ny,{Mas[nx,ny].Creature^.vermas});

end;

if Mas[nx,ny].Xish<>nil then

Mas[nx,ny].Xish^.IsHodila:=True;

end;

end;

for j:=1 to MAXSIZEY do

for i:=1 to MAXSIZEX do

begin

if mas[i,j].Creature<>nil then

if not mas[i,j].Creature^.IsHodila then

with mas[i,j].Creature^ do

begin

k:=random(7)+1;

l:=k;

nx:=i;

ny:=j;

dx:=Raspozn({Vector[VecWas,l]}l).dx;

dy:=Raspozn({Vector[VecWas,l]}l).dy;

if ((nx+dx)=1) and

((ny+dy)=1) then

begin

if (mas[nx+dx,ny+dy].Creature=nil) and (mas[nx+dx,ny+dy].Xish=nil) then

begin

New(mas[nx+dx,ny+dy].Creature);

mas[nx+dx,ny+dy].Creature^:=TKosiak.Init(nx+dx,ny+dy,VecWas,{VerMas}Canva);

mas[nx+dx,ny+dy].Creature^.life:=mas[nx,ny].Creature^.life;

mas[nx+dx,ny+dy].Creature^.syt:=mas[nx,ny].Creature^.syt;

mas[nx+dx,ny+dy].Creature^.gol:=mas[nx,ny].Creature^.gol;

KillKosiak(nx,ny);

nx:=nx+dx;

ny:=ny+dy;

end;

end;

if Mas[nx,ny].Eda<>nil then

begin

if (Mas[nx,ny].Eda.GetKol-EST)>=0 then

begin

inc(Mas[nx,ny].Creature^.Syt,1);

Mas[nx,ny].Eda.SetKol(Mas[nx,ny].Eda.GetKol-EST);

end else

begin

Mas[nx,ny].Creature^.Syt:=0;

inc(Mas[nx,ny].Creature^.Gol,1);

end;

end;

if Mas[nx,ny].Creat