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

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

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

;

procedure Draw(a,b:integer);virtual;

procedure SetKol(h: integer);

function GetKol:integer;

destructor Done;virtual;

end;=class(TPlankton)

public

Life:integer; {время жизни}

Syt:integer; {коэфф. сытости}

Gol:integer; {коэфф. голодания}

VecWas:integer; {откуда пришёл}

IsHodila:boolean;

Canv:TCanvas;

private

constructor Init(x1, y1, vmove:integer; Canva:TCanvas);

function GetHod: boolean;

Procedure NilHod;

procedure Draw(a,b:integer);virtual;

Function Raspozn(k:integer):dxdy;

destructor Done;virtual;

end;=class(TKosiak)

constructor Init(x1, y1, vmove:integer; Canva:TCanvas);

function GetHod: boolean;

Procedure NilHod;

procedure Draw(a,b:integer);virtual;

Function Raspozn(k:integer):dxdy;

destructor Done;virtual;

end;=^TXishnik;=^TKosiak;=^TPlankton;=record

Xish:TPXishnik;

Creature:TPKosiak;

Eda:TPPlankton;

end;=class

x,y:integer;

Canva:TCanvas;

Mas:array[1..50,1..50] of TLink;

constructor Init(Canv: TCanvas);

procedure DrawGrid;

function GetCanvas:TCanvas;

Procedure KillXishnik(tx,ty: integer);

Procedure KillKosiak(tx,ty: integer);

procedure Draw(i,j:integer);

Procedure Step;DivisionXishnik(tx,ty: integer{ n:vertype});

Procedure DivisionKosiak(tx,ty: integer{ n:vertype});

end;

 

Syst:TOkean;

AmountAtTheBeginingK:integer;

AmountAtTheBeginingX:integer;

AmountOfKosiak:integer;

AmountOfXishnik:integer;

Counter:Integer;

MAXSIZEX:integer;

MAXSIZEY:integer;

rasp:string;

CellSize:integer;

MaxLife:integer; {время жизни}

PoraDelK:integer;

PoraDelX:integer; {когда делится}

MaxGolK:integer;

MaxGolX:integer; {когда умирает}

PlanktonGrow:integer;

EST:integer; {съедает за один раз}

p0k0x0: TBitmap;

p0k0x3: TBitmap;

p0k0x6: TBitmap;

p0k0x8: TBitmap;

p0k3x0: TBitmap;

p0k3x3: TBitmap;

p0k3x6: TBitmap;

p0k3x8: TBitmap;

p0k6x0: TBitmap;

p0k6x3: TBitmap;

p0k6x6: TBitmap;

p0k6x8: TBitmap;

p0k8x0: TBitmap;

p0k8x3: TBitmap;

p0k8x6: TBitmap;

p0k8x8: TBitmap;

p3k0x0: TBitmap;

p3k0x3: TBitmap;

p3k0x6: TBitmap;

p3k0x8: TBitmap;

p3k3x0: TBitmap;

p3k3x3: TBitmap;

p3k3x6: TBitmap;

p3k3x8: TBitmap;

p3k6x0: TBitmap;

p3k6x3: TBitmap;

p3k6x6: TBitmap;

p3k6x8: TBitmap;

p3k8x0: TBitmap;

p3k8x3: TBitmap;

p3k8x6: TBitmap;

p3k8x8: TBitmap;

p6k0x0: TBitmap;

p6k0x3: TBitmap;

p6k0x6: TBitmap;

p6k0x8: TBitmap;

p6k3x0: TBitmap;

p6k3x3: TBitmap;

p6k3x6: TBitmap;

p6k3x8: TBitmap;

p6k6x0: TBitmap;

p6k6x3: TBitmap;

p6k6x6: TBitmap;

p6k6x8: TBitmap;

p6k8x0: TBitmap;

p6k8x3: TBitmap;

p6k8x6: TBitmap;

p6k8x8: TBitmap;

p8k0x0: TBitmap;

p8k0x3: TBitmap;

p8k0x6: TBitmap;

p8k0x8: TBitmap;

p8k3x0: TBitmap;

p8k3x3: TBitmap;

p8k3x6: TBitmap;

p8k3x8: TBitmap;

p8k6x0: TBitmap;

p8k6x3: TBitmap;

p8k6x6: TBitmap;

p8k6x8: TBitmap;

p8k8x0: TBitmap;

p8k8x3: TBitmap;

p8k8x6: TBitmap;

p8k8x8: TBitmap;

kart: TBitmap;TKletka.Init(InitX, InitY: integer);

x:=initx; y:=inity;;TKletka.Draw;;TKletka.Done;;TKosiak.Init(x1, y1, vmove:integer; Canva :TCanvas);

x:=x1; y:=y1;

Canv := Canva;

VecWas:=vmove; {откуда пришёл}

Syt:=0; Gol:=5;

Life:=0;

IsHodila:=true;;TKosiak.GetHod: boolean;

Result:=IsHodila;;TKosiak.NilHod;

IsHodila:=false;;TKosiak.Raspozn(k:integer):dxdy;

case k of

1:begin Raspozn.dx:=-1;Raspozn.dy:=-1;end;

2:begin Raspozn.dx:=0;Raspozn.dy:=-1;end;

3:begin Raspozn.dx:=1;Raspozn.dy:=-1;end;

4:begin Raspozn.dx:=1;Raspozn.dy:=0;end;

5:begin Raspozn.dx:=1;Raspozn.dy:=1;end;

6:begin Raspozn.dx:=0;Raspozn.dy:=1;end;

7:begin Raspozn.dx:=-1;Raspozn.dy:=1;end;

8:begin Raspozn.dx:=-1;Raspozn.dy:=0;end;

end;;TKosiak.Draw(a,b:integer);

if gol<(MaxGolK div 2) then

case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k6x0);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k6x0);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k6x0);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k6x0);

end

else

case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k3x0);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k3x0);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k3x0);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k3x0);

end;

end;TKosiak.Done;;TXishnik.Init(x1, y1, vmove:integer;{v: Vertype} Canva :TCanvas);

x:=x1; y:=y1;

Canv := Canva;

VecWas:=vmove; {откуда пришёл}

Syt:=0; Gol:=5;

Life:=0;

IsHodila:=true;;TXishnik.GetHod: boolean;

Result:=IsHodila;;TXishnik.NilHod;

IsHodila:=false;;TXishnik.Raspozn(k:integer):dxdy;

case k of

1:begin Raspozn.dx:=-1;Raspozn.dy:=-1;end;

2:begin Raspozn.dx:=0;Raspozn.dy:=-1;end;

3:begin Raspozn.dx:=1;Raspozn.dy:=-1;end;

4:begin Raspozn.dx:=1;Raspozn.dy:=0;end;

5:begin Raspozn.dx:=1;Raspozn.dy:=1;end;

6:begin Raspozn.dx:=0;Raspozn.dy:=1;end;

7:begin Raspozn.dx:=-1;Raspozn.dy:=1;end;

8:begin Raspozn.dx:=-1;Raspozn.dy:=0;end;

end;;TXishnik.Draw(a,b:integer);

if gol<(MaxGolX div 2) then

case b of

0: case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k0x6);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k0x6);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k0x6);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k0x6);

end;

1: case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k3x6);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k3x6);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k3x6);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k3x6);

end;

2: case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k6x6);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k6x6);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k6x6);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k6x6);

end;

end

else

case b of

0: case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k0x3);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k0x3);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k0x3);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k0x3);

end;

1: case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k3x3);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k3x3);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k3x3);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k3x3);

end;

2: case a of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k6x3);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k6x3);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k6x3);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k6x3);

end;

end;

end;TXishnik.Done;;TPlankton.Init(initx, inity, kol: integer; Canva :TCanvas);

inherited Init(initx,inity);

Canv := Canva;

Amount:=kol;;TPlankton.SetKol(h: integer);

Amount:=h;;TPlankton.GetKol: integer;

Result:=Amount;;TPlankton.Draw;

case Amount of

0..29: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p0k0x0);

30..59: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p3k0x0);

60..79: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p6k0x0);

80..100: Canv.Draw(cellsize*(x-1)+1,cellsize*(y-1)+1,p8k0x0);

end;;TPlankton.Done;;TOkean.Init(Canv: TCanvas);i,j: integer;

x1,y1: integer;

CellSize:=52;

MaxLife:=20;

PlanktonGrow:=5;

EST:=10;

Canva := Canv;

DrawGrid;

AmountOfKosiak := 0;

AmountOfXishnik := 0;

for j:=1 to MAXSIZEY do

for i:=1 to MAXSIZEX do

begin

mas[i,j].Xish:=nil;

mas[i,j].Creature:=nil;

mas[i,j].Eda:=nil;

end;rasp='рандомное' then begin

i:=1;

while i<=AmountAtTheBeginingK do

begin

x1:=random(MAXSIZEX)+1;

y1:=random(MAXSIZEY)+1;

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:=random(MAXSIZEX)+1;

y1:=random(MAXSIZEY)+1;

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

begin

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

Mas[x1,y1].Xish^:=TXishnik.Init(x1,y1,random(8)+1