Program: 56054
Project: 56054
Buggy source:
@Override public ShortPoint2D findBestConstructionPosition(AiStatistics aiStatistics,AbstractConstructionMarkableMap constructionMap,byte playerId){
  List<ShortPoint2D> borderLandNextToFreeLandForPlayer=aiStatistics.getBorderLandNextToFreeLandForPlayer(playerId);
  if (borderLandNextToFreeLandForPlayer.size() == 0) {
    return null;
  }
  ImportantResource importantResource=detectMostImportantResourcePoints(aiStatistics,playerId,borderLandNextToFreeLandForPlayer.get(0));
  List<ShortPoint2D> militaryBuildings=aiStatistics.getBuildingPositionsOfTypeForPlayer(TOWER,playerId);
  militaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(BIG_TOWER,playerId));
  militaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(CASTLE,playerId));
  double nearestResourcePointDistance=Double.MAX_VALUE;
  List<ScoredConstructionPosition> scoredConstructionPositions=new ArrayList<ScoredConstructionPosition>();
  for (  ShortPoint2D point : borderLandNextToFreeLandForPlayer) {
    if (constructionMap.canConstructAt(point.x,point.y,buildingType,playerId) && !aiStatistics.blocksWorkingAreaOfOtherBuilding(point)) {
      ShortPoint2D nearestResourcePoint;
switch (importantResource) {
case TREES:
        nearestResourcePoint=aiStatistics.getNearestCuttableObjectPointInDefaultPartitionFor(point,EMapObjectType.TREE_ADULT);
      break;
case STONES:
    nearestResourcePoint=aiStatistics.getNearestCuttableObjectPointInDefaultPartitionFor(point,EMapObjectType.STONE);
  break;
case RIVER:
nearestResourcePoint=aiStatistics.getNearestRiverPointInDefaultPartitionFor(point);
break;
case GOLD:
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.GOLD);
break;
case FISH:
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.FISH);
break;
case IRON:
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.IRON);
break;
default :
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.COAL,nearestResourcePointDistance);
}
if (nearestResourcePoint != null) {
nearestResourcePointDistance=aiStatistics.getDistance(nearestResourcePoint,point);
ShortPoint2D nearestMilitairyBuildingPosition=aiStatistics.detectNearestPointFromList(point,militaryBuildings);
double militairyBuildingDistance=aiStatistics.getDistance(point,nearestMilitairyBuildingPosition);
scoredConstructionPositions.add(new ScoredConstructionPosition(point,nearestResourcePointDistance - militairyBuildingDistance));
}
}
}
return ScoredConstructionPosition.detectPositionWithLowestScore(scoredConstructionPositions);
}

Fixed version (ground truth):
@Override public ShortPoint2D findBestConstructionPosition(AiStatistics aiStatistics,AbstractConstructionMarkableMap constructionMap,byte playerId){
  List<ShortPoint2D> borderLandNextToFreeLandForPlayer=aiStatistics.getBorderLandNextToFreeLandForPlayer(playerId);
  if (borderLandNextToFreeLandForPlayer.size() == 0) {
    return null;
  }
  ImportantResource importantResource=detectMostImportantResourcePoints(aiStatistics,playerId,borderLandNextToFreeLandForPlayer.get(0));
  List<ShortPoint2D> militaryBuildings=aiStatistics.getBuildingPositionsOfTypeForPlayer(TOWER,playerId);
  militaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(BIG_TOWER,playerId));
  militaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(CASTLE,playerId));
  double nearestResourcePointDistance=Double.MAX_VALUE;
  List<ScoredConstructionPosition> scoredConstructionPositions=new ArrayList<ScoredConstructionPosition>();
  for (  ShortPoint2D point : borderLandNextToFreeLandForPlayer) {
    if (constructionMap.canConstructAt(point.x,point.y,buildingType,playerId) && !aiStatistics.blocksWorkingAreaOfOtherBuilding(point)) {
      ShortPoint2D nearestResourcePoint;
switch (importantResource) {
case TREES:
        nearestResourcePoint=aiStatistics.getNearestCuttableObjectPointInDefaultPartitionFor(point,EMapObjectType.TREE_ADULT,nearestResourcePointDistance);
      break;
case STONES:
    nearestResourcePoint=aiStatistics.getNearestCuttableObjectPointInDefaultPartitionFor(point,EMapObjectType.STONE,nearestResourcePointDistance);
  break;
case RIVER:
nearestResourcePoint=aiStatistics.getNearestRiverPointInDefaultPartitionFor(point,nearestResourcePointDistance);
break;
case GOLD:
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.GOLD,nearestResourcePointDistance);
break;
case FISH:
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.FISH,nearestResourcePointDistance);
break;
case IRON:
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.IRON,nearestResourcePointDistance);
break;
default :
nearestResourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(point,EResourceType.COAL,nearestResourcePointDistance);
}
if (nearestResourcePoint != null) {
nearestResourcePointDistance=aiStatistics.getDistance(nearestResourcePoint,point);
ShortPoint2D nearestMilitairyBuildingPosition=aiStatistics.detectNearestPointFromList(point,militaryBuildings);
double militairyBuildingDistance=aiStatistics.getDistance(point,nearestMilitairyBuildingPosition);
scoredConstructionPositions.add(new ScoredConstructionPosition(point,nearestResourcePointDistance - militairyBuildingDistance));
}
}
}
return ScoredConstructionPosition.detectPositionWithLowestScore(scoredConstructionPositions);
}