anchor.diff:      if Company[I].IsGroupInCompany(aGroup) then
         Exit;
     Result := False;
  -end;
  -
  -
  -// Find best target -> to secure that AI will be as universal as possible find only point in map and company will destroy everything around automatically
  -function TKMArmyAttack.FindBestTarget(var TargetOwner: TKMHandIndex; var aTargetPoint: TKMPoint; aForceToAttack: Boolean = False): Boolean;
  -const
  -  DISTANCE_COEF = 0.75; // If second enemy is twice as far away decrease chance by 3/8
  -  MIN_COMPARSION = 0.2; // 20% advantage for attacker
  -var
  -  I, MinDist: Integer;
  -  Comparison, BestComparison: Single;
  -  Group: TKMUnitGroup;
  -  CenterPoints: TKMPointArray;
  -  EnemyStats: TKMEnemyStatisticsArray;
  -begin
  -  Result := False;
  -  aTargetPoint := KMPOINT_ZERO;
  -
  -  // Find center point of city / army (where we should start scan - init point / center screen is useless for this)
  -  CenterPoints := gAIFields.Eye.GetCityCenterPoints(True);
  -  if (Length(CenterPoints) = 0) then // No important houses were found -> try find soldier
  -  begin
  -    Group := gHands[fOwner].UnitGroups.Groups[ KaMRandom(gHands[fOwner].UnitGroups.Count) ];
  -    if (Group <> nil) then
  -    begin
  -      SetLength(CenterPoints, 1);
  -      CenterPoints[0] := Group.Position;
  -    end
  -    else
  -      Exit;
  -  end;
  -
  -  // Try find enemies by influence area
  -  if not gAIFields.Influences.InfluenceSearch.FindClosestEnemies(fOwner, CenterPoints, True) then // Try find hostile house
  -    if not gAIFields.Influences.InfluenceSearch.FindClosestEnemies(fOwner, CenterPoints, False) then // Try find hostile unit
  -      Exit;
  -  EnemyStats := gAIFields.Influences.InfluenceSearch.EnemiesStats;
  -
  -  // Calculate strength of alliance, find best comparison - value in interval <-1,1>, positive value = advantage, negative = disadvantage
  -  BestComparison := -1;
  -  if (Length(EnemyStats) > 0) then
  -  begin
  -    // Find closest enemy
  -    MinDist := High(Integer);
  -    for I := 0 to Length(EnemyStats) - 1 do
  -      if (MinDist > EnemyStats[I].Distance) then
  -        MinDist := EnemyStats[I].Distance;
  -
  -    for I := 0 to Length(EnemyStats) - 1 do
  -    begin
  -      Comparison := gAIFields.Eye.ArmyEvaluation.CompareAllianceStrength(fOwner, EnemyStats[I].Player) - (EnemyStats[I].Distance / Max(1,MinDist) - 1) * DISTANCE_COEF;
  -      if (Comparison > BestComparison) then
  -      begin
  -        BestComparison := Comparison;
  -        TargetOwner := EnemyStats[I].Player;
  -        aTargetPoint := EnemyStats[I].ClosestPoint;
  -      end;
  -    end;
  -  end;
  -
  -  Result := (Length(EnemyStats) > 0) AND (aForceToAttack OR (BestComparison > MIN_COMPARSION));
   end;
   
   
  
positive.code:   else if (fTargetHouse <> nil) then
    begin
      FinPos := fTargetHouse.GetPosition;
      if PlanPath(ActPos, FinPos, False, True) then
        Group.OrderWalk(FinPos, True, wtokAISquad, FinalPosition.Dir)
      else if fTargetChanged OR (fAttackTimeLimit < aTick) then
      begin
  
negative.code: end;
  
  
  function TAISquad.PlanPath(aTick: Cardinal; var aActualPosition, aTargetPosition: TKMPoint; aOrderAttack: Boolean = False; aOrderDestroy: Boolean = False): Boolean;
  const
    SQR_POSITION_REACHED_TOLERANCE = 3*3; // Tolerance between reached point and actual position it is useful in traffic problems
    SQR_TARGET_REACHED_TOLERANCE = 3*3; // Target unit should have lower tolerance because of group type pathfinding (cav will avoid spears etc)
  