function margin(att,def,mar:longint):boolean;
var result:boolean;
    diff,maxmar,test:longint;
    megmar:longint;
    tmp:longint;
begin
  result:=false;
  diff:=att-def;

  if
    (((abs(diff)*100) div att) >(mar*2))  {If we are outside the random margin}
  then                          {then return true or false depending}
    if                          {on which value is greater...       }
      (diff>=0)
    then
      begin
        margin:=true;
        exit;
      end
    else
      begin
        margin:=false;
        exit;
      end;
  test:=random(def);
  diff:=def-att;
  tmp:=def-(def-att) div 2;
  if
    test<=tmp
  then
    result:=true
  else
    result:=false;
  margin:=result;
end;
