anchor.diff:    begin
       // Get count of available group types
       FillChar(GTArr, SizeOf(GTArr), #0);
  -    for I := 0 to Length(aAvailableGroups) - 1 do
  +    for I := 0 to aAGCnt - 1 do
         Inc(  GTArr[ aAvailableGroups[I].GroupType ]  );
   
  -    CompaniesCnt := Max(1, Ceil(Length(aAvailableGroups) / MAX_GROUPS_IN_COMPANY));
  -    HighAG := Length(aAvailableGroups) - 1;
  +    CompaniesCnt := Max(1, Ceil(aAGCnt / MAX_GROUPS_IN_COMPANY));
  +    HighAG := aAGCnt - 1;
       for I := 0 to CompaniesCnt - 1 do
       begin
         GCnt := 0;
  
positive.code:       OR not Group.IsIdleToAI([wtokFlagPoint, wtokHaltOrder])
        OR (not TakeAllIn AND (Group.Count < MIN_TROOPS_IN_GROUP)) then
        Continue;
      if ForceToAttack then
      begin
        // Take all groups out of attack class
        if not fAttack.IsGroupInAction(Group) then
        begin
          if (Length(AvailableGroups) <= Cnt) then
            SetLength(AvailableGroups, Length(AvailableGroups) + 16);
          AvailableGroups[Cnt] := Group;
          Cnt := Cnt + 1;
        end;
      end
      else
      begin
        // Take group in defence position
        if (fDefence.FindPositionOf(Group) <> nil) then
        begin
          if (Length(AvailableGroups) <= Cnt) then
            SetLength(AvailableGroups, Length(AvailableGroups) + 16);
          AvailableGroups[Cnt] := Group;
          Cnt := Cnt + 1;
        end;
      end;
    end;
    // If we dont have groups exit
    if (Cnt = 0) then
      Exit;
  
  
    if fAttack.FindBestTarget(TargetOwner, TargetPoint, ForceToAttack) then
    begin
      SetLength(AvailableGroups, Cnt);
      for I := Low(AvailableGroups) to High(AvailableGroups) do
        fDefence.ReleaseGroup(AvailableGroups[I]);
      OrderAttack(TargetPoint, AvailableGroups);
      //if ForceToAttack OR (gAIFields.Eye.ArmyEvaluation.CompareAllianceStrength(TargetOwner, AvailableGroups) > COMPANY_MIN_ATTACK_CHANCE) then
    end;
  
    //Comparison := gAIFields.Eye.ArmyEvaluation.CompareAllianceStrength(fOwner, EnemyStats[I].Player) - (EnemyStats[I].Distance / MinDist - 1) * DISTANCE_COEF;
    //fAttack.AttackChance(AvailableGroups);
  
negative.code:   // ForceToAttack := ForceToAttack OR (gGame.MissionMode = mm_Tactic); // Maybe force attack in mm_Tactic map? But some of mm_Tactic map are also defensive...
  
    // Get array of pointers to available groups
    for I := 0 to gHands[fOwner].UnitGroups.Count - 1 do
    begin
      Group := gHands[fOwner].UnitGroups[I];
  