with Ada.Text_IO; with Ada.Integer_Text_IO; procedure pingwiny is package T_IO renames Ada.Text_IO; package I_IO renames Ada.Integer_Text_IO; type Pingwin is record x: Natural; y: Natural; end record; type Macierz is array (Positive range<>, Positive range<>) of Natural; type Wektor is array (Positive range <>) of Pingwin; procedure Symuluj(Plansza: Macierz; Pingwiny: Wektor) is function Finish return Boolean is function SprawdzPingwina(nr: Positive) return Boolean is WolnePola : Integer := 0; Fields: constant array (1 .. 6, 1 .. 2) of Integer := ( 1 => (0,-1), -- górny lewy 2 => (1,-1), -- górny prawy 3 => (-1,0), -- środkowy lewy 4 => (1,0), -- środkowy prawy 5 => (0,1), -- dolny lewy 6 => (-1,1) -- dolny prawy ); x: Integer; y: Integer; begin SprawdzPola: for i in Fields'Range loop x := Pingwiny(i).x + Fields(i,1); y := Pingwiny(i).y + Fields(i,2); if not (x in Plansza'Range(2)) or not (y in Plansza'Range(1)) then WolnePola := WolnePola + 1; end if; end loop SprawdzPola; return true; end SprawdzPingwina; MozliwyRuch: Boolean := false; begin SprawdzPingwiny: for i in Pingwiny'Range loop if not (SprawdzPingwina(i)) then MozliwyRuch := true; exit SprawdzPingwiny; end if; end loop SprawdzPingwiny; return not(MozliwyRuch); end Finish; begin T_IO.Put_Line("Symulację czas zacząć"); SymulacjaPetla: while not(Finish) loop null; end loop SymulacjaPetla; null; end Symuluj; LiczbaPingwinow, LiczbaKier, Wysokosc, Szerokosc: Positive; begin T_IO.Put("Podaj dane: (Liczba pinginow, Liczba kier, Wysokosc, Szerokosc): "); I_IO.Get(Item => LiczbaPingwinow); I_IO.Get(Item => LiczbaKier); I_IO.Get(Item => Wysokosc); I_IO.Get(Item => Szerokosc); T_IO.Put("Pingwinow: "); I_IO.Put(Item => LiczbaPingwinow, Width => 0); T_IO.New_Line; T_IO.Put("Wymiary to: ("); I_IO.Put(Item => Szerokosc, Width => 0); T_IO.Put(","); I_IO.Put(Item => Wysokosc, Width => 0); T_IO.Put_Line(")"); -- Chuj ci w dupę alokujemy sobie tabliice declare MacierzPingwiny: Macierz(1 .. Wysokosc, 1 .. Szerokosc); WektorPingwiny: Wektor(1 .. Wysokosc); WspolX, WspolY: Integer; LiczbaRyb: Positive; begin T_IO.Put_Line("Start"); ZeroingRows: for i in Integer range 1 .. Wysokosc loop ZeroingCols: for j in Integer range 1 .. Szerokosc loop MacierzPingwiny(i,j) := 0; end loop ZeroingCols; end loop ZeroingRows; T_IO.Put_Line("Wczytujemy pingwiny"); WczytujPingwiny: for i in Integer range 1 .. LiczbaPingwinow loop T_IO.Put_Line("Reading Pingwin"); I_IO.Get(Item => WektorPingwiny(i).x); I_IO.Get(Item => WektorPingwiny(i).y); T_IO.Put("Wczytany pingwin: ("); I_IO.Put(Item => WektorPingwiny(i).x, Width => 0); T_IO.Put(","); I_IO.Put(Item => WektorPingwiny(i).y, Width => 0); T_IO.Put_Line(")"); end loop WczytujPingwiny; T_IO.Put_Line("Wczytujemy kry z rybami"); WczytujKry: for i in Integer range 1 .. LiczbaKier loop T_IO.Put_Line("Reading Kra"); I_IO.Get(Item => WspolX); I_IO.Get(Item => WspolY); I_IO.Get(Item => LiczbaRyb); MacierzPingwiny(WspolY,WspolX) := LiczbaRyb; end loop WczytujKry; Symuluj(MacierzPingwiny,WektorPingwiny); end; null; end pingwiny;