anchor.diff:  type
   
     TBuildNode = record
  -    Active, RemoveTreesMode: Boolean;
  -    FreeWorkers, RequiredWorkers, MaxReqWorkers, ResponsibleHouseIdx: Integer;
  -    ResponsibleHouseType: THouseType;
  +    Active, RemoveTreesMode, ShortcutMode: Boolean;
  +    FreeWorkers, RequiredWorkers, MaxReqWorkers: Integer;
       CenterPoint: TKMPoint;
  -    FieldType: TFieldType; //ft_Corn,ft_Wine  ft_Road
  +    FieldType: TFieldType; //ft_Corn, ft_Wine, ft_Road
       FieldList: TKMPointList;
     end;
   
  
positive.code:     Output := gHands[fOwner].CanAddHousePlan(Loc, aHT);
      if Output then
      begin
        // Update reservation status
        if fPlanner.PlannedHouses[aHT,HouseIdx].HouseReservation AND not aHouseReservation then
        begin
          fPlanner.PlannedHouses[aHT,HouseIdx].HouseReservation := False;
          UnLockHouseLoc(aHT, Loc);
        end;
        gHands[fOwner].AddHousePlan(aHT, Loc); // Place house
        if not fPlanner.PlannedHouses[aHT,HouseIdx].HouseReservation then
        begin
          // Add road to node
          if fPlanner.GetRoadToHouse(aHT, HouseIdx, fBuildNodes[Node1Idx].FieldList, fBuildNodes[Node1Idx].FieldType) then
          begin
            LockNode(fBuildNodes[Node1Idx]);
            with fBuildNodes[Node1Idx] do
            begin
              Active := True;
              RemoveTreesMode := False;
              MaxReqWorkers := 5 + Byte(aUnlockProcedure) * 20;
              RequiredWorkers := Min(MaxReqWorkers, FieldList.Count);
              CenterPoint := FieldList[0];
            end;
          end;
          // Add field to node (if is required [ht_Farm, ht_Wineyard])
          if fPlanner.GetFieldToHouse(aHT, HouseIdx, fBuildNodes[Node2Idx].FieldList, fBuildNodes[Node2Idx].FieldType) then
          begin
            LockNode(fBuildNodes[Node2Idx]);
            with fBuildNodes[Node2Idx] do
            begin
              Active := True;
              RemoveTreesMode := False;
              MaxReqWorkers := 5 + Byte(aUnlockProcedure) * 20;
              RequiredWorkers := Min(MaxReqWorkers, FieldList.Count);
              CenterPoint := Loc;
            end;
          end;
        end;
        // Reserve house place
        if aHouseReservation then
        begin
          fPlanner.PlannedHouses[aHT,HouseIdx].HouseReservation := True;
          gHands[fOwner].RemHousePlan(Loc);
          LockHouseLoc(aHT, Loc);
        end;
      end
      else
      begin
        // Remove tree procedure is already active
        if (fPlanner.PlannedHouses[aHT,HouseIdx].RemoveTreeInPlanProcedure) then
        begin
          // Wait till is tree removed
        end
  
negative.code: end;
  
  
  procedure TKMCityBuilder.UpdateState(aTick: Cardinal; out aFreeWorkersCnt: Integer);
  var
    Outline1, Outline2: TKMWeightSegments;
  begin
    if (aTick mod MAX_HANDS = fOwner) then
    begin
      fPlanner.UpdateState(aTick); // Planner must be updated as first to secure that completed houses are actualized
      UpdateBuildNodes(aFreeWorkersCnt);
    end;
    ////((gGame.GameOptions.Peacetime <> 0) and gGame.CheckTime(600 * Max(0, gGame.GameOptions.Peacetime - 15)))
    //if (aTick = 50) then
    //  gAIFields.NavMesh.GetDefenceOutline(fOwner, Outline1, Outline2);
  end;
  
  
  procedure TKMCityBuilder.LockHouseLoc(aHT: THouseType; aLoc: TKMPoint);
  var
    I,Dist: Integer;
    Point: TKMPoint;
    Dir: TDirection;
    HMA: THouseMappingArray;
  begin
    HMA := gAIFields.Eye.HousesMapping;
    // Reserve all tiles inside house plan
    for I := Low(HMA[aHT].Tiles) to High(HMA[aHT].Tiles) do
      gAIFields.Influences.AvoidBuilding[aLoc.Y + HMA[aHT].Tiles[I].Y, aLoc.X + HMA[aHT].Tiles[I].X] := AVOID_BUILDING_HOUSE_INSIDE_LOCK;
    // Reserve all tiles in distance 1 from house plan
    Dist := 1;
    for Dir := Low(HMA[aHT].Surroundings[Dist]) to High(HMA[aHT].Surroundings[Dist]) do
      for I := Low(HMA[aHT].Surroundings[Dist,Dir]) to High(HMA[aHT].Surroundings[Dist,Dir]) do
      begin
        Point := KMPointAdd(aLoc, HMA[aHT].Surroundings[Dist,Dir,I]);
        if (gAIFields.Influences.AvoidBuilding[Point.Y, Point.X] < AVOID_BUILDING_HOUSE_INSIDE_LOCK) then
          gAIFields.Influences.AvoidBuilding[Point.Y, Point.X] := AVOID_BUILDING_HOUSE_OUTSIDE_LOCK;
      end;
  end;
  
  
  procedure TKMCityBuilder.UnlockHouseLoc(aHT: THouseType; aLoc: TKMPoint);
  var
    I,Dist: Integer;
    Point: TKMPoint;
    Dir: TDirection;
    HMA: THouseMappingArray;
  begin
    HMA := gAIFields.Eye.HousesMapping;
    // Free all tiles inside house plan
    for I := Low(HMA[aHT].Tiles) to High(HMA[aHT].Tiles) do
      gAIFields.Influences.AvoidBuilding[aLoc.Y + HMA[aHT].Tiles[I].Y, aLoc.X + HMA[aHT].Tiles[I].X] := AVOID_BUILDING_UNLOCK;
    // Free all tiles in distance 1 from house plan
    Dist := 1;
    for Dir := Low(HMA[aHT].Surroundings[Dist]) to High(HMA[aHT].Surroundings[Dist]) do
      for I := Low(HMA[aHT].Surroundings[Dist,Dir]) to High(HMA[aHT].Surroundings[Dist,Dir]) do
      begin
        Point := KMPointAdd(aLoc, HMA[aHT].Surroundings[Dist,Dir,I]);
        if (gAIFields.Influences.AvoidBuilding[Point.Y, Point.X] = AVOID_BUILDING_HOUSE_OUTSIDE_LOCK) then
          gAIFields.Influences.AvoidBuilding[Point.Y, Point.X] := AVOID_BUILDING_UNLOCK;
      end;
  end;
  
  
  procedure TKMCityBuilder.LockNode(var aNode: TBuildNode);
  var
    NODE_TYPE: Byte;
    I: Integer;
  begin
    case aNode.FieldType of
      ft_Road: NODE_TYPE := AVOID_BUILDING_NODE_LOCK_ROAD;
      else     NODE_TYPE := AVOID_BUILDING_NODE_LOCK_FIELD;
    end;
    with aNode.FieldList do
      for I := 0 to Count-1 do
        if (gAIFields.Influences.AvoidBuilding[Items[I].Y, Items[I].X] < NODE_TYPE) then
          gAIFields.Influences.AvoidBuilding[Items[I].Y, Items[I].X] := NODE_TYPE;
  end;
  
  
  procedure TKMCityBuilder.UnlockPointOfNode(aPoint: TKMPoint);
  begin
    if (gAIFields.Influences.AvoidBuilding[aPoint.Y, aPoint.X] = AVOID_BUILDING_NODE_LOCK_ROAD) then // Only roads are unlocked
      gAIFields.Influences.AvoidBuilding[aPoint.Y, aPoint.X] := AVOID_BUILDING_UNLOCK;
  end;
  
  
  procedure TKMCityBuilder.UnlockNode(var aNode: TBuildNode);
  var
    I: Integer;
  begin
    with aNode.FieldList do
      for I := 0 to Count-1 do
        UnlockPointOfNode(Items[I]);
  end;
  
  
  //procedure ActivateNode(var aNode: TBuildNode; aRemoveTreesMode,aShortcutMode: Boolean = False);
  //begin
  //  with aNode do
  //  begin
  //    Active := True;
  //    RemoveTreesMode := aRemoveTreesMode;
  //    ShortcutMode := aShortcutMode;
  //    MaxReqWorkers := 5;
  //    RequiredWorkers := Min(MaxReqWorkers, FieldList.Count); // Real count will be updated during building process
  //    CenterPoint := Loc;
  //  end;
  //end;
  
  
  procedure TKMCityBuilder.UpdateBuildNodes(out aFreeWorkersCnt: Integer);
  