anchor.diff:  
   
   function TKMCityPlanner.SnapCrit(aHT: THouseType; aLoc: TKMPoint): Single;
  -  function IsPlan(aPoint: TKMPoint; aLock: TTileLock; aField: TFieldType): Boolean;
  +  function IsPlan(aPoint: TKMPoint; aLock: TTileLock; aField: TFieldType): Boolean; inline;
     begin
       Result := (gHands[fOwner].BuildList.FieldworksList.HasField(aPoint) = aField)
                 OR (gTerrain.Land[aPoint.Y, aPoint.X].TileLock = aLock);
     end;
  -  function IsRoad(aPoint: TKMPoint): Boolean;
  +  function IsRoad(aPoint: TKMPoint): Boolean; inline;
     begin
       Result := gTerrain.TileIsWalkableRoad(aPoint) OR IsPlan(aPoint, tlRoadWork, ft_Road);
     end;
  -  function IsCornField(aPoint: TKMPoint): Boolean;
  +  function IsCornField(aPoint: TKMPoint): Boolean; inline;
     begin
       Result := gTerrain.TileIsCornField(aPoint) OR IsPlan(aPoint, tlFieldWork, ft_Corn);
     end;
  -  function IsWineField(aPoint: TKMPoint): Boolean;
  +  function IsWineField(aPoint: TKMPoint): Boolean; inline;
     begin
       Result := gTerrain.TileIsWineField(aPoint) OR IsPlan(aPoint, tlFieldWork, ft_Wine);
     end;
  -  function IsNearHouse(aPoint: TKMPoint): Boolean;
  +  function IsNearHouse(aPoint: TKMPoint): Boolean; inline;
     begin
       Result := not (tpBuild in gTerrain.Land[aPoint.Y,aPoint.X].Passability);
     end;
  -  function IsAvoidBuilding(aPoint:TKMPoint): Boolean;
  +  function IsAvoidBuilding(aPoint: TKMPoint): Boolean; inline;
     begin
       Result := gAIFields.Influences.AvoidBuilding[aPoint.Y, aPoint.X] > 0;
     end;
  
positive.code:   GA_PLANNER_FindPlaceForQuary_SnapCrit             : Single = 26.14780426;
    GA_PLANNER_FindPlaceForQuary_DistCrit             : Single = 37.61137009;
    GA_PLANNER_FindPlaceForWoodcutter_DistFromForest  : Single = 28.76280212;
    GA_PLANNER_FindPlaceForWoodcutter_DistCrit        : Single = 44.20793533;
    GA_PLANNER_FindPlaceForWoodcutter_TreeCnt         : Single = 0.1000000015;
    GA_PLANNER_FindPlaceForWoodcutter_SnapToEdge      : Single = 5.223324299;
    GA_PLANNER_FindPlaceForWoodcutter_CanPlaceTreeCnt : Single = 30.30228996;
    GA_PLANNER_FindPlaceForWoodcutter_PlansAround     : Single = 4.992388725;
  
negative.code:   end;
    Result := Output;
  end;
  
  
  function TKMCityPlanner.PlanDefenceTowers(): Boolean;
  
    procedure FindPlaceForTowers(aCenter: TKMPoint);
    const
      RADIUS = 3;
      MAX_BID = 100000;
    var
      X,Y: Integer;
      Bid, BestBid: Single;
      Loc, BestLoc: TKMPoint;
    begin
      BestBid := MAX_BID;
      for Y := Max(1, aCenter.Y - RADIUS) to Min(gTerrain.MapY, aCenter.Y + RADIUS) do
      for X := Max(1, aCenter.X - RADIUS) to Min(gTerrain.MapX, aCenter.X + RADIUS) do
      begin
        Loc := KMPoint(X,Y);
        if gAIFields.Eye.CanAddHousePlan(Loc, ht_WatchTower, True, False) then
        begin
          Bid := KMDistanceAbs(aCenter, Loc);
          if (Bid < BestBid) then
          begin
            BestBid := Bid;
            BestLoc := Loc;
          end;
        end;
      end;
      if (BestBid <> MAX_BID) then
        AddPlan(ht_WatchTower, BestLoc);
    end;
  
  const
    DISTANCE_BETWEEN_TOWERS = 10;
  var
    I, K, DefCount: Integer;
    P1,P2: TKMPoint;
    Ratio: Single;
    DefLines: TKMDefenceLines;
  begin
    Result := False;
  
    if not gHands[fOwner].Locks.HouseCanBuild(ht_WatchTower)
      OR not gAIFields.NavMesh.GetDefenceLines(fOwner, DefLines)
      OR (DefLines.Count < 1) then
      Exit;
  
    //Make list of defence positions
    for I := 0 to DefLines.Count-1 do
    begin
      P1 := gAIFields.NavMesh.Nodes[ DefLines.Lines[I].Nodes[0] ].Loc;
      P2 := gAIFields.NavMesh.Nodes[ DefLines.Lines[I].Nodes[1] ].Loc;
      DefCount := Ceil( KMLength(P1,P2) / DISTANCE_BETWEEN_TOWERS );
      for K := 0 to DefCount - 1 do
      begin
        Ratio := (K + 1) / (DefCount + 1);
        FindPlaceForTowers( KMPointRound(KMLerp(P1, P2, Ratio)) );
      end;
    end;
    Result := True;
  end;
  
  
  
  procedure TKMCityPlanner.Paint();
  