procedure TAnt_Hill.Put_Wood_Into_Hill(whereis, rozmer : integer)

Zpět
procedure TAnt_Hill.Put_Wood_Into_Hill(whereis, rozmer : integer);
var px, py, pom,i: integer;
   free_index : boolean;
begin
 if (whereis>=100) then begin
 whereis:=whereis-100;
 Data_Wood[whereis].where:=3;    // vetvicka je pryc :)
 inc(curr_num_woods_hill); // zvetsime pocet vetsicek v mravenisti
 SetLength(Data_Wood_Hill,curr_num_woods_hill);
 repeat
   px:=random(rozmer);
   py:=random(rozmer);
   pom:=round(sqrt((px-(rozmer div 2))*(px-(rozmer div 2))+(py-(rozmer div 2))*(py-(rozmer div 2))));
 until pom<=(rozmer div 2);
 Data_Wood_Hill[curr_num_woods_hill-1].x:=px-(rozmer div 2)+ curr_pos_ant_hill_x;
 Data_Wood_Hill[curr_num_woods_hill-1].y:=py-(rozmer div 2)+ curr_pos_ant_hill_y;
 Data_Wood_Hill[curr_num_woods_hill-1].where:=1; // vetvicka je v mravenisti
 Resize_Ant_Hill;
 changed_ant_hill := false;     // pribyla vetvicka
 curr_num_carried_woods:=Ant_Hill.curr_num_carried_woods -1; 
  end
  else begin   // vajicko je v mravesnisti.. narodi se novy mravenecek
     whereis:=whereis-10;
     Data_Egg[whereis].where:=3;    // vajicko je pryc :)
     free_index := false;
     i:=0;
     while (i<=Ant_Hill.curr_num_ants) and (free_index=false) do begin  // rovnost jen v dokumentaci
        if Data_Ants[i].live=0 then free_index:=true;
        inc(i);
        end;
     if free_index then begin
           Data_Ants[i-1].New_Ant;           // novy mravenec
        end
        else begin  // v poli neni misto .. zvetsime
          curr_num_ants:=curr_num_ants+1;
          SetLength(Data_Ants,curr_num_ants);
          Data_Ants[curr_num_ants-1]:=TMravenec.Init(curr_num_ants-1);
          Data_Ants[curr_num_ants-1].New_Ant;
        end;
 end

end;