anchor.diff:  
   
   procedure TAICompany.OrderMove(aActualPosition: TKMPoint);
  -const
  -  MINIMAL_MOVEMENT = 5;
  -var
  -  InitPolygon: Word;
  -  I, Idx, Cnt: Integer;
  -  TargetPoint: TKMPoint;
  -  Dir: TKMDirection;
  -  GT: TGroupType;
  -  PolygonPath: TKMWordArray;
  -  PointPath, PointPath2: TKMPointArray;
  -  InitPolygons: TKMWordArray;
  -  Squad: TAISquad;
  -begin
  -  TargetPoint := TargetPosition;
  -  if gAIFields.Eye.Pathfinding.Route_Make(aActualPosition, TargetPoint, PolygonPath, PointPath) then
  -  begin
  -    // Get center point on the path
  +
  +  function GetInitPolygons(aCnt: Integer; var aPointPath: TKMPointArray): TKMWordArray;
  +  const
  +    MINIMAL_MOVEMENT = 5;
  +    INIT_POLYGONS_COEF = 3;
  +  var
  +    InitPolygon: Word;
  +    I, Idx: Integer;
  +    InitPolygons: TKMWordArray;
  +  begin
  +    // Get initial point on the path (it must be in specific distance from actual position to secure smooth moving of the company)
       I := Length(PointPath)-1;
       while (I >= 0) AND (KMDistanceAbs(aActualPosition, PointPath[I]) < MINIMAL_MOVEMENT) do
         I := I - 1;
  -    InitPolygon := gAIFields.NavMesh.FindClosestPolygon(aActualPosition);
  +    // Make sure that platoon will not start in actual polygon but position will be moved forward
  +    InitPolygon := gAIFields.NavMesh.Point2Polygon[aActualPosition.Y,aActualPosition.X];
       repeat
  -      fPosition := PointPath[ Max(0, I) ];
  +      fPathPosition := PointPath[ Max(0, I) ];
         I := I - 1;
  -    until (InitPolygon <> gAIFields.NavMesh.FindClosestPolygon(fPosition)) OR (I < 0);
  -
  +    until (InitPolygon <> gAIFields.NavMesh.Point2Polygon[fPathPosition.Y,fPathPosition.X]) OR (I < 0);
  +
  +    I := Max(0,I + 1); // I = 0 we are in polygon of our target
  +    // Get several init polygons
  +    SetLength(InitPolygons, Min(Length(PointPath) - I, Max(1, aCnt div INIT_POLYGONS_COEF)) );
  +    Idx := 0;
  +    while (I >= 0) AND (Idx < Length(InitPolygons)) do
  +    begin
  +      InitPolygons[Idx] := gAIFields.NavMesh.Point2Polygon[PointPath[I].Y,PointPath[I].X];
  +      Idx := Idx + 1;
  +      I := I - 2;
  +    end;
  +    if (Idx <> Length(InitPolygons)) then
  +      SetLength(InitPolygons, Idx);
  +    Result := InitPolygons;
  +  end;
  +
  +  procedure SetOrders(aCnt: Integer; var aPositions: TKMPointArray);
  +  const
  +    TIME_PER_A_TILE = 8; // Max ticks per a tile
  +    INIT_DIST = 1000;
  +  var
  +    I, K, Dist, ClosestDist, ClosestIdx: Integer;
  +    Dir: TKMDirection;
  +    Position: TKMPoint;
  +    GT: TGroupType;
  +    Squads: array of TAISquad;
  +    AvaiableSquads: TBooleanArray;
  +    TagPositions: TKMPointTagList;
  +  begin
  +    TagPositions := TKMPointTagList.Create;
  +    try
  +      for I := 0 to Min(aCnt, High(aPositions)) do
  +        TagPositions.Add(aPositions[I], KMDistanceAbs(aActualPosition, aPositions[I]));
  +      TagPositions.SortByTag();
  +      fScanPosition := TagPositions.Items[TagPositions.Count - 1];
  +      //fPathPosition := TagPositions.Items[(TagPositions.Count - 1) div 2];
  +      Dir := KMGetDirection( aActualPosition, fPathPosition );
  +
  +      SetLength(Squads, aCnt);
  +      SetLength(AvaiableSquads, aCnt);
  +      K := 0;
  +      for GT := Low(TGroupType) to High(TGroupType) do
  +        for I := 0 to fSquads[GT].Count - 1 do
  +        begin
  +          Squads[K] := fSquads[GT].Items[I];
  +          AvaiableSquads[K] := True;
  +          K := K + 1;
  +        end;
  +      for I := TagPositions.Count - 1 downto 0 do
  +      begin
  +        Position := TagPositions.Items[I];
  +        ClosestDist := INIT_DIST;
  +        for K := 0 to Length(Squads) - 1 do
  +          if AvaiableSquads[K] then
  +          begin
  +            Dist := KMDistanceAbs(Position, Squads[K].Position);
  +            if (Dist < ClosestDist) then
  +            begin
  +              ClosestDist := Dist;
  +              ClosestIdx := K;
  +            end;
  +          end;
  +        if (ClosestIdx = INIT_DIST) then
  +          break;
  +        Squads[ClosestIdx].FinalPosition := KMPointDir(Position, Dir);
  +        Squads[ClosestIdx].TimeLimit := gGame.GameTickCount + KMDistanceAbs(Position, Squads[ClosestIdx].Position) * TIME_PER_A_TILE;
  +        AvaiableSquads[ClosestIdx] := False;
  +      end;
  +    finally
  +      TagPositions.Free;
  +    end;
  +  end;
  +
  +var
  +  Distance: Word;
  +  Cnt: Integer;
  +  TargetPoint: TKMPoint;
  +  PointPath, Positions: TKMPointArray;
  +  InitPolygons: TKMWordArray;
  +begin
  +  TargetPoint := TargetPosition;
  +  // Try find path to the target point
  +  if gAIFields.NavMesh.Pathfinding.ShortestRoute(aActualPosition, TargetPoint, Distance, PointPath) then
  +  begin
       fDEBUGPointPath := PointPath;
  -
  -    Cnt := SquadCnt();
  -    I := I + 1;
  -    SetLength(InitPolygons, Min(Length(PointPath) - I, Max(1, Cnt div 4)) );
  -    Idx := 0;
  -    while (I < Length(PointPath)) AND (Idx < Length(InitPolygons)) do
  -    begin
  -      InitPolygons[Idx] := gAIFields.NavMesh.FindClosestPolygon(PointPath[I]);
  -      Idx := Idx + 1;
  -      I := I + 2;
  -    end;
  -
  -    gAIFields.Eye.Positioning.FindPositions(Cnt, InitPolygons, PointPath2);
  -    Idx := 0;
  -    Dir := KMGetDirection( aActualPosition, fPosition );
  -    for GT := Low(TGroupType) to High(TGroupType) do
  -      for I := 0 to fSquads[GT].Count - 1 do
  -      begin
  -        if (Idx >= Length(PointPath2)) then
  -          break;
  -        Squad := fSquads[GT].Items[I];
  -        Squad.FinalPosition := KMPointDir(PointPath2[Idx], Dir);
  -        Idx := Idx + 1;
  -      end;
  +    Cnt := SquadCnt(); // Count of groups in company
  +
  +    // Get init polygons -> polygons on road which are base for army positioning (groups will get order to walk there)
  +    InitPolygons := GetInitPolygons(Cnt, PointPath);
  +
  +    // Get positions around init polygons
  +    gAIFields.NavMesh.Positioning.FindPositions(Cnt, InitPolygons, Positions);
  +
  +    // Compute distance of new positions and select the closest group to walk there
  +    SetOrders(Cnt, Positions);
     end;
   end;
   
  
positive.code: end;
  
  
  {
  function TAICompany.FindPath(aStart,aEnd: TKMPoint; aPolygonPath: TKMWordArray; aPointPath: TKMPointArray): Boolean;
  begin
    Result := fPathfinding.Route_Make(aStart, aEnd, aPolygonPath, aPointPath);
  end;
  }
  
  function TAICompany.IsGroupInCompany(aGroup: TKMUnitGroup): Boolean;
  var
    I: Integer;
    G: TGroupType;
    Squad: TAISquad;
  begin
    Result := True;
    for G := Low(TGroupType) to High(TGroupType) do
      for I := 0 to fSquads[G].Count-1 do
      begin
        Squad := fSquads[G][I];
        if (Squad.Group = aGroup) then
          Exit;
      end;
    Result := False;
  end;
  
  
negative.code:   inherited Create;
    LoadStream.ReadAssert('Company');
    LoadStream.Read(fOwner);
    LoadStream.Read(fPathPosition);
    LoadStream.Read(fScanPosition);
    LoadStream.Read(fTargetUnit, 4);
    LoadStream.Read(fTargetHouse, 4);
  
  