Procedure TForm1.changePole( a,b,c,d: integer);
var i,j: integer;
begin
    for  i:=a to c do
 for j:=b to d do
 begin
 if pole[i,j].col=1 then pole[i,j].col:=0 else pole[i,j].col:=1 ;
 end;
 end;



 Procedure TForm1.Intelegence;
var max,min1,i,j,q, max1,max2,z,a,b,c,d,e,f,t,r,p,m,i1i,i2i,j1i,j2i: integer;
begin
  max:=-25;
  z:=-25;
  for i1i:=1 to n do
   for j1i:= 1 to n do
    for i2i:=i1i to n do
     for j2i:=j1i to n do
     begin
     max2:=HowMuch (0,i1i,j1i,i2i,j2i)-HowMuch (1,i1i,j1i,i2i,j2i);
     max1:=HowMuch (1,i1i,j1i,i2i,j2i)-HowMuch(0,i1i,j1i,i2i,j2i);
     if  max1>max then
     begin
     max:=max1;
     a:=i1i;
     b:=j1i;
     c:=i2i;
     d:=j2i;
     end;
     {if max2>z then
      begin
     z:=max2;
     e:=i1i;
     f:=j1i;
     t:=i2i;
     r:=j2i;
     p:=HowMuch (1,i1i,j1i,i2i,j2i);
     m:=HowMuch (0,i1i,j1i,i2i,j2i)
      end;}
      end;
     {k:=Howmuch(1,1,1,n,n);
     showmessage('Õîä Êîìïüþòåðà');
     if P=0 then
     begin
      if (p=0)and ((m mod 5)=0) and (m<>5) then
        e:=t
        else
        begin
      if (p=0) and (f>1) then
      begin
      f:=f-1;
      r:=f;
      end;
      if (p=0) and (f=1) and (e=1) then
       begin
       e:=t+1;
       t:=e;
       end;
        changePole( e,f,t,r) ;

       end
       end
       else
       begin}
     if ((a=m) and (c=u) and (b=p) and (d=o)) then
     begin
        a:=random(2)+1;
        b:=random (2)+1 ;
        c:=random(3)+2;
        d:=random(3)+2;

     end;
 changePole( a,b,c,d) ;

 k:=HowMuch (1,1,1,n,n);
 if (k=0) then Label2.Visible:= true;
  ShowMass;
end;