nus-yam/ex-repair huggingface dataset:
Program: 55682
Project: 55682
Buggy source:
private void addOrRemoveMarkObject(short buildingPartition,boolean draw,ShortPoint2D pos,float progress){
  if (draw) {
    if (partitionsGrid.getPartitionIdAt(pos.x,pos.y) == buildingPartition) {
      mapObjectsManager.addBuildingWorkAreaObject(pos.x,pos.y,progress);
    }
  }
 else {
    mapObjectsManager.removeMapObjectType(pos.x,pos.y,EMapObjectType.WORKAREA_MARK);
  }
}

Fixed version (ground truth):
private void addOrRemoveMarkObject(short buildingPartition,boolean draw,int x,int y,float progress){
  if (draw) {
    if (partitionsGrid.getPartitionIdAt(x,y) == buildingPartition) {
      mapObjectsManager.addBuildingWorkAreaObject(x,y,progress);
    }
  }
 else {
    mapObjectsManager.removeMapObjectType(x,y,EMapObjectType.WORKAREA_MARK);
  }
}
Program: 55684
Project: 55684
Buggy source:
@Background void positionSelected(int position){
  String item=getItem(position);
  if (item != null) {
    try {
      File newDirectory=new File(currentDirectory,item).getCanonicalFile();
      if (newDirectory.exists()) {
        currentDirectory=newDirectory;
        updateList();
      }
    }
 catch (    IOException e) {
    }
  }
}

Fixed version (ground truth):
void positionSelected(int position){
  String item=getItem(position);
  if (item != null) {
    try {
      File newDirectory=new File(currentDirectory,item).getCanonicalFile();
      if (newDirectory.exists()) {
        currentDirectory=newDirectory;
        updateList();
      }
    }
 catch (    IOException e) {
    }
  }
}
Program: 55685
Project: 55685
Buggy source:
void offer(ShortPoint2D position,EMaterialType materialType,EOfferPriority priority);

Fixed version (ground truth):
void offer(ShortPoint2D position,EMaterialType materialType,EOfferPriority priority,IOfferEmptiedListener offerListener);
Program: 55686
Project: 55686
Buggy source:
protected void deliveryFulFilled(EMaterialType materialType){
  grid.offer(position,materialType,EOfferPriority.LOWEST);
}

Fixed version (ground truth):
protected void deliveryFulFilled(EMaterialType materialType){
  grid.offer(position,materialType,EOfferPriority.LOWEST,this);
}
Program: 55687
Project: 55687
Buggy source:
private void checkIfCurrentMaterialShouldBeReset(){
  if (currentMaterialType != null && materialRequests[currentMaterialType.ordinal].getInDelivery() <= 0 && getStackSize() == 0) {
    sharedData.unregisterHandlingStack(currentMaterialType,this);
    currentMaterialType=null;
  }
}

Fixed version (ground truth):
protected void checkIfCurrentMaterialShouldBeReset(){
  if (currentMaterialType != null && materialRequests[currentMaterialType.ordinal].getInDelivery() <= 0 && getStackSize() == 0) {
    sharedData.unregisterHandlingStack(currentMaterialType,this);
    currentMaterialType=null;
  }
}
Program: 55688
Project: 55688
Buggy source:
@Override public void offer(ShortPoint2D position,EMaterialType materialType,EOfferPriority priority){
  partitionsGrid.getPartitionAt(position.x,position.y).addOffer(position,materialType,priority);
}

Fixed version (ground truth):
@Override public void offer(ShortPoint2D position,EMaterialType materialType,EOfferPriority priority,IOfferEmptiedListener offerListener){
  partitionsGrid.getPartitionAt(position.x,position.y).addOffer(position,materialType,priority,offerListener);
}
Program: 55689
Project: 55689
Buggy source:
public void addOffer(ShortPoint2D position,EMaterialType materialType,EOfferPriority offerPriority){
  materialOffers.addOffer(position,materialType,offerPriority);
}

Fixed version (ground truth):
public void addOffer(ShortPoint2D position,EMaterialType materialType,EOfferPriority offerPriority,IOfferEmptiedListener offerListener){
  materialOffers.addOffer(position,materialType,offerPriority,offerListener);
}
Program: 55690
Project: 55690
Buggy source:
/** 
 * Insert an offered material at the given position.
 * @param position The position the offered material is located.
 * @param material The material that is offered at the given position.
 */
public void addOffer(ShortPoint2D position,EMaterialType material,EOfferPriority offerPriority){
  PrioritizedPositionableList<EOfferPriority,MaterialOffer> list=offersLists[material.ordinal];
  MaterialOffer existingOffer=list.getObjectAt(position,offerPriority);
  if (existingOffer != null) {
    existingOffer.incrementAmount();
  }
 else {
    list.insert(new MaterialOffer(position,material,materialCounts,offerPriority,(byte)1));
  }
}

Fixed version (ground truth):
/** 
 * Insert an offered material at the given position.
 * @param position The position the offered material is located.
 * @param material The material that is offered at the given position.
 * @param offerPriority The priority of the offer
 * @param offerListener A listener that will be set to the offer
 */
public void addOffer(ShortPoint2D position,EMaterialType material,EOfferPriority offerPriority,IOfferEmptiedListener offerListener){
  PrioritizedPositionableList<EOfferPriority,MaterialOffer> list=offersLists[material.ordinal];
  MaterialOffer existingOffer=list.getObjectAt(position,offerPriority);
  if (existingOffer != null && existingOffer instanceof ListenableMaterialOffer) {
    existingOffer.incrementAmount();
  }
 else {
    list.insert(new ListenableMaterialOffer(position,material,materialCounts,offerPriority,(byte)1,offerListener));
  }
}
Program: 55692
Project: 55692
Buggy source:
/** 
 * Creates a new   {@link PartitionCalculatorAlgorithm}. The given   {@link BitSet} defines the positions that need to be in the partitions and theones that mustn't.
 * @param minX The x offset of the  {@link BitSet}.
 * @param minY The y offset of the  {@link BitSet}.
 * @param width The width of the grid defined by the  {@link BitSet}.
 * @param height The height of the grid defined by the  {@link BitSet}.
 * @param containing The  {@link BitSet} defining the positions in the partitions and the ones not. <br>NOTE: The  {@link BitSet} must be indexed with x + y * width
 * @param blockingProvider Provides the information if a position is blocked or not.
 */
public PartitionCalculatorAlgorithm(int minX,int minY,int width,int height,BitSet containing,IBlockingProvider blockingProvider){
  this.minX=minX;
  this.minY=minY;
  this.width=width;
  this.height=height;
  this.containing=containing;
  this.blockingProvider=blockingProvider;
  this.partitionsGrid=new short[width * height];
}

Fixed version (ground truth):
/** 
 * Creates a new   {@link PartitionCalculatorAlgorithm}. The given   {@link BitSet} defines the positions that need to be in the partitions and theones that mustn't.
 * @param minX The x offset of the  {@link BitSet}.
 * @param minY The y offset of the  {@link BitSet}.
 * @param width The width of the grid defined by the  {@link BitSet}.
 * @param height The height of the grid defined by the  {@link BitSet}.
 * @param containing The  {@link BitSet} defining the positions in the partitions and the ones not. <br>NOTE: The  {@link BitSet} must be indexed with x + y * width
 * @param blockingProvider Provides the information if a position is blocked or not.
 */
public PartitionCalculatorAlgorithm(int minX,int minY,int width,int height,BitSet containing,IBlockingProvider blockingProvider){
  this.minX=minX;
  this.minY=minY;
  this.width=width;
  this.height=height;
  this.containing=containing;
  this.blockingProvider=blockingProvider;
  this.partitionsGrid=new short[width * height];
  this.partitions[BLOCKED_PARTITION]=BLOCKED_PARTITION;
}
Program: 55693
Project: 55693
Buggy source:
private void handleJobFailed(boolean reportAsJobless){
switch (state) {
case INIT_CARRY_JOB:
case GOING_TO_OFFER:
    reoffer();
case TAKING:
  if (workerCreationRequest != null) {
    workerRequester.workerCreationRequestFailed(workerCreationRequest);
  }
case GOING_TO_REQUEST:
if (request != null) {
  request.deliveryAborted();
}
break;
case DROPPING:
if (request != null) {
boolean offerMaterial=droppingMaterial();
super.setMaterial(EMaterialType.NO_MATERIAL);
super.getGrid().dropMaterial(super.getPos(),materialType,offerMaterial,false);
}
break;
case INIT_BECOME_SOLDIER_JOB:
case GOING_TO_BARRACK:
barrack.bearerRequestFailed();
break;
case INIT_CONVERT_WITH_TOOL_JOB:
reoffer();
case INIT_CONVERT_JOB:
workerRequester.workerCreationRequestFailed(workerCreationRequest);
break;
case DEAD_OBJECT:
break;
case JOBLESS:
break;
default :
break;
}
EMaterialType carriedMaterial=super.setMaterial(EMaterialType.NO_MATERIAL);
if (carriedMaterial != EMaterialType.NO_MATERIAL) {
super.getGrid().dropMaterial(movable.getPos(),materialType,true,false);
}
offer=null;
request=null;
materialType=null;
workerCreationRequest=null;
workerRequester=null;
state=EBearerState.JOBLESS;
if (reportAsJobless) {
reportJobless();
}
}

Fixed version (ground truth):
private void handleJobFailed(boolean reportAsJobless){
switch (state) {
case INIT_CARRY_JOB:
case GOING_TO_OFFER:
case TAKING:
    if (super.movable.getMaterial() == EMaterialType.NO_MATERIAL) {
      reoffer();
    }
  if (workerCreationRequest != null) {
    workerRequester.workerCreationRequestFailed(workerCreationRequest);
  }
case GOING_TO_REQUEST:
if (request != null) {
  request.deliveryAborted();
}
break;
case DROPPING:
if (request != null) {
boolean offerMaterial=droppingMaterial();
super.setMaterial(EMaterialType.NO_MATERIAL);
super.getGrid().dropMaterial(super.getPos(),materialType,offerMaterial,false);
}
break;
case INIT_BECOME_SOLDIER_JOB:
case GOING_TO_BARRACK:
barrack.bearerRequestFailed();
break;
case INIT_CONVERT_WITH_TOOL_JOB:
reoffer();
case INIT_CONVERT_JOB:
workerRequester.workerCreationRequestFailed(workerCreationRequest);
break;
case DEAD_OBJECT:
break;
case JOBLESS:
break;
default :
break;
}
EMaterialType carriedMaterial=super.setMaterial(EMaterialType.NO_MATERIAL);
if (carriedMaterial != EMaterialType.NO_MATERIAL) {
super.getGrid().dropMaterial(movable.getPos(),materialType,true,false);
}
offer=null;
request=null;
materialType=null;
workerCreationRequest=null;
workerRequester=null;
state=EBearerState.JOBLESS;
if (reportAsJobless) {
reportJobless();
}
}
Program: 55694
Project: 55694
Buggy source:
public CoordinateStream stream(){
  return new CoordinateStream(){
    @Override public boolean iterate(    IBooleanCoordinateFunction function){
      int width=base.getWidth();
      int lastRelativeYWithPoint=0;
      for (int relativeY=0; relativeY < MIN_SEARCH_LINES || relativeY - lastRelativeYWithPoint <= 2; relativeY++) {
        int lineStartX=base.getLineStartX(relativeY);
        for (int relativeX=0; relativeX < width; relativeX++) {
          int x=lineStartX + relativeX;
          int y=base.getLineY(relativeY);
          if (contains(x,y)) {
            lastRelativeYWithPoint=relativeY;
            if (!function.apply(x,y)) {
              return false;
            }
          }
        }
      }
      return true;
    }
  }
;
}

Fixed version (ground truth):
public CoordinateStream stream(){
  return new CoordinateStream(){
    @Override public boolean iterate(    IBooleanCoordinateFunction function){
      int width=base.getWidth();
      int lastRelativeYWithPoint=0;
      for (int relativeY=0; relativeY < MIN_SEARCH_LINES || relativeY - lastRelativeYWithPoint <= 2; relativeY++) {
        int lineStartX=base.getLineStartX(relativeY);
        for (int relativeX=0; relativeX < width; relativeX++) {
          int x=lineStartX + relativeX;
          int y=base.getLineY(relativeY);
          if (HeightedMapRectangle.this.contains(x,y)) {
            lastRelativeYWithPoint=relativeY;
            if (!function.apply(x,y)) {
              return false;
            }
          }
        }
      }
      return true;
    }
  }
;
}
Program: 55695
Project: 55695
Buggy source:
@Override public boolean iterate(IBooleanCoordinateFunction function){
  int width=base.getWidth();
  int lastRelativeYWithPoint=0;
  for (int relativeY=0; relativeY < MIN_SEARCH_LINES || relativeY - lastRelativeYWithPoint <= 2; relativeY++) {
    int lineStartX=base.getLineStartX(relativeY);
    for (int relativeX=0; relativeX < width; relativeX++) {
      int x=lineStartX + relativeX;
      int y=base.getLineY(relativeY);
      if (contains(x,y)) {
        lastRelativeYWithPoint=relativeY;
        if (!function.apply(x,y)) {
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean iterate(IBooleanCoordinateFunction function){
  int width=base.getWidth();
  int lastRelativeYWithPoint=0;
  for (int relativeY=0; relativeY < MIN_SEARCH_LINES || relativeY - lastRelativeYWithPoint <= 2; relativeY++) {
    int lineStartX=base.getLineStartX(relativeY);
    for (int relativeX=0; relativeX < width; relativeX++) {
      int x=lineStartX + relativeX;
      int y=base.getLineY(relativeY);
      if (HeightedMapRectangle.this.contains(x,y)) {
        lastRelativeYWithPoint=relativeY;
        if (!function.apply(x,y)) {
          return false;
        }
      }
    }
  }
  return true;
}
Program: 55696
Project: 55696
Buggy source:
@Override public void releaseRequests(){
  for (  RequestOfMultiRequestStack materialRequest : materialRequests) {
    materialRequest.updatePriority(EPriority.STOPPED);
    grid.updateOfferPriorities(position,materialRequest.materialType,EOfferPriority.OFFER_TO_ALL);
  }
  released=true;
}

Fixed version (ground truth):
@Override public void releaseRequests(){
  for (  RequestOfMultiRequestStack materialRequest : materialRequests) {
    materialRequest.updatePriority(EPriority.STOPPED);
  }
  if (currentMaterialType != null) {
    grid.updateOfferPriorities(position,currentMaterialType,EOfferPriority.OFFER_TO_ALL);
  }
  released=true;
}
Program: 55697
Project: 55697
Buggy source:
public short getStillNeededIfNoOthersHandleIt(EMaterialType materialType){
  Set<MultiRequestStack> stacksHandlingThisMaterial=handlingStacks[materialType.ordinal];
  for (  MultiRequestStack stack : stacksHandlingThisMaterial) {
    if (stack.canAcceptMoreDeliveries()) {
      return 0;
    }
  }
  return getStillNeeded(materialType);
}

Fixed version (ground truth):
public short getStillNeededIfNoOthersHandleIt(EMaterialType materialType){
  Set<MultiRequestStack> stacksHandlingThisMaterial=handlingStacks[materialType.ordinal];
  for (  MultiRequestStack stack : stacksHandlingThisMaterial) {
    if (stack.canAcceptMoreDeliveriesOf(materialType)) {
      return 0;
    }
  }
  return getStillNeeded(materialType);
}
Program: 55698
Project: 55698
Buggy source:
public void insert(P priority,T object){
  lists[priority.ordinal()].insert(object);
}

Fixed version (ground truth):
public void insert(T object){
  lists[object.getPriority().ordinal()].insert(object);
}
Program: 55699
Project: 55699
Buggy source:
public void updatePriorityAt(ShortPoint2D position,P newPriority){
  int newPriorityIndex=newPriority.ordinal();
  for (int i=0; i < lists.length; i++) {
    if (i != newPriorityIndex) {
      T foundObject=lists[i].removeObjectAt(position);
      if (foundObject != null) {
        lists[newPriorityIndex].insert(foundObject);
      }
    }
  }
}

Fixed version (ground truth):
public void updatePriorityAt(ShortPoint2D position,P newPriority){
  int newPriorityIndex=newPriority.ordinal();
  for (int i=0; i < lists.length; i++) {
    if (i != newPriorityIndex) {
      T foundObject=lists[i].removeObjectAt(position);
      if (foundObject != null) {
        foundObject.updatePriority(newPriority);
        lists[newPriorityIndex].insert(foundObject);
      }
    }
  }
}
Program: 55700
Project: 55700
Buggy source:
public void remove(T offer){
  for (int i=lists.length - 1; i >= 0; i--) {
    lists[i].remove(offer);
  }
}

Fixed version (ground truth):
public void remove(T offer){
  lists[offer.getPriority().ordinal()].remove(offer);
}
Program: 55701
Project: 55701
Buggy source:
public EOfferPriority getPriority(){
  return priority;
}

Fixed version (ground truth):
@Override public EOfferPriority getPriority(){
  return priority;
}
Program: 55702
Project: 55702
Buggy source:
/** 
 * @param materialType {@link EMaterialType} of the offer.
 * @param position     The position to be used for the search.
 * @return Returns an offer of the given {@link EMaterialType} that's close to the given position or <br>null if no offer for the given  {@link EMaterialType} exists.
 */
public MaterialOffer removeOfferCloseTo(EMaterialType materialType,EOfferPriority minimumIncludedPriority,ShortPoint2D position){
  PrioritizedPositionableList<EOfferPriority,MaterialOffer> offerSlot=offersLists[materialType.ordinal];
  MaterialOffer offer=offerSlot.getObjectCloseTo(position,minimumIncludedPriority);
  decrementOfferAmount(offerSlot,materialType,offer);
  return offer;
}

Fixed version (ground truth):
/** 
 * @param materialType {@link EMaterialType} of the offer.
 * @param position The position to be used for the search.
 * @return Returns an offer of the given {@link EMaterialType} that's close to the given position or <br>null if no offer for the given  {@link EMaterialType} exists.
 */
public MaterialOffer removeOfferCloseTo(EMaterialType materialType,EOfferPriority minimumIncludedPriority,ShortPoint2D position){
  PrioritizedPositionableList<EOfferPriority,MaterialOffer> offerSlot=offersLists[materialType.ordinal];
  MaterialOffer offer=offerSlot.getObjectCloseTo(position,minimumIncludedPriority);
  decrementOfferAmount(offerSlot,materialType,offer);
  return offer;
}
Program: 55703
Project: 55703
Buggy source:
/** 
 * Insert an offered material at the given position.
 * @param position The position the offered material is located.
 * @param material The material that is offered at the given position.
 */
public void addOffer(ShortPoint2D position,EMaterialType material,EOfferPriority offerPriority){
  PrioritizedPositionableList<EOfferPriority,MaterialOffer> list=offersLists[material.ordinal];
  MaterialOffer existingOffer=list.getObjectAt(position,offerPriority);
  if (existingOffer != null) {
    existingOffer.incAmount();
  }
 else {
    list.insert(offerPriority,new MaterialOffer(position,offerPriority,(byte)1));
  }
  numberOfOffers[material.ordinal]++;
  countListener.offersCountChanged(material,+1);
}

Fixed version (ground truth):
/** 
 * Insert an offered material at the given position.
 * @param position The position the offered material is located.
 * @param material The material that is offered at the given position.
 */
public void addOffer(ShortPoint2D position,EMaterialType material,EOfferPriority offerPriority){
  PrioritizedPositionableList<EOfferPriority,MaterialOffer> list=offersLists[material.ordinal];
  MaterialOffer existingOffer=list.getObjectAt(position,offerPriority);
  if (existingOffer != null) {
    existingOffer.incAmount();
  }
 else {
    list.insert(new MaterialOffer(position,offerPriority,(byte)1));
  }
  numberOfOffers[material.ordinal]++;
  countListener.offersCountChanged(material,+1);
}
Program: 55704
Project: 55704
Buggy source:
/** 
 * Checks if there are any offers for the given   {@link EMaterialType}.
 * @param materialType The {@link EMaterialType} to be checked.
 * @param minimumIncludedPriority The lowest priority to be included in
 * @return Returns true if there are no offers for the given {@link EMaterialType},<br> false otherwise.
 */
public boolean isEmpty(EMaterialType materialType,EOfferPriority minimumIncludedPriority){
  return offersLists[materialType.ordinal].isEmpty(minimumIncludedPriority);
}

Fixed version (ground truth):
/** 
 * Checks if there are any offers for the given   {@link EMaterialType}.
 * @param materialType The  {@link EMaterialType} to be checked.
 * @param minimumIncludedPriority The lowest priority to be included in
 * @return Returns true if there are no offers for the given {@link EMaterialType},<br> false otherwise.
 */
public boolean isEmpty(EMaterialType materialType,EOfferPriority minimumIncludedPriority){
  return offersLists[materialType.ordinal].isEmpty(minimumIncludedPriority);
}
Program: 55705
Project: 55705
Buggy source:
private BitSet calculatePositionsInDistanceTrivial(int width,int height,IBooleanCoordinateValueProvider provider,int maxDistance){
  BitSet inDistance=new BitSet();
  for (int x=0; x < width; x++) {
    for (int y=0; y < height; y++) {
      if (provider.getValue(x,y)) {
        HexGridArea.iterate(x,y,0,maxDistance,VisitorConsumerUtils.filterBounds(width,height,(currX,currY,radius) -> {
          inDistance.set(currY * width + currX);
          return null;
        }
));
      }
    }
  }
  return inDistance;
}

Fixed version (ground truth):
private BitSet calculatePositionsInDistanceTrivial(int width,int height,IBooleanCoordinateValueProvider provider,int maxDistance){
  BitSet inDistance=new BitSet();
  for (int x=0; x < width; x++) {
    for (int y=0; y < height; y++) {
      if (provider.getValue(x,y)) {
        HexGridArea.iterate(x,y,0,maxDistance,VisitorConsumerUtils.filterBounds(width,height,(currX,currY,radius) -> {
          inDistance.set(currY * width + currX);
          return Optional.empty();
        }
));
      }
    }
  }
  return inDistance;
}
Program: 55706
Project: 55706
Buggy source:
public static final void checkLandmark(IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D startPos){
  final short startX=startPos.x;
  final short startY=startPos.y;
  if (grid.isBlocked(startX,startY)) {
    return;
  }
  short startPartition=grid.getPartitionAt(startPos.x,startPos.y);
  for (  EDirection currDir : EDirection.VALUES) {
    ShortPoint2D currPos=currDir.getNextHexPoint(startX,startY);
    if (grid.isBlocked(currPos.x,currPos.y)) {
      if (needsRelabel(grid,containingProvider,currPos,startPartition)) {
        relabel(grid,containingProvider,currPos,startPartition);
      }
    }
  }
}

Fixed version (ground truth):
public static final void checkLandmark(IEnclosedBlockedAreaFinderGrid grid,ShortPoint2D startPos){
  final short startX=startPos.x;
  final short startY=startPos.y;
  if (grid.isPioneerBlocked(startX,startY)) {
    return;
  }
  final IContainingProvider containingProvider=grid::isPioneerBlocked;
  final short startPartition=grid.getPartitionAt(startPos.x,startPos.y);
  for (  EDirection currDir : EDirection.VALUES) {
    ShortPoint2D currPos=currDir.getNextHexPoint(startX,startY);
    if (grid.isPioneerBlocked(currPos.x,currPos.y)) {
      if (needsRelabel(grid,containingProvider,currPos,startPartition)) {
        relabel(grid,containingProvider,currPos,startPartition);
      }
    }
  }
}
Program: 55707
Project: 55707
Buggy source:
/** 
 * Checks if the blocked partition given by the coordinates blockedX and blockedY is surrounded by the given partition.
 * @param grid
 * @param containingProvider
 * @param blockedStartPos
 * @return
 */
private static boolean needsRelabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short partition){
  return BorderTraversingAlgorithm.traverseBorder(containingProvider,blockedStartPos,new IBorderVisitor(){
    @Override public boolean visit(    int insideX,    int insideY,    int outsideX,    int outsideY){
      return grid.getPartitionAt((short)outsideX,(short)outsideY) == partition;
    }
  }
,true);
}

Fixed version (ground truth):
/** 
 * Checks if the blocked partition given by the coordinates blockedX and blockedY is surrounded by the given partition.
 * @param grid
 * @param containingProvider
 * @param blockedStartPos
 * @return
 */
private static boolean needsRelabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short partition){
  return BorderTraversingAlgorithm.traverseBorder(containingProvider,blockedStartPos,(insideX,insideY,outsideX,outsideY) -> grid.getPartitionAt((short)outsideX,(short)outsideY) == partition,true);
}
Program: 55708
Project: 55708
Buggy source:
private static void relabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short newPartition){
  IAreaVisitor visitor=new IAreaVisitor(){
    @Override public boolean visit(    int x,    int y){
      grid.setPartitionAt(x,y,newPartition);
      return true;
    }
  }
;
  AreaTraversingAlgorithm.traverseArea(containingProvider,visitor,blockedStartPos,grid.getWidth(),grid.getHeight());
}

Fixed version (ground truth):
private static void relabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short newPartition){
  IAreaVisitor visitor=(x,y) -> {
    grid.setPartitionAt(x,y,newPartition);
    return true;
  }
;
  AreaTraversingAlgorithm.traverseArea(containingProvider,visitor,blockedStartPos,grid.getWidth(),grid.getHeight());
}
Program: 55709
Project: 55709
Buggy source:
final void checkPositionThatChangedPlayer(ShortPoint2D position){
  if (!isInBounds(position.x,position.y)) {
    return;
  }
  EnclosedBlockedAreaFinderAlgorithm.checkLandmark(enclosedBlockedAreaFinderGrid,flagsGrid.getBlockedContainingProvider(),position);
  Movable movable=movableGrid.getMovableAt(position.x,position.y);
  if (movable != null) {
    movable.checkPlayerOfPosition(partitionsGrid.getPlayerAt(position.x,position.y));
  }
}

Fixed version (ground truth):
final void checkPositionThatChangedPlayer(ShortPoint2D position){
  if (!isInBounds(position.x,position.y)) {
    return;
  }
  EnclosedBlockedAreaFinderAlgorithm.checkLandmark(enclosedBlockedAreaFinderGrid,position);
  Movable movable=movableGrid.getMovableAt(position.x,position.y);
  if (movable != null) {
    movable.checkPlayerOfPosition(partitionsGrid.getPlayerAt(position.x,position.y));
  }
}
Program: 55710
Project: 55710
Buggy source:
public FlagsGrid(final short width,final short height){
  this.width=width;
  this.blockedGrid=new BitSet(width * height);
  this.protectedGrid=new BitSet(width * height);
  this.markedGrid=new BitSet(width * height);
  initAdditional();
}

Fixed version (ground truth):
public FlagsGrid(final short width,final short height){
  this.width=width;
  this.blockedGrid=new BitSet(width * height);
  this.protectedGrid=new BitSet(width * height);
  this.markedGrid=new BitSet(width * height);
}
Program: 55711
Project: 55711
Buggy source:
@Test public void veryHardShouldProduceCertainAmountOfSoldiersWithin85Minutes() throws MapLoadException {
  PlayerSetting[] playerSettings=getDefaultPlayerSettings(12);
  playerSettings[0]=new PlayerSetting(EPlayerType.AI_VERY_HARD,ECivilisation.ROMAN,(byte)0);
  JSettlersGame.GameRunner startingGame=createStartingGame(playerSettings);
  IStartedGame startedGame=ReplayUtils.waitForGameStartup(startingGame);
  MatchConstants.clock().fastForwardTo(85 * MINUTES);
  ReplayUtils.awaitShutdown(startedGame);
  short expectedMinimalProducedSoldiers=1000;
  short producedSoldiers=startingGame.getMainGrid().getPartitionsGrid().getPlayer(0).getEndgameStatistic().getAmountOfProducedSoldiers();
  if (producedSoldiers < expectedMinimalProducedSoldiers) {
    fail("String_Node_Str" + expectedMinimalProducedSoldiers + "String_Node_Str"+ producedSoldiers+ "String_Node_Str"+ "String_Node_Str");
  }
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getApplyRulesStopWatch(),200,2500);
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getUpdateStatisticsStopWatch(),100,2500);
}

Fixed version (ground truth):
@Test public void veryHardShouldProduceCertainAmountOfSoldiersWithin85Minutes() throws MapLoadException {
  PlayerSetting[] playerSettings=getDefaultPlayerSettings(12);
  playerSettings[0]=new PlayerSetting(EPlayerType.AI_VERY_HARD,ECivilisation.ROMAN,(byte)0);
  JSettlersGame.GameRunner startingGame=createStartingGame(playerSettings);
  IStartedGame startedGame=ReplayUtils.waitForGameStartup(startingGame);
  MatchConstants.clock().fastForwardTo(86 * MINUTES);
  ReplayUtils.awaitShutdown(startedGame);
  short expectedMinimalProducedSoldiers=1000;
  short producedSoldiers=startingGame.getMainGrid().getPartitionsGrid().getPlayer(0).getEndgameStatistic().getAmountOfProducedSoldiers();
  if (producedSoldiers < expectedMinimalProducedSoldiers) {
    fail("String_Node_Str" + expectedMinimalProducedSoldiers + "String_Node_Str"+ producedSoldiers+ "String_Node_Str"+ "String_Node_Str");
  }
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getApplyRulesStopWatch(),200,2500);
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getUpdateStatisticsStopWatch(),100,2500);
}
Program: 55712
Project: 55712
Buggy source:
public static final void checkLandmark(IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D startPos){
  final short startX=startPos.x;
  final short startY=startPos.y;
  if (grid.isBlocked(startX,startY)) {
    return;
  }
  short startPartition=grid.getPartitionAt(startPos.x,startPos.y);
  for (  EDirection currDir : EDirection.VALUES) {
    ShortPoint2D currPos=currDir.getNextHexPoint(startX,startY);
    if (grid.isBlocked(currPos.x,currPos.y)) {
      if (needsRelabel(grid,containingProvider,currPos,startPartition)) {
        relabel(grid,containingProvider,currPos,startPartition);
      }
    }
  }
}

Fixed version (ground truth):
public static final void checkLandmark(IEnclosedBlockedAreaFinderGrid grid,ShortPoint2D startPos){
  final short startX=startPos.x;
  final short startY=startPos.y;
  if (grid.isPioneerBlocked(startX,startY)) {
    return;
  }
  final IContainingProvider containingProvider=grid::isPioneerBlocked;
  final short startPartition=grid.getPartitionAt(startPos.x,startPos.y);
  for (  EDirection currDir : EDirection.VALUES) {
    ShortPoint2D currPos=currDir.getNextHexPoint(startX,startY);
    if (grid.isPioneerBlocked(currPos.x,currPos.y)) {
      if (needsRelabel(grid,containingProvider,currPos,startPartition)) {
        relabel(grid,containingProvider,currPos,startPartition);
      }
    }
  }
}
Program: 55713
Project: 55713
Buggy source:
/** 
 * Checks if the blocked partition given by the coordinates blockedX and blockedY is surrounded by the given partition.
 * @param grid
 * @param containingProvider
 * @param blockedStartPos
 * @return
 */
private static boolean needsRelabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short partition){
  return BorderTraversingAlgorithm.traverseBorder(containingProvider,blockedStartPos,new IBorderVisitor(){
    @Override public boolean visit(    int insideX,    int insideY,    int outsideX,    int outsideY){
      return grid.getPartitionAt((short)outsideX,(short)outsideY) == partition;
    }
  }
,true);
}

Fixed version (ground truth):
/** 
 * Checks if the blocked partition given by the coordinates blockedX and blockedY is surrounded by the given partition.
 * @param grid
 * @param containingProvider
 * @param blockedStartPos
 * @return
 */
private static boolean needsRelabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short partition){
  return BorderTraversingAlgorithm.traverseBorder(containingProvider,blockedStartPos,(insideX,insideY,outsideX,outsideY) -> grid.getPartitionAt((short)outsideX,(short)outsideY) == partition,true);
}
Program: 55714
Project: 55714
Buggy source:
private static void relabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short newPartition){
  IAreaVisitor visitor=new IAreaVisitor(){
    @Override public boolean visit(    int x,    int y){
      grid.setPartitionAt(x,y,newPartition);
      return true;
    }
  }
;
  AreaTraversingAlgorithm.traverseArea(containingProvider,visitor,blockedStartPos,grid.getWidth(),grid.getHeight());
}

Fixed version (ground truth):
private static void relabel(final IEnclosedBlockedAreaFinderGrid grid,IContainingProvider containingProvider,ShortPoint2D blockedStartPos,final short newPartition){
  IAreaVisitor visitor=(x,y) -> {
    grid.setPartitionAt(x,y,newPartition);
    return true;
  }
;
  AreaTraversingAlgorithm.traverseArea(containingProvider,visitor,blockedStartPos,grid.getWidth(),grid.getHeight());
}
Program: 55715
Project: 55715
Buggy source:
final void checkPositionThatChangedPlayer(ShortPoint2D position){
  if (!isInBounds(position.x,position.y)) {
    return;
  }
  EnclosedBlockedAreaFinderAlgorithm.checkLandmark(enclosedBlockedAreaFinderGrid,flagsGrid.getBlockedContainingProvider(),position);
  Movable movable=movableGrid.getMovableAt(position.x,position.y);
  if (movable != null) {
    movable.checkPlayerOfPosition(partitionsGrid.getPlayerAt(position.x,position.y));
  }
}

Fixed version (ground truth):
final void checkPositionThatChangedPlayer(ShortPoint2D position){
  if (!isInBounds(position.x,position.y)) {
    return;
  }
  EnclosedBlockedAreaFinderAlgorithm.checkLandmark(enclosedBlockedAreaFinderGrid,position);
  Movable movable=movableGrid.getMovableAt(position.x,position.y);
  if (movable != null) {
    movable.checkPlayerOfPosition(partitionsGrid.getPlayerAt(position.x,position.y));
  }
}
Program: 55716
Project: 55716
Buggy source:
public FlagsGrid(final short width,final short height){
  this.width=width;
  this.blockedGrid=new BitSet(width * height);
  this.protectedGrid=new BitSet(width * height);
  this.markedGrid=new BitSet(width * height);
  initAdditional();
}

Fixed version (ground truth):
public FlagsGrid(final short width,final short height){
  this.width=width;
  this.blockedGrid=new BitSet(width * height);
  this.protectedGrid=new BitSet(width * height);
  this.markedGrid=new BitSet(width * height);
}
Program: 55717
Project: 55717
Buggy source:
@Test public void veryHardShouldProduceCertainAmountOfSoldiersWithin85Minutes() throws MapLoadException {
  PlayerSetting[] playerSettings=getDefaultPlayerSettings(12);
  playerSettings[0]=new PlayerSetting(EPlayerType.AI_VERY_HARD,ECivilisation.ROMAN,(byte)0);
  JSettlersGame.GameRunner startingGame=createStartingGame(playerSettings);
  IStartedGame startedGame=ReplayUtils.waitForGameStartup(startingGame);
  MatchConstants.clock().fastForwardTo(85 * MINUTES);
  ReplayUtils.awaitShutdown(startedGame);
  short expectedMinimalProducedSoldiers=1000;
  short producedSoldiers=startingGame.getMainGrid().getPartitionsGrid().getPlayer(0).getEndgameStatistic().getAmountOfProducedSoldiers();
  if (producedSoldiers < expectedMinimalProducedSoldiers) {
    fail("String_Node_Str" + expectedMinimalProducedSoldiers + "String_Node_Str"+ producedSoldiers+ "String_Node_Str"+ "String_Node_Str");
  }
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getApplyRulesStopWatch(),200,2500);
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getUpdateStatisticsStopWatch(),100,2500);
}

Fixed version (ground truth):
@Test public void veryHardShouldProduceCertainAmountOfSoldiersWithin85Minutes() throws MapLoadException {
  PlayerSetting[] playerSettings=getDefaultPlayerSettings(12);
  playerSettings[0]=new PlayerSetting(EPlayerType.AI_VERY_HARD,ECivilisation.ROMAN,(byte)0);
  JSettlersGame.GameRunner startingGame=createStartingGame(playerSettings);
  IStartedGame startedGame=ReplayUtils.waitForGameStartup(startingGame);
  MatchConstants.clock().fastForwardTo(86 * MINUTES);
  ReplayUtils.awaitShutdown(startedGame);
  short expectedMinimalProducedSoldiers=1000;
  short producedSoldiers=startingGame.getMainGrid().getPartitionsGrid().getPlayer(0).getEndgameStatistic().getAmountOfProducedSoldiers();
  if (producedSoldiers < expectedMinimalProducedSoldiers) {
    fail("String_Node_Str" + expectedMinimalProducedSoldiers + "String_Node_Str"+ producedSoldiers+ "String_Node_Str"+ "String_Node_Str");
  }
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getApplyRulesStopWatch(),200,2500);
  ensureRuntimePerformance("String_Node_Str",startingGame.getAiExecutor().getUpdateStatisticsStopWatch(),100,2500);
}
Program: 55718
Project: 55718
Buggy source:
public void endTask(){
  if (taskAction != null) {
switch (taskAction.getActionType()) {
case SHOW_CONSTRUCTION_MARK:
      actionFireable.fireAction(new ShowConstructionMarksAction(null));
  }
  taskAction=null;
}
}

Fixed version (ground truth):
public void endTask(){
  if (taskAction != null) {
switch (taskAction.getActionType()) {
case SHOW_CONSTRUCTION_MARK:
      actionFireable.fireAction(new ShowConstructionMarksAction(null));
    break;
case MOVE_TO:
  break;
}
taskAction=null;
}
}
Program: 55719
Project: 55719
Buggy source:
public void progressChanged(String status,int progress){
  statusTextView.setText(status);
  progressBar.setProgress(progress);
}

Fixed version (ground truth):
public void progressChanged(String status,int progress){
  this.status=status;
  this.progress=progress;
  if (this.getView() != null) {
    setProgress();
  }
}
Program: 55720
Project: 55720
Buggy source:
@Override public void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  gameStarter=(GameStarter)getActivity();
  map=gameStarter.getSelectedMap();
}

Fixed version (ground truth):
@Override public void onCreate(@Nullable Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
}
Program: 55721
Project: 55721
Buggy source:
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_new_single_player,container,false);
  FragmentUtil.setActionBar(this,view);
  TextView textViewName=(TextView)view.findViewById(R.id.text_view_name);
  textViewName.setText(map.getMapName());
  Button startGameButton=(Button)view.findViewById(R.id.button_start_game);
  startGameButton.setOnClickListener(startGameClickListener);
  return view;
}

Fixed version (ground truth):
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View view=inflater.inflate(R.layout.fragment_new_single_player,container,false);
  FragmentUtil.setActionBar(this,view);
  Button startGameButton=(Button)view.findViewById(R.id.button_start_game);
  startGameButton.setOnClickListener(startGameClickListener);
  return view;
}
Program: 55722
Project: 55722
Buggy source:
private ShortPoint2D getNearestPointInDefaultPartitionOutOfSortedMap(ShortPoint2D point,AiPositions sortedPoints,final byte playerId,int searchDistance){
  return sortedPoints.getNearestPoint(point,searchDistance,new AiPositionFilter(){
    @Override public boolean contains(    int x,    int y){
      return partitionsGrid.getPartitionAt(x,y).getPlayerId() == playerId;
    }
  }
);
}

Fixed version (ground truth):
private ShortPoint2D getNearestPointInDefaultPartitionOutOfSortedMap(ShortPoint2D point,AiPositions sortedPoints,final byte playerId,int searchDistance,final AiPositionFilter filter){
  return sortedPoints.getNearestPoint(point,searchDistance,new AiPositionFilter(){
    @Override public boolean contains(    int x,    int y){
      return partitionsGrid.getPartitionAt(x,y).getPlayerId() == playerId && (filter == null || filter.contains(x,y));
    }
  }
);
}
Program: 55723
Project: 55723
Buggy source:
public ShortPoint2D getNearestRiverPointInDefaultPartitionFor(ShortPoint2D referencePoint,int searchDistance){
  return getNearestPointInDefaultPartitionOutOfSortedMap(referencePoint,sortedRiversInDefaultPartition,(byte)-1,searchDistance);
}

Fixed version (ground truth):
public ShortPoint2D getNearestRiverPointInDefaultPartitionFor(ShortPoint2D referencePoint,int searchDistance){
  return getNearestPointInDefaultPartitionOutOfSortedMap(referencePoint,sortedRiversInDefaultPartition,(byte)-1,searchDistance,null);
}
Program: 55724
Project: 55724
Buggy source:
@Override public boolean contains(int x,int y){
  return partitionsGrid.getPartitionAt(x,y).getPlayerId() == playerId;
}

Fixed version (ground truth):
@Override public boolean contains(int x,int y){
  return partitionsGrid.getPartitionAt(x,y).getPlayerId() == playerId && (filter == null || filter.contains(x,y));
}
Program: 55725
Project: 55725
Buggy source:
public ShortPoint2D getNearestCuttableObjectPointForPlayer(ShortPoint2D point,EMapObjectType cuttableObject,int searchDistance,byte playerId){
  AiPositions sortedResourcePoints=sortedCuttableObjectsInDefaultPartition.get(cuttableObject);
  if (sortedResourcePoints == null) {
    return null;
  }
  return getNearestPointInDefaultPartitionOutOfSortedMap(point,sortedResourcePoints,playerId,searchDistance);
}

Fixed version (ground truth):
public ShortPoint2D getNearestCuttableObjectPointForPlayer(ShortPoint2D point,EMapObjectType cuttableObject,int searchDistance,byte playerId){
  AiPositions sortedResourcePoints=sortedCuttableObjectsInDefaultPartition.get(cuttableObject);
  if (sortedResourcePoints == null) {
    return null;
  }
  return getNearestPointInDefaultPartitionOutOfSortedMap(point,sortedResourcePoints,playerId,searchDistance,null);
}
Program: 55726
Project: 55726
Buggy source:
public ShortPoint2D getNearestResourcePointForPlayer(ShortPoint2D point,EResourceType resourceType,byte playerId,int searchDistance){
  return getNearestPointInDefaultPartitionOutOfSortedMap(point,sortedResourceTypes[resourceType.ordinal],playerId,searchDistance);
}

Fixed version (ground truth):
public ShortPoint2D getNearestResourcePointForPlayer(ShortPoint2D point,EResourceType resourceType,byte playerId,int searchDistance,AiPositionFilter filter){
  return getNearestPointInDefaultPartitionOutOfSortedMap(point,sortedResourceTypes[resourceType.ordinal],playerId,searchDistance,filter);
}
Program: 55727
Project: 55727
Buggy source:
public ShortPoint2D getNearestResourcePointInDefaultPartitionFor(ShortPoint2D point,EResourceType resourceType,int currentNearestPointDistance){
  return getNearestResourcePointForPlayer(point,resourceType,(byte)-1,currentNearestPointDistance);
}

Fixed version (ground truth):
public ShortPoint2D getNearestResourcePointInDefaultPartitionFor(ShortPoint2D point,EResourceType resourceType,int currentNearestPointDistance,AiPositionFilter filter){
  return getNearestResourcePointForPlayer(point,resourceType,(byte)-1,currentNearestPointDistance,filter);
}
Program: 55728
Project: 55728
Buggy source:
private void sendGeologistToNearest(Movable geologist,EResourceType resourceType){
  ShortPoint2D resourcePoint=aiStatistics.getNearestResourcePointForPlayer(aiStatistics.getPositionOfPartition(playerId),resourceType,playerId,Integer.MAX_VALUE);
  if (resourcePoint == null) {
    resourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(aiStatistics.getPositionOfPartition(playerId),resourceType,Integer.MAX_VALUE);
  }
  if (resourcePoint != null) {
    sendMovableTo(geologist,resourcePoint);
  }
}

Fixed version (ground truth):
private void sendGeologistToNearest(Movable geologist,EResourceType resourceType){
  ShortPoint2D resourcePoint=aiStatistics.getNearestResourcePointForPlayer(aiStatistics.getPositionOfPartition(playerId),resourceType,playerId,Integer.MAX_VALUE,geologistFilters[resourceType.ordinal]);
  if (resourcePoint == null) {
    resourcePoint=aiStatistics.getNearestResourcePointInDefaultPartitionFor(aiStatistics.getPositionOfPartition(playerId),resourceType,Integer.MAX_VALUE,geologistFilters[resourceType.ordinal]);
  }
  if (resourcePoint != null) {
    sendMovableTo(geologist,resourcePoint);
  }
}
Program: 55729
Project: 55729
Buggy source:
public WhatToDoAi(byte playerId,AiStatistics aiStatistics,EconomyMinister economyMinister,ArmyGeneral armyGeneral,MainGrid mainGrid,ITaskScheduler taskScheduler){
  this.playerId=playerId;
  this.mainGrid=mainGrid;
  this.taskScheduler=taskScheduler;
  this.aiStatistics=aiStatistics;
  this.armyGeneral=armyGeneral;
  this.economyMinister=economyMinister;
  this.pioneerAi=new PioneerAi(aiStatistics,playerId);
  bestConstructionPositionFinderFactory=new BestConstructionPositionFinderFactory();
  resourcePioneers=new PioneerGroup(RESOURCE_PIONEER_GROUP_COUNT);
  broadenerPioneers=new PioneerGroup(BROADEN_PIONEER_GROUP_COUNT);
}

Fixed version (ground truth):
public WhatToDoAi(byte playerId,AiStatistics aiStatistics,EconomyMinister economyMinister,ArmyGeneral armyGeneral,MainGrid mainGrid,ITaskScheduler taskScheduler){
  this.playerId=playerId;
  this.mainGrid=mainGrid;
  this.taskScheduler=taskScheduler;
  this.aiStatistics=aiStatistics;
  this.armyGeneral=armyGeneral;
  this.economyMinister=economyMinister;
  this.pioneerAi=new PioneerAi(aiStatistics,playerId);
  bestConstructionPositionFinderFactory=new BestConstructionPositionFinderFactory();
  resourcePioneers=new PioneerGroup(RESOURCE_PIONEER_GROUP_COUNT);
  broadenerPioneers=new PioneerGroup(BROADEN_PIONEER_GROUP_COUNT);
  for (  EResourceType resourceType : EResourceType.VALUES) {
    geologistFilters[resourceType.ordinal]=new SurroundedByResourcesFilter(mainGrid,mainGrid.getLandscapeGrid(),resourceType);
  }
}
Program: 55730
Project: 55730
Buggy source:
@Override public ShortPoint2D findTarget(AiPositions playerBorder,ShortPoint2D center){
  if (aiStatistics.resourceCountInDefaultPartition(resourceType) == 0)   return null;
  int factor=aiStatistics.getTotalNumberOfBuildingTypeForPlayer(mineBuildingType,playerId) + 1;
  int tiles=mineBuildingType.getProtectedTiles().length * 2;
  if (aiStatistics.resourceCountOfPlayer(resourceType,playerId) > tiles * factor)   return null;
  ShortPoint2D nearestResourceAbroad=aiStatistics.getNearestResourcePointInDefaultPartitionFor(center,resourceType,searchDistance);
  if (nearestResourceAbroad == null)   return null;
  ShortPoint2D target=playerBorder.getNearestPoint(nearestResourceAbroad,searchDistance);
  return target;
}

Fixed version (ground truth):
@Override public ShortPoint2D findTarget(AiPositions playerBorder,ShortPoint2D center){
  if (aiStatistics.resourceCountInDefaultPartition(resourceType) == 0)   return null;
  int factor=aiStatistics.getTotalNumberOfBuildingTypeForPlayer(mineBuildingType,playerId) + 1;
  int tiles=mineBuildingType.getProtectedTiles().length * 2;
  if (aiStatistics.resourceCountOfPlayer(resourceType,playerId) > tiles * factor)   return null;
  ShortPoint2D nearestResourceAbroad=aiStatistics.getNearestResourcePointInDefaultPartitionFor(center,resourceType,searchDistance,sourroundedByResourceFilter);
  if (nearestResourceAbroad == null)   return null;
  return playerBorder.getNearestPoint(nearestResourceAbroad,searchDistance);
}
Program: 55731
Project: 55731
Buggy source:
public MineTargetFinder(AiStatistics aiStatistics,byte playerId,int searchDistance,EResourceType resourceType,EBuildingType mineBuildingType){
  super(aiStatistics,playerId,searchDistance);
  this.resourceType=resourceType;
  this.mineBuildingType=mineBuildingType;
}

Fixed version (ground truth):
public MineTargetFinder(final AiStatistics aiStatistics,final byte playerId,final int searchDistance,final EResourceType resourceType,final EBuildingType mineBuildingType){
  super(aiStatistics,playerId,searchDistance);
  this.resourceType=resourceType;
  this.mineBuildingType=mineBuildingType;
  sourroundedByResourceFilter=new SurroundedByResourcesFilter(aiStatistics.getMainGrid(),aiStatistics.getMainGrid().getLandscapeGrid(),resourceType);
}
Program: 55732
Project: 55732
Buggy source:
public static PlayerSetting readFromStream(DataInputStream dis) throws IOException {
  dis.readShort();
  boolean available=dis.readBoolean();
  if (available) {
    byte readTeamId=dis.readByte();
    Byte teamId=readTeamId == -1 ? null : readTeamId;
    String civilizationName=dis.readUTF();
    ECivilisation civilisation=civilizationName.isEmpty() ? null : ECivilisation.valueOf(civilizationName);
    String playerTypeName=dis.readUTF();
    EPlayerType playerType=playerTypeName.isEmpty() ? null : EPlayerType.valueOf(playerTypeName);
    return new PlayerSetting(playerType,civilisation,teamId);
  }
 else {
    return new PlayerSetting();
  }
}

Fixed version (ground truth):
public static PlayerSetting readFromStream(DataInputStream dis) throws IOException {
  dis.readShort();
  boolean available=dis.readBoolean();
  if (available) {
    byte readTeamId=dis.readByte();
    Byte teamId=readTeamId == -1 ? null : readTeamId;
    String civilizationName=dis.readUTF();
    ECivilisation civilisation=civilizationName.isEmpty() ? null : ECivilisation.valueOf(civilizationName);
    String playerTypeName=dis.readUTF();
    EPlayerType playerType=playerTypeName.isEmpty() ? null : EPlayerType.valueOf(playerTypeName);
    return new PlayerSetting(true,playerType,civilisation,teamId);
  }
 else {
    return new PlayerSetting();
  }
}