nus-yam/ex-repair huggingface dataset:
Program: 55983
Project: 55983
Buggy source:
private boolean tryToCreateWorker(IWorkerCreationRequest workerCreationRequest){
  EMovableType movableType=workerCreationRequest.requestedMovableType();
  EMaterialType tool=movableType.getTool();
  if (tool != EMaterialType.NO_MATERIAL) {
    MaterialOffer offer=this.materialOffers.removeOfferCloseTo(tool,workerCreationRequest.getPos());
    if (offer != null) {
      IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(offer.getPos());
      if (manageableBearer != null) {
        manageableBearer.becomeWorker(this,workerCreationRequest,offer.getPos());
        return true;
      }
 else {
        materialOffers.addOffer(offer.getPos(),tool);
        return false;
      }
    }
 else {
      return false;
    }
  }
 else {
    IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(workerCreationRequest.getPos());
    if (manageableBearer != null) {
      manageableBearer.becomeWorker(this,workerCreationRequest);
      return true;
    }
 else {
      return false;
    }
  }
}

Fixed version (ground truth):
private boolean tryToCreateWorker(WorkerCreationRequest workerCreationRequest){
  EMovableType movableType=workerCreationRequest.requestedMovableType();
  EMaterialType tool=movableType.getTool();
  if (tool != EMaterialType.NO_MATERIAL) {
    MaterialOffer offer=this.materialOffers.removeOfferCloseTo(tool,workerCreationRequest.getPos());
    if (offer != null) {
      IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(offer.getPos());
      if (manageableBearer != null) {
        manageableBearer.becomeWorker(this,workerCreationRequest,offer.getPos());
        return true;
      }
 else {
        materialOffers.addOffer(offer.getPos(),tool);
        return false;
      }
    }
 else {
      workerCreationRequest.setToolProductionRequired(true);
      return false;
    }
  }
 else {
    IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(workerCreationRequest.getPos());
    if (manageableBearer != null) {
      manageableBearer.becomeWorker(this,workerCreationRequest);
      return true;
    }
 else {
      return false;
    }
  }
}
Program: 55984
Project: 55984
Buggy source:
@Override public final int timerEvent(){
  if (stopped) {
    return -1;
  }
  materialsManager.distributeJobs();
  handleWorkerCreationRequests();
  handleSoldierCreationRequest();
  handleDiggerRequest();
  handleBricklayerRequest();
  handleWorkerRequest();
  return SCHEDULING_PERIOD;
}

Fixed version (ground truth):
@Override public final int timerEvent(){
  if (stopped) {
    return -1;
  }
  materialsManager.distributeJobs();
  handleDiggerRequest();
  handleBricklayerRequest();
  handleWorkerRequest();
  handleWorkerCreationRequests();
  handleSoldierCreationRequest();
  return SCHEDULING_PERIOD;
}
Program: 55985
Project: 55985
Buggy source:
public final EMaterialType popToolProduction(ShortPoint2D closeTo){
  byte bestPrio=0;
  EMaterialType bestTool=null;
  for (  IWorkerCreationRequest request : workerCreationRequests) {
    if (!request.isRequestAlive())     continue;
    EMaterialType tool=request.requestedMovableType().getTool();
    byte prio=priorityForTool[tool.ordinal];
    if (prio > bestPrio) {
      bestPrio=prio;
      bestTool=tool;
    }
  }
  return bestTool;
}

Fixed version (ground truth):
public final EMaterialType popToolProduction(ShortPoint2D closeTo){
  byte bestPrio=0;
  EMaterialType bestTool=null;
  for (  WorkerCreationRequest request : workerCreationRequests) {
    if (!request.isRequestAlive() || !request.isToolProductionRequired())     continue;
    request.setToolProductionRequired(false);
    EMaterialType tool=request.requestedMovableType().getTool();
    byte prio=priorityForTool[tool.ordinal];
    if (prio > bestPrio) {
      bestPrio=prio;
      bestTool=tool;
    }
  }
  return bestTool;
}
Program: 55986
Project: 55986
Buggy source:
@Override public void workerCreationRequestFailed(IWorkerCreationRequest failedRequest){
  workerCreationRequests.offer(failedRequest);
}

Fixed version (ground truth):
@Override public void workerCreationRequestFailed(WorkerCreationRequest failedRequest){
  workerCreationRequests.offer(failedRequest);
}
Program: 55987
Project: 55987
Buggy source:
private void handleWorkerCreationRequests(){
  for (Iterator<IWorkerCreationRequest> iterator=workerCreationRequests.iterator(); iterator.hasNext(); ) {
    IWorkerCreationRequest workerCreationRequest=iterator.next();
    if (!workerCreationRequest.isRequestAlive() || tryToCreateWorker(workerCreationRequest)) {
      iterator.remove();
    }
  }
}

Fixed version (ground truth):
private void handleWorkerCreationRequests(){
  for (Iterator<WorkerCreationRequest> iterator=workerCreationRequests.iterator(); iterator.hasNext() && !joblessBearer.isEmpty(); ) {
    WorkerCreationRequest workerCreationRequest=iterator.next();
    if (!workerCreationRequest.isRequestAlive() || tryToCreateWorker(workerCreationRequest)) {
      iterator.remove();
    }
  }
}
Program: 55988
Project: 55988
Buggy source:
void workerCreationRequestFailed(IWorkerCreationRequest failedRequest);

Fixed version (ground truth):
void workerCreationRequestFailed(WorkerCreationRequest failedRequest);
Program: 55989
Project: 55989
Buggy source:
void becomeWorker(IWorkerRequester requester,IWorkerCreationRequest request,ShortPoint2D offer);

Fixed version (ground truth):
void becomeWorker(IWorkerRequester requester,WorkerCreationRequest request,ShortPoint2D offer);
Program: 55990
Project: 55990
Buggy source:
@Override public void becomeWorker(IWorkerRequester requester,IWorkerCreationRequest workerCreationRequest,ShortPoint2D offer){
  this.workerRequester=requester;
  this.workerCreationRequest=workerCreationRequest;
  this.offer=offer;
  this.state=EBearerState.INIT_CONVERT_WITH_TOOL_JOB;
  this.materialType=workerCreationRequest.requestedMovableType().getTool();
}

Fixed version (ground truth):
@Override public void becomeWorker(IWorkerRequester requester,WorkerCreationRequest workerCreationRequest,ShortPoint2D offer){
  this.workerRequester=requester;
  this.workerCreationRequest=workerCreationRequest;
  this.offer=offer;
  this.state=EBearerState.INIT_CONVERT_WITH_TOOL_JOB;
  this.materialType=workerCreationRequest.requestedMovableType().getTool();
}
Program: 55991
Project: 55991
Buggy source:
private void createNewToolUser(IWorkerCreationRequest workerCreationRequest){
  workerCreationRequests.offer(workerCreationRequest);
}

Fixed version (ground truth):
private void createNewToolUser(WorkerCreationRequest workerCreationRequest){
  workerCreationRequests.offer(workerCreationRequest);
}
Program: 55992
Project: 55992
Buggy source:
private boolean tryToCreateWorker(IWorkerCreationRequest workerCreationRequest){
  EMovableType movableType=workerCreationRequest.requestedMovableType();
  EMaterialType tool=movableType.getTool();
  if (tool != EMaterialType.NO_MATERIAL) {
    MaterialOffer offer=this.materialOffers.removeOfferCloseTo(tool,workerCreationRequest.getPos());
    if (offer != null) {
      IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(offer.getPos());
      if (manageableBearer != null) {
        manageableBearer.becomeWorker(this,workerCreationRequest,offer.getPos());
        return true;
      }
 else {
        materialOffers.addOffer(offer.getPos(),tool);
        return false;
      }
    }
 else {
      return false;
    }
  }
 else {
    IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(workerCreationRequest.getPos());
    if (manageableBearer != null) {
      manageableBearer.becomeWorker(this,workerCreationRequest);
      return true;
    }
 else {
      return false;
    }
  }
}

Fixed version (ground truth):
private boolean tryToCreateWorker(WorkerCreationRequest workerCreationRequest){
  EMovableType movableType=workerCreationRequest.requestedMovableType();
  EMaterialType tool=movableType.getTool();
  if (tool != EMaterialType.NO_MATERIAL) {
    MaterialOffer offer=this.materialOffers.removeOfferCloseTo(tool,workerCreationRequest.getPos());
    if (offer != null) {
      IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(offer.getPos());
      if (manageableBearer != null) {
        manageableBearer.becomeWorker(this,workerCreationRequest,offer.getPos());
        return true;
      }
 else {
        materialOffers.addOffer(offer.getPos(),tool);
        return false;
      }
    }
 else {
      workerCreationRequest.setToolProductionRequired(true);
      return false;
    }
  }
 else {
    IManageableBearer manageableBearer=joblessBearer.removeObjectNextTo(workerCreationRequest.getPos());
    if (manageableBearer != null) {
      manageableBearer.becomeWorker(this,workerCreationRequest);
      return true;
    }
 else {
      return false;
    }
  }
}
Program: 55993
Project: 55993
Buggy source:
@Override public final int timerEvent(){
  if (stopped) {
    return -1;
  }
  materialsManager.distributeJobs();
  handleWorkerCreationRequests();
  handleSoldierCreationRequest();
  handleDiggerRequest();
  handleBricklayerRequest();
  handleWorkerRequest();
  return SCHEDULING_PERIOD;
}

Fixed version (ground truth):
@Override public final int timerEvent(){
  if (stopped) {
    return -1;
  }
  materialsManager.distributeJobs();
  handleDiggerRequest();
  handleBricklayerRequest();
  handleWorkerRequest();
  handleWorkerCreationRequests();
  handleSoldierCreationRequest();
  return SCHEDULING_PERIOD;
}
Program: 55994
Project: 55994
Buggy source:
public final EMaterialType popToolProduction(ShortPoint2D closeTo){
  byte bestPrio=0;
  EMaterialType bestTool=null;
  for (  IWorkerCreationRequest request : workerCreationRequests) {
    if (!request.isRequestAlive())     continue;
    EMaterialType tool=request.requestedMovableType().getTool();
    byte prio=priorityForTool[tool.ordinal];
    if (prio > bestPrio) {
      bestPrio=prio;
      bestTool=tool;
    }
  }
  return bestTool;
}

Fixed version (ground truth):
public final EMaterialType popToolProduction(ShortPoint2D closeTo){
  byte bestPrio=0;
  EMaterialType bestTool=null;
  for (  WorkerCreationRequest request : workerCreationRequests) {
    if (!request.isRequestAlive() || !request.isToolProductionRequired())     continue;
    request.setToolProductionRequired(false);
    EMaterialType tool=request.requestedMovableType().getTool();
    byte prio=priorityForTool[tool.ordinal];
    if (prio > bestPrio) {
      bestPrio=prio;
      bestTool=tool;
    }
  }
  return bestTool;
}
Program: 55995
Project: 55995
Buggy source:
@Override public void workerCreationRequestFailed(IWorkerCreationRequest failedRequest){
  workerCreationRequests.offer(failedRequest);
}

Fixed version (ground truth):
@Override public void workerCreationRequestFailed(WorkerCreationRequest failedRequest){
  workerCreationRequests.offer(failedRequest);
}
Program: 55996
Project: 55996
Buggy source:
private void handleWorkerCreationRequests(){
  for (Iterator<IWorkerCreationRequest> iterator=workerCreationRequests.iterator(); iterator.hasNext(); ) {
    IWorkerCreationRequest workerCreationRequest=iterator.next();
    if (!workerCreationRequest.isRequestAlive() || tryToCreateWorker(workerCreationRequest)) {
      iterator.remove();
    }
  }
}

Fixed version (ground truth):
private void handleWorkerCreationRequests(){
  for (Iterator<WorkerCreationRequest> iterator=workerCreationRequests.iterator(); iterator.hasNext() && !joblessBearer.isEmpty(); ) {
    WorkerCreationRequest workerCreationRequest=iterator.next();
    if (!workerCreationRequest.isRequestAlive() || tryToCreateWorker(workerCreationRequest)) {
      iterator.remove();
    }
  }
}
Program: 55997
Project: 55997
Buggy source:
void workerCreationRequestFailed(IWorkerCreationRequest failedRequest);

Fixed version (ground truth):
void workerCreationRequestFailed(WorkerCreationRequest failedRequest);
Program: 55998
Project: 55998
Buggy source:
void becomeWorker(IWorkerRequester requester,IWorkerCreationRequest request,ShortPoint2D offer);

Fixed version (ground truth):
void becomeWorker(IWorkerRequester requester,WorkerCreationRequest request,ShortPoint2D offer);
Program: 55999
Project: 55999
Buggy source:
@Override public void becomeWorker(IWorkerRequester requester,IWorkerCreationRequest workerCreationRequest,ShortPoint2D offer){
  this.workerRequester=requester;
  this.workerCreationRequest=workerCreationRequest;
  this.offer=offer;
  this.state=EBearerState.INIT_CONVERT_WITH_TOOL_JOB;
  this.materialType=workerCreationRequest.requestedMovableType().getTool();
}

Fixed version (ground truth):
@Override public void becomeWorker(IWorkerRequester requester,WorkerCreationRequest workerCreationRequest,ShortPoint2D offer){
  this.workerRequester=requester;
  this.workerCreationRequest=workerCreationRequest;
  this.offer=offer;
  this.state=EBearerState.INIT_CONVERT_WITH_TOOL_JOB;
  this.materialType=workerCreationRequest.requestedMovableType().getTool();
}
Program: 56000
Project: 56000
Buggy source:
/** 
 * Sets or removes a construction mark
 * @param x x coordinate
 * @param y y coordinate
 * @param set If true, the construction mark shall be set, otherwise, it shall be removed.
 * @param flattenPositions The positions that need to be flattened to position this building. This value might be null whenever set is false.
 */
public abstract void setConstructMarking(int x,int y,boolean set,RelativePoint[] flattenPositions);

Fixed version (ground truth):
/** 
 * Sets or removes a construction mark
 * @param x x coordinate
 * @param y y coordinate
 * @param set If true, the construction mark shall be set, otherwise, it shall be removed.
 * @param binaryConstructionMarkValues If true, the construction marks can only have to values: Either building is possible (set == <code>true</code>) or building is not possible (set == <code>false</code>).
 * @param flattenPositions The positions that need to be flattened to position this building. This value might be null whenever set is false.
 */
public abstract void setConstructMarking(int x,int y,boolean set,boolean binaryConstructionMarkValues,RelativePoint[] flattenPositions);
Program: 56001
Project: 56001
Buggy source:
@Override public void run(){
  while (!canceled) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null && !canceled) {
        if (!pausingSupplier.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.restart();
          EBuildingType buildingType=this.buildingType;
          if (buildingType != null && mapArea != null) {
            algorithm.calculateConstructMarks(mapArea,buildingType.getBuildingAreaBitSet(),buildingType.getGroundtypes(),buildingType.getBlockedTiles());
          }
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      algorithm.removeConstructionMarks();
    }
 catch (    InterruptedException e) {
    }
catch (    Throwable t) {
      t.printStackTrace();
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (!canceled) {
    try {
synchronized (this) {
        while (buildingType == null) {
          this.wait();
        }
      }
      while (buildingType != null && !canceled) {
        if (!pausingSupplier.isPausing()) {
          StopWatch watch=new MilliStopWatch();
          watch.restart();
          EBuildingType buildingType=this.buildingType;
          if (buildingType != null && mapArea != null) {
            algorithm.calculateConstructMarks(mapArea,buildingType.getBuildingAreaBitSet(),buildingType.getGroundtypes(),buildingType.getBlockedTiles(),buildingType.isMine());
          }
          watch.stop("String_Node_Str");
        }
synchronized (this) {
          wait(AlgorithmConstants.CONSTRUCT_MARKS_MAX_REFRESH_TIME);
        }
      }
      algorithm.removeConstructionMarks();
    }
 catch (    InterruptedException e) {
    }
catch (    Throwable t) {
      t.printStackTrace();
    }
  }
}
Program: 56003
Project: 56003
Buggy source:
/** 
 * Removes all construction marks in the given area.
 * @param area The area to remove the marks
 * @param notIn The area of marks that should be skipped.
 */
private void removeConstructionMarks(IMapArea area,IMapArea notIn){
  for (  ShortPoint2D pos : new MapShapeFilter(area,map.getWidth(),map.getHeight())) {
    if (!notIn.contains(pos)) {
      map.setConstructMarking(pos.x,pos.y,false,null);
    }
  }
}

Fixed version (ground truth):
/** 
 * Removes all construction marks in the given area.
 * @param area The area to remove the marks
 * @param notIn The area of marks that should be skipped.
 */
private void removeConstructionMarks(IMapArea area,IMapArea notIn){
  for (  ShortPoint2D pos : new MapShapeFilter(area,map.getWidth(),map.getHeight())) {
    if (!notIn.contains(pos)) {
      map.setConstructMarking(pos.x,pos.y,false,false,null);
    }
  }
}
Program: 56004
Project: 56004
Buggy source:
@Override public final void setConstructMarking(int x,int y,boolean set,RelativePoint[] flattenPositions){
  if (isInBounds(x,y)) {
    if (set) {
      mapObjectsManager.setConstructionMarking(x,y,getConstructionMarkValue(x,y,flattenPositions));
    }
 else {
      mapObjectsManager.setConstructionMarking(x,y,(byte)-1);
    }
  }
}

Fixed version (ground truth):
@Override public final void setConstructMarking(int x,int y,boolean set,boolean binaryConstructionMarkValues,RelativePoint[] flattenPositions){
  if (isInBounds(x,y)) {
    if (set) {
      byte newValue=binaryConstructionMarkValues ? 0 : getConstructionMarkValue(x,y,flattenPositions);
      mapObjectsManager.setConstructionMarking(x,y,newValue);
    }
 else {
      mapObjectsManager.setConstructionMarking(x,y,(byte)-1);
    }
  }
}
Program: 56005
Project: 56005
Buggy source:
@Test public void test(){
  boolean[][] blocked={{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,true,false,false,false,false,false},{false,false,false,false,false,false,true,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false}};
  boolean[][] buildingMask={{false,false,true,false,false},{true,true,true,true,true},{false,false,false,false,false}};
  MapRectangle mapArea=new MapRectangle(-15,-15,30,30);
  BuildingAreaBitSet buildingSet=new BuildingAreaBitSet(BuildingAreaBitSetTest.createRelativePoints(buildingMask));
  TestMap map=new TestMap(blocked);
  NewConstructionMarksAlgorithm algorithm=new NewConstructionMarksAlgorithm(map,(byte)0);
  algorithm.calculateConstructMarks(mapArea,buildingSet,null,null);
  for (int y=0; y < map.height; y++) {
    for (int x=0; x < map.width; x++) {
      assertEquals(x + "String_Node_Str" + y,canCostructAt(map,x,y,buildingSet),map.marksSet[x + y * map.width] > 0);
    }
  }
}

Fixed version (ground truth):
@Test public void test(){
  boolean[][] blocked={{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,true,false,false,false,false,false},{false,false,false,false,false,false,true,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false},{false,false,false,false,false,false,false,false,false,false,false,false}};
  boolean[][] buildingMask={{false,false,true,false,false},{true,true,true,true,true},{false,false,false,false,false}};
  MapRectangle mapArea=new MapRectangle(-15,-15,30,30);
  BuildingAreaBitSet buildingSet=new BuildingAreaBitSet(BuildingAreaBitSetTest.createRelativePoints(buildingMask));
  TestMap map=new TestMap(blocked);
  NewConstructionMarksAlgorithm algorithm=new NewConstructionMarksAlgorithm(map,(byte)0);
  algorithm.calculateConstructMarks(mapArea,buildingSet,null,null,false);
  for (int y=0; y < map.height; y++) {
    for (int x=0; x < map.width; x++) {
      assertEquals(x + "String_Node_Str" + y,canCostructAt(map,x,y,buildingSet),map.marksSet[x + y * map.width] > 0);
    }
  }
}
Program: 56006
Project: 56006
Buggy source:
@Override public void setConstructMarking(int x,int y,boolean set,RelativePoint[] flattenPositions){
  if (isInBounds(x,y))   marksSet[x + y * width]=set ? 1 : -1;
}

Fixed version (ground truth):
@Override public void setConstructMarking(int x,int y,boolean set,boolean binaryConstructionMarkValues,RelativePoint[] flattenPositions){
  if (isInBounds(x,y))   marksSet[x + y * width]=set ? 1 : -1;
}
Program: 56007
Project: 56007
Buggy source:
@Override public EMovableType popWeaponForBearer(){
  List<RequestStack> stacks=super.getStacks();
  for (  RequestStack stack : stacks) {
    if (stack.getMaterialType() == EMaterialType.BOW || stack.getMaterialType() == EMaterialType.SWORD || stack.getMaterialType() == EMaterialType.SPEAR) {
      if (stack.hasMaterial()) {
        stack.pop();
        return getSoldierType(stack.getMaterialType());
      }
    }
  }
  return null;
}

Fixed version (ground truth):
@Override public EMovableType popWeaponForBearer(){
  List<RequestStack> stacks=super.getStacks();
  for (  RequestStack stack : stacks) {
    if (stack.getMaterialType() == EMaterialType.BOW || stack.getMaterialType() == EMaterialType.SWORD || stack.getMaterialType() == EMaterialType.SPEAR) {
      if (stack.pop()) {
        return getSoldierType(stack.getMaterialType());
      }
    }
  }
  return null;
}
Program: 56008
Project: 56008
Buggy source:
@Override protected int subTimerEvent(){
  RequestStack wineStack=getWineStack();
  if (wineStack.hasMaterial()) {
    wineStack.pop();
    return CONSUME_DELAY;
  }
 else {
    return CHECK_DELAY;
  }
}

Fixed version (ground truth):
@Override protected int subTimerEvent(){
  RequestStack wineStack=getWineStack();
  if (wineStack.pop()) {
    return CONSUME_DELAY;
  }
 else {
    return CHECK_DELAY;
  }
}
Program: 56009
Project: 56009
Buggy source:
@Override public final boolean popMaterialFromStack(EMaterialType material){
  for (  RequestStack stack : super.getStacks()) {
    if (stack.getMaterialType() == material) {
      stack.pop();
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
@Override public final boolean popMaterialFromStack(EMaterialType material){
  for (  RequestStack stack : super.getStacks()) {
    if (stack.getMaterialType() == material) {
      return stack.pop();
    }
  }
  return false;
}
Program: 56010
Project: 56010
Buggy source:
@Override public final void popMaterial(ShortPoint2D position,EMaterialType materialType){
  mapObjectsManager.popMaterial(position.x,position.y,materialType);
}

Fixed version (ground truth):
@Override public final boolean popMaterial(ShortPoint2D position,EMaterialType materialType){
  return mapObjectsManager.popMaterial(position.x,position.y,materialType);
}
Program: 56011
Project: 56011
Buggy source:
/** 
 * Pops a materials of the given type from the given location.
 * @param position The location to pop the material.
 * @param materialType The  {@link EMaterialType} type to be popped.
 */
void popMaterial(ShortPoint2D position,EMaterialType materialType);

Fixed version (ground truth):
/** 
 * Pops a materials of the given type from the given location.
 * @param position The location to pop the material.
 * @param materialType The  {@link EMaterialType} type to be popped.
 * @return if <code>true</code>, the material has been popped. If <code>false</code>, no material of this type has been found at the givenposition.
 */
boolean popMaterial(ShortPoint2D position,EMaterialType materialType);
Program: 56012
Project: 56012
Buggy source:
/** 
 * Pops a material from this stack. The material is of the type returned by   {@link #getMaterialType()} and specified in the constructor.
 */
public void pop(){
  grid.popMaterial(position,materialType);
  popped++;
}

Fixed version (ground truth):
/** 
 * Pops a material from this stack. The material is of the type returned by   {@link #getMaterialType()} and specified in the constructor.
 * @return <code>true</code> if there was a material to be popped from this stack. False otherwise.
 */
public boolean pop(){
  if (grid.popMaterial(position,materialType)) {
    popped++;
    return true;
  }
 else {
    return false;
  }
}
Program: 56013
Project: 56013
Buggy source:
@Override protected void action(){
switch (state) {
case JOBLESS:
    break;
case INIT_JOB:
  goToDiggablePosition();
break;
case PLAYING_ACTION:
executeDigg();
if (!requester.isDiggerRequestActive()) {
reportJobless();
break;
}
case GOING_TO_POS:
if (needsToBeWorkedOn(super.getPos())) {
super.playAction(EAction.ACTION1,1f);
this.state=EDiggerState.PLAYING_ACTION;
}
 else {
goToDiggablePosition();
}
break;
case DEAD_OBJECT:
break;
}
}

Fixed version (ground truth):
@Override protected void action(){
switch (state) {
case JOBLESS:
    break;
case INIT_JOB:
  goToDiggablePosition();
break;
case PLAYING_ACTION:
executeDigg();
if (!requester.isDiggerRequestActive()) {
super.getStrategyGrid().setMarked(super.getPos(),false);
reportJobless();
break;
}
case GOING_TO_POS:
if (needsToBeWorkedOn(super.getPos())) {
super.playAction(EAction.ACTION1,1f);
this.state=EDiggerState.PLAYING_ACTION;
}
 else {
goToDiggablePosition();
}
break;
case DEAD_OBJECT:
break;
}
}
Program: 56014
Project: 56014
Buggy source:
private boolean goToRandomDirection(Movable pushingMovable){
  int offset=RandomSingleton.getInt(0,EDirection.NUMBER_OF_DIRECTIONS - 1);
  EDirection pushedFromDir=EDirection.getDirection(this.getPos(),pushingMovable.getPos());
  for (int i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
    EDirection currDir=EDirection.values[(i + offset) % EDirection.NUMBER_OF_DIRECTIONS];
    if (currDir != pushedFromDir && goInDirection(currDir)) {
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean goToRandomDirection(Movable pushingMovable){
  int offset=RandomSingleton.getInt(0,EDirection.NUMBER_OF_DIRECTIONS - 1);
  EDirection pushedFromDir=EDirection.getDirection(this.getPos(),pushingMovable.getPos());
  for (int i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
    EDirection currDir=EDirection.values[(i + offset) % EDirection.NUMBER_OF_DIRECTIONS];
    if (currDir != pushedFromDir && goInDirection(currDir,false)) {
      return true;
    }
  }
  return false;
}
Program: 56015
Project: 56015
Buggy source:
/** 
 * Tries to go a step in the given direction.
 * @param direction direction to go
 * @return true if the step can and will immediately be executed. <br>false if the target position is generally blocked or a movable occupies that position.
 */
final boolean goInDirection(EDirection direction){
  ShortPoint2D pos=direction.getNextHexPoint(position);
  if (grid.isValidPosition(this,pos) && grid.hasNoMovableAt(pos.x,pos.y)) {
    initGoingSingleStep(pos);
    this.direction=direction;
    setState(EMovableState.GOING_SINGLE_STEP);
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Tries to go a step in the given direction.
 * @param direction direction to go
 * @param force If true, the step will be forced and the method will always return true.
 * @return true if the step can and will immediately be executed. <br>false if the target position is generally blocked or a movable occupies that position.
 */
final boolean goInDirection(EDirection direction,boolean force){
  ShortPoint2D pos=direction.getNextHexPoint(position);
  if (force || (grid.isValidPosition(this,pos) && grid.hasNoMovableAt(pos.x,pos.y))) {
    this.direction=direction;
    initGoingSingleStep(pos);
    setState(EMovableState.GOING_SINGLE_STEP);
    return true;
  }
 else {
    return false;
  }
}
Program: 56016
Project: 56016
Buggy source:
public void leavePosition(){
  if (!enableNothingToDo) {
    return;
  }
  int offset=RandomSingleton.getInt(0,EDirection.NUMBER_OF_DIRECTIONS - 1);
  for (int i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
    EDirection currDir=EDirection.values[(i + offset) % EDirection.NUMBER_OF_DIRECTIONS];
    if (goInDirection(currDir)) {
      break;
    }
 else {
      Movable movableAtPos=grid.getMovableAt(currDir.getNextTileX(position.x),currDir.getNextTileY(position.y));
      if (movableAtPos != null) {
        movableAtPos.push(this);
      }
    }
  }
}

Fixed version (ground truth):
public void leavePosition(){
  if (!enableNothingToDo) {
    return;
  }
  int offset=RandomSingleton.getInt(0,EDirection.NUMBER_OF_DIRECTIONS - 1);
  for (int i=0; i < EDirection.NUMBER_OF_DIRECTIONS; i++) {
    EDirection currDir=EDirection.values[(i + offset) % EDirection.NUMBER_OF_DIRECTIONS];
    if (goInDirection(currDir,false)) {
      break;
    }
 else {
      Movable movableAtPos=grid.getMovableAt(currDir.getNextTileX(position.x),currDir.getNextTileY(position.y));
      if (movableAtPos != null) {
        movableAtPos.push(this);
      }
    }
  }
}
Program: 56017
Project: 56017
Buggy source:
/** 
 * Tries to walk the movable into a position where it has a minimum distance to others.
 * @return true if the movable moves to flock, false if no flocking is required.
 */
private boolean flockToDecentralize(){
  ShortPoint2D decentVector=grid.calcDecentralizeVector(position.x,position.y);
  EDirection randomDirection=direction.getNeighbor(RandomSingleton.getInt(-1,1));
  int dx=randomDirection.gridDeltaX + decentVector.x;
  int dy=randomDirection.gridDeltaY + decentVector.y;
  if (ShortPoint2D.getOnGridDist(dx,dy) >= 2) {
    flockDelay=Math.max(flockDelay - 100,500);
    if (this.goInDirection(EDirection.getApproxDirection(0,0,dx,dy))) {
      return true;
    }
 else {
      return false;
    }
  }
 else {
    flockDelay=Math.min(flockDelay + 100,1000);
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Tries to walk the movable into a position where it has a minimum distance to others.
 * @return true if the movable moves to flock, false if no flocking is required.
 */
private boolean flockToDecentralize(){
  ShortPoint2D decentVector=grid.calcDecentralizeVector(position.x,position.y);
  EDirection randomDirection=direction.getNeighbor(RandomSingleton.getInt(-1,1));
  int dx=randomDirection.gridDeltaX + decentVector.x;
  int dy=randomDirection.gridDeltaY + decentVector.y;
  if (ShortPoint2D.getOnGridDist(dx,dy) >= 2) {
    flockDelay=Math.max(flockDelay - 100,500);
    if (this.goInDirection(EDirection.getApproxDirection(0,0,dx,dy),false)) {
      return true;
    }
 else {
      return false;
    }
  }
 else {
    flockDelay=Math.min(flockDelay + 100,1000);
    return false;
  }
}
Program: 56018
Project: 56018
Buggy source:
/** 
 * Tries to go a step in the given direction.
 * @param direction direction to go
 * @return true if the step can and will immediately be executed. <br>false if the target position is generally blocked or a movable occupies that position.
 */
protected final boolean goInDirection(EDirection direction){
  return movable.goInDirection(direction);
}

Fixed version (ground truth):
/** 
 * Tries to go a step in the given direction.
 * @param direction direction to go
 * @param force If true, the step will be forced and the method will always return true.
 * @return true if the step can and will immediately be executed. <br>false if the target position is generally blocked or a movable occupies that position.
 */
protected final boolean goInDirection(EDirection direction,boolean force){
  return movable.goInDirection(direction,force);
}
Program: 56019
Project: 56019
Buggy source:
@Override protected void action(){
  ShortPoint2D position=super.getPos();
  if (!super.isValidPosition(position)) {
    if (searchesCounter > 120) {
      super.getMovable().kill();
      return;
    }
    if (super.preSearchPath(true,position.x,position.y,Constants.MOVABLE_FLEE_TO_VALID_POSITION_RADIUS,ESearchType.VALID_FREE_POSITION)) {
      super.followPresearchedPath();
    }
 else {
      EDirection currentDirection=super.getMovable().getDirection();
      EDirection newDirection;
      if (turnNextTime || RandomSingleton.nextF() < 0.10) {
        turnNextTime=false;
        newDirection=currentDirection.getNeighbor(RandomSingleton.getInt(-1,1));
      }
 else {
        newDirection=currentDirection;
      }
      ShortPoint2D newPos=newDirection.getNextHexPoint(position);
      if (super.getStrategyGrid().isFreePosition(newPos)) {
        super.goInDirection(newDirection);
      }
 else {
        super.lookInDirection(newDirection);
        turnNextTime=true;
      }
    }
    searchesCounter++;
  }
 else {
    super.convertTo(super.getMovable().getMovableType());
  }
}

Fixed version (ground truth):
@Override protected void action(){
  ShortPoint2D position=super.getPos();
  if (!super.isValidPosition(position)) {
    if (searchesCounter > 120) {
      super.getMovable().kill();
      return;
    }
    if (super.preSearchPath(true,position.x,position.y,Constants.MOVABLE_FLEE_TO_VALID_POSITION_RADIUS,ESearchType.VALID_FREE_POSITION)) {
      super.followPresearchedPath();
    }
 else {
      EDirection currentDirection=super.getMovable().getDirection();
      EDirection newDirection;
      if (turnNextTime || RandomSingleton.nextF() < 0.10) {
        turnNextTime=false;
        newDirection=currentDirection.getNeighbor(RandomSingleton.getInt(-1,1));
      }
 else {
        newDirection=currentDirection;
      }
      ShortPoint2D newPos=newDirection.getNextHexPoint(position);
      if (super.getStrategyGrid().isFreePosition(newPos)) {
        super.goInDirection(newDirection,true);
        turnNextTime=RandomSingleton.getInt(7) == 0;
      }
 else {
        super.lookInDirection(newDirection);
        turnNextTime=true;
      }
    }
    searchesCounter++;
  }
 else {
    super.convertTo(super.getMovable().getMovableType());
  }
}
Program: 56020
Project: 56020
Buggy source:
private void goToEnemy(IAttackable enemy){
  if (inSaveGotoMode) {
    goToSavely(enemy);
  }
 else {
    ShortPoint2D pos=super.getPos();
    EDirection dir=EDirection.getApproxDirection(pos,enemy.getPos());
    ShortPoint2D nextPos=dir.getNextHexPoint(pos);
    if (super.isValidPosition(nextPos)) {
      super.goInDirection(dir);
      return;
    }
 else {
      goToSavely(enemy);
      inSaveGotoMode=true;
    }
  }
}

Fixed version (ground truth):
private void goToEnemy(IAttackable enemy){
  if (inSaveGotoMode) {
    goToSavely(enemy);
  }
 else {
    ShortPoint2D pos=super.getPos();
    EDirection dir=EDirection.getApproxDirection(pos,enemy.getPos());
    if (super.goInDirection(dir,false)) {
      return;
    }
 else {
      inSaveGotoMode=true;
      goToSavely(enemy);
    }
  }
}
Program: 56021
Project: 56021
Buggy source:
private void findWorkablePosition(){
  EDirection closeForeignTileDir=getCloseForeignTile();
  if (closeForeignTileDir != null && super.goInDirection(closeForeignTileDir)) {
    this.state=EPioneerState.GOING_TO_POS;
    return;
  }
  centerPos=null;
  ShortPoint2D pos=super.getPos();
  if (super.preSearchPath(true,pos.x,pos.y,(short)30,ESearchType.UNENFORCED_FOREIGN_GROUND)) {
    super.followPresearchedPath();
    this.state=EPioneerState.GOING_TO_POS;
  }
 else {
    this.state=EPioneerState.JOBLESS;
  }
}

Fixed version (ground truth):
private void findWorkablePosition(){
  EDirection closeForeignTileDir=getCloseForeignTile();
  if (closeForeignTileDir != null && super.goInDirection(closeForeignTileDir,false)) {
    this.state=EPioneerState.GOING_TO_POS;
    return;
  }
  centerPos=null;
  ShortPoint2D pos=super.getPos();
  if (super.preSearchPath(true,pos.x,pos.y,(short)30,ESearchType.UNENFORCED_FOREIGN_GROUND)) {
    super.followPresearchedPath();
    this.state=EPioneerState.GOING_TO_POS;
  }
 else {
    this.state=EPioneerState.JOBLESS;
  }
}
Program: 56022
Project: 56022
Buggy source:
/** 
 * Registers the given listener to receive data of the type it specifys with it's getKeys() method.
 * @param listener The listener that shall be registered.
 */
public void registerListener(IChannelListener listener){
  ENetworkKey[] keys=listener.getKeys();
  for (int i=0; i < keys.length; i++) {
    listenerRegistry.put(keys[i],listener);
  }
}

Fixed version (ground truth):
/** 
 * Registers the given listener to receive data of the type it specifies with it's getKeys() method.
 * @param listener The listener that shall be registered.
 */
public void registerListener(IChannelListener listener){
  ENetworkKey[] keys=listener.getKeys();
  for (int i=0; i < keys.length; i++) {
    listenerRegistry.put(keys[i],listener);
  }
}
Program: 56023
Project: 56023
Buggy source:
public void playerLeft(Player player){
synchronized (players) {
    players.remove(player);
    sendMatchInfoUpdate(NetworkConstants.ENetworkMessage.PLAYER_LEFT,player.getPlayerInfo());
    player.sendPacket(NetworkConstants.ENetworkKey.MATCH_INFO_UPDATE,generateMatchInfoUpdate(NetworkConstants.ENetworkMessage.PLAYER_LEFT,player.getPlayerInfo()));
    if (isRunning()) {
synchronized (leftPlayers) {
        leftPlayers.add(player);
      }
    }
  }
}

Fixed version (ground truth):
public void playerLeft(Player player){
synchronized (players) {
    players.remove(player);
    sendMatchInfoUpdate(NetworkConstants.ENetworkMessage.PLAYER_LEFT,player.getPlayerInfo());
    player.sendPacket(NetworkConstants.ENetworkKey.MATCH_INFO_UPDATE,generateMatchInfoUpdate(NetworkConstants.ENetworkMessage.PLAYER_LEFT,player.getPlayerInfo()));
    if (isRunning()) {
synchronized (leftPlayers) {
        leftPlayers.add(player);
      }
    }
    if (players.isEmpty()) {
      shutdownMatch();
    }
  }
}
Program: 56024
Project: 56024
Buggy source:
public List<? extends T> getItems(){
  return items;
}

Fixed version (ground truth):
public List<T> getItems(){
  return items;
}
Program: 56025
Project: 56025
Buggy source:
public void stop(){
  listener=null;
  items=Collections.emptyList();
}

Fixed version (ground truth):
public void stop(){
  listener=null;
  items=new LinkedList<>();
}
Program: 56026
Project: 56026
Buggy source:
public ChangingList(List<? extends T> items){
  setList(items);
}

Fixed version (ground truth):
public ChangingList(List<T> items){
  this.items=items;
}
Program: 56027
Project: 56027
Buggy source:
public synchronized void setListener(IChangingListListener<T> listener){
  this.listener=listener;
}

Fixed version (ground truth):
public void setListener(IChangingListListener<? super T> listener){
  this.listener=listener;
}
Program: 56028
Project: 56028
Buggy source:
public void setList(List<? extends T> items){
  if (items == null) {
    throw new NullPointerException();
  }
  this.items=items;
  informListener();
}

Fixed version (ground truth):
public void setList(List<T> items){
  if (items == null) {
    throw new NullPointerException();
  }
  this.items=items;
  notifyListener();
}
Program: 56029
Project: 56029
Buggy source:
void listChanged(ChangingList<T> list);

Fixed version (ground truth):
void listChanged(ChangingList<? extends T> list);
Program: 56030
Project: 56030
Buggy source:
@Override public Component getListCellRendererComponent(JList<? extends IMapDefinition> list,IMapDefinition map,int index,boolean isSelected,boolean hasFocus){
  return new MapDefintionPanel(map.getName(),map.getDescription(),map.getCreationDate(),isSelected);
}

Fixed version (ground truth):
@Override public Component getListCellRendererComponent(JList<? extends IMapDefinition> list,IMapDefinition map,int index,boolean isSelected,boolean hasFocus){
  return new MapDefintionPanel(map.getMapName(),map.getDescription(),map.getCreationDate(),isSelected);
}
Program: 56031
Project: 56031
Buggy source:
protected ListModel<IMapDefinition> generateModel(ChangingList<IMapDefinition> maps){
  DefaultListModel<IMapDefinition> model=new DefaultListModel<IMapDefinition>();
  for (  IMapDefinition curr : maps.getItems())   model.addElement(curr);
  return model;
}

Fixed version (ground truth):
protected ListModel<IMapDefinition> generateModel(ChangingList<? extends IMapDefinition> maps){
  DefaultListModel<IMapDefinition> model=new DefaultListModel<IMapDefinition>();
  for (  IMapDefinition curr : maps.getItems())   model.addElement(curr);
  return model;
}
Program: 56032
Project: 56032
Buggy source:
@Override public void onDetach(){
  connector.getPlayers().setListener(null);
}

Fixed version (ground truth):
@Override public void onDetach(){
  connector.getPlayers().removeListener(this);
}
Program: 56033
Project: 56033
Buggy source:
@Override public void listChanged(ChangingList<IMultiplayerPlayer> list){
  multiplayerList.setItems(list.getItems());
}

Fixed version (ground truth):
@Override public void listChanged(ChangingList<? extends IMultiplayerPlayer> list){
  multiplayerList.setItems(list.getItems());
}
Program: 56034
Project: 56034
Buggy source:
public JoinableGameItem(IJoinableGame item){
  super(item.getMap().getName(),item.getId());
}

Fixed version (ground truth):
public JoinableGameItem(IJoinableGame item){
  super(item.getMap().getMapName(),item.getId());
}
Program: 56035
Project: 56035
Buggy source:
public LoadableMapListItem(IMapDefinition item){
  super(item.getName(),toPlayerString(item.getPlayers()));
}

Fixed version (ground truth):
public LoadableMapListItem(IMapDefinition item){
  super(item.getMapName(),toPlayerString(item.getPlayers()));
}
Program: 56036
Project: 56036
Buggy source:
public void stop(){
  listener=null;
  items=Collections.emptyList();
}

Fixed version (ground truth):
public void stop(){
  listener=null;
  items=new LinkedList<>();
}
Program: 56037
Project: 56037
Buggy source:
public synchronized void setListener(IChangingListListener<? super T> listener){
  this.listener=listener;
}

Fixed version (ground truth):
public void setListener(IChangingListListener<? super T> listener){
  this.listener=listener;
}
Program: 56038
Project: 56038
Buggy source:
@Override public void onDetach(){
  connector.getPlayers().setListener(null);
}

Fixed version (ground truth):
@Override public void onDetach(){
  connector.getPlayers().removeListener(this);
}
Program: 56039
Project: 56039
Buggy source:
@Override public void onDetach(){
  super.onDetach();
  getList().setListener(null);
}

Fixed version (ground truth):
@Override public void onDetach(){
  super.onDetach();
  getList().removeListener(this);
}
Program: 56040
Project: 56040
Buggy source:
short getPartitionIdAt(int x,int y);

Fixed version (ground truth):
public abstract short getPartitionIdAt(int x,int y);
Program: 56041
Project: 56041
Buggy source:
boolean canConstructAt(short x,short y,EBuildingType type,byte playerId);

Fixed version (ground truth):
public abstract boolean canConstructAt(short x,short y,EBuildingType type,byte playerId);
Program: 56042
Project: 56042
Buggy source:
/** 
 * @return height of map
 */
short getHeight();

Fixed version (ground truth):
/** 
 * @return height of map
 */
public abstract short getHeight();
Program: 56043
Project: 56043
Buggy source:
/** 
 * Checks if the given position is valid to build a building of given player that can stand on the given   {@link ELandscapeType}s. Bounds checks will be done by this method.
 * @param x x coordinate of the target position
 * @param y y coordinate of the target position
 * @param landscapeTypes allowed landscape types
 * @param partitionId player
 * @return true if a building can be positioned at the given position<br>false otherwise.
 */
boolean canUsePositionForConstruction(int x,int y,ELandscapeType[] landscapeTypes,short partitionId);

Fixed version (ground truth):
/** 
 * Checks if the given position is valid to build a building of given player that can stand on the given   {@link ELandscapeType}s. Bounds checks will be done by this method.
 * @param x x coordinate of the target position
 * @param y y coordinate of the target position
 * @param landscapeTypes allowed landscape types
 * @param partitionId player
 * @return true if a building can be positioned at the given position<br>false otherwise.
 */
public abstract boolean canUsePositionForConstruction(int x,int y,ELandscapeType[] landscapeTypes,short partitionId);
Program: 56044
Project: 56044
Buggy source:
byte getConstructionMarkValue(int mapX,int mapY,final RelativePoint[] flattenPositions);

Fixed version (ground truth):
public abstract byte getConstructionMarkValue(int mapX,int mapY,final RelativePoint[] flattenPositions);
Program: 56045
Project: 56045
Buggy source:
boolean isInBounds(int x,int y);

Fixed version (ground truth):
public abstract boolean isInBounds(int x,int y);
Program: 56046
Project: 56046
Buggy source:
boolean canPlayerConstructOnPartition(byte playerId,short partitionId);

Fixed version (ground truth):
public abstract boolean canPlayerConstructOnPartition(byte playerId,short partitionId);
Program: 56047
Project: 56047
Buggy source:
/** 
 * @return width of map.
 */
short getWidth();

Fixed version (ground truth):
/** 
 * @return width of map.
 */
public abstract short getWidth();
Program: 56048
Project: 56048
Buggy source:
/** 
 * Sets or removes a construction mark
 * @param x x coordinate
 * @param y y coordinate
 * @param set If true, the construction mark shall be set, otherwise, it shall be removed.
 * @param flattenPositions The positions that need to be flattened to position this building. This value might be null whenever set is false.
 */
void setConstructMarking(int x,int y,boolean set,RelativePoint[] flattenPositions);

Fixed version (ground truth):
/** 
 * Sets or removes a construction mark
 * @param x x coordinate
 * @param y y coordinate
 * @param set If true, the construction mark shall be set, otherwise, it shall be removed.
 * @param flattenPositions The positions that need to be flattened to position this building. This value might be null whenever set is false.
 */
public abstract void setConstructMarking(int x,int y,boolean set,RelativePoint[] flattenPositions);
Program: 56049
Project: 56049
Buggy source:
public static void main(String[] args){
  try {
    final File file=new File(args[0]);
    JSettlersGame game=new JSettlersGame(MapLoader.getLoaderForListedMap(new DirectoryMapLister.ListedMapFile(file,false)),123456L,(byte)0,null);
    game.start();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  try {
    final File file=new File(args[0]);
    JSettlersGame game=new JSettlersGame(MapLoader.getLoaderForListedMap(new DirectoryMapLister.ListedMapFile(file,false)),123456L,(byte)0,null,null);
    game.start();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 56050
Project: 56050
Buggy source:
public void notify(int time);

Fixed version (ground truth):
void notify(int time);