nus-yam/ex-repair huggingface dataset:
Program: 56663
Project: 56663
Buggy source:
@Override public void timerEvent(){
switch (state) {
case NO_ACTION:
    nothingTodoAction();
  if (state == EMovableState.NO_ACTION)   strategy.noActionEvent();
break;
case PUSHED_AND_WAITING:
case WAITING_FOR_FREE_TILE:
IHexMovable movableOnNextTile=grid.getMovable(nextTile);
if (movableOnNextTile == null) {
initGoingToNextTile();
}
 else {
movableOnNextTile.push(this);
break;
}
case EXECUTING_ACTION:
progress+=progressIncrease;
if (progress >= 1) {
state=EMovableState.FINISHED_ACTION;
strategy.actionFinished();
if (state == EMovableState.FINISHED_ACTION) {
System.out.println("String_Node_Str");
strategy.actionFinished();
}
}
break;
case FINISHED_ACTION:
System.out.println("String_Node_Str");
break;
}
}

Fixed version (ground truth):
@Override public void timerEvent(){
switch (state) {
case NO_ACTION:
    nothingTodoAction();
  if (state == EMovableState.NO_ACTION)   strategy.noActionEvent();
break;
case PUSHED_AND_WAITING:
case WAITING_FOR_FREE_TILE:
IHexMovable movableOnNextTile=grid.getMovable(nextPos);
if (movableOnNextTile == null) {
initGoingToNextTile();
}
 else {
movableOnNextTile.push(this);
break;
}
case EXECUTING_ACTION:
progress+=progressIncrease;
if (progress >= 1) {
state=EMovableState.FINISHED_ACTION;
strategy.actionFinished();
if (state == EMovableState.FINISHED_ACTION) {
System.out.println("String_Node_Str");
strategy.actionFinished();
}
}
break;
case FINISHED_ACTION:
System.out.println("String_Node_Str");
break;
}
}
Program: 56664
Project: 56664
Buggy source:
@Override public void kill(){
  MovableTimer.remove(this);
  this.health=0;
  grid.movableLeft(pos,this);
  movablesByID.remove(this.getID());
  grid.getMapObjectsManager().addSelfDeletingMapObject(pos,EMapObjectType.GHOST,1,player);
}

Fixed version (ground truth):
@Override public void kill(){
  MovableTimer.remove(this);
  strategy.killedEvent();
  grid.setMarked(pos,false);
  if (nextPos != null)   grid.setMarked(nextPos,false);
  this.health=0;
  grid.movableLeft(pos,this);
  movablesByID.remove(this.getID());
  grid.getMapObjectsManager().addSelfDeletingMapObject(pos,EMapObjectType.GHOST,1,player);
}
Program: 56665
Project: 56665
Buggy source:
@Override public void push(IHexMovable from){
  if (from == null) {
    if (state == EMovableState.NO_ACTION) {
      goToRandomDirection(null);
    }
    return;
  }
switch (state) {
case NO_ACTION:
    goToRandomDirection(from);
  break;
case WAITING_FOR_FREE_TILE:
if (from.getPos().equals(this.nextTile)) {
  if (from.getNextTile() != null) {
    initGoingToNextTile();
    from.initGoingToNextTile();
  }
}
 else {
  IHexMovable movableOnNextTile=grid.getMovable(nextTile);
  if (movableOnNextTile != null) {
    state=EMovableState.PUSHED_AND_WAITING;
    pushedFrom=from;
    movableOnNextTile.push(this);
    pushedFrom=null;
    if (state == EMovableState.PUSHED_AND_WAITING)     state=EMovableState.WAITING_FOR_FREE_TILE;
  }
}
break;
case PUSHED_AND_WAITING:
if (pushedFrom.getPos().equals(from.getPos())) {
while (from != this) {
from.initGoingToNextTile();
from=from.getPushedFrom();
}
this.initGoingToNextTile();
}
 else {
pushedFrom=from;
}
break;
case EXECUTING_ACTION:
case FINISHED_ACTION:
break;
}
}

Fixed version (ground truth):
@Override public void push(IHexMovable from){
  if (from == null) {
    if (state == EMovableState.NO_ACTION) {
      goToRandomDirection(null);
    }
    return;
  }
switch (state) {
case NO_ACTION:
    goToRandomDirection(from);
  break;
case WAITING_FOR_FREE_TILE:
if (from.getPos().equals(this.nextPos)) {
  if (from.getNextTile() != null) {
    initGoingToNextTile();
    from.initGoingToNextTile();
  }
}
 else {
  IHexMovable movableOnNextTile=grid.getMovable(nextPos);
  if (movableOnNextTile != null) {
    state=EMovableState.PUSHED_AND_WAITING;
    pushedFrom=from;
    movableOnNextTile.push(this);
    pushedFrom=null;
    if (state == EMovableState.PUSHED_AND_WAITING)     state=EMovableState.WAITING_FOR_FREE_TILE;
  }
}
break;
case PUSHED_AND_WAITING:
if (pushedFrom.getPos().equals(from.getPos())) {
while (from != this) {
from.initGoingToNextTile();
from=from.getPushedFrom();
}
this.initGoingToNextTile();
}
 else {
pushedFrom=from;
}
break;
case EXECUTING_ACTION:
case FINISHED_ACTION:
break;
}
}
Program: 56666
Project: 56666
Buggy source:
@Override public void initGoingToNextTile(){
  grid.movableLeft(pos,this);
  grid.movableEntered(this.nextTile,this);
  this.pos=this.nextTile;
  this.nextTile=null;
  this.progress=0;
  this.action=EAction.WALKING;
  this.state=EMovableState.EXECUTING_ACTION;
  this.progressIncrease=getProgressIncrease(Constants.MOVABLE_STEP_DURATION);
  isRightstep=!isRightstep;
}

Fixed version (ground truth):
@Override public void initGoingToNextTile(){
  grid.movableLeft(pos,this);
  grid.movableEntered(this.nextPos,this);
  this.pos=this.nextPos;
  this.nextPos=null;
  this.progress=0;
  this.action=EAction.WALKING;
  this.state=EMovableState.EXECUTING_ACTION;
  this.progressIncrease=getProgressIncrease(Constants.MOVABLE_STEP_DURATION);
  isRightstep=!isRightstep;
}
Program: 56667
Project: 56667
Buggy source:
@Override public ISPosition2D getNextTile(){
  return nextTile;
}

Fixed version (ground truth):
@Override public ISPosition2D getNextTile(){
  return nextPos;
}
Program: 56668
Project: 56668
Buggy source:
@Override public void leaveBlockedPosition(){
  calculateDijkstraPath(super.getPos(),(short)200,ESearchType.NON_BLOCKED_OR_PROTECTED);
}

Fixed version (ground truth):
@Override protected void leaveBlockedPosition(){
  calculateDijkstraPath(super.getPos(),(short)200,ESearchType.NON_BLOCKED_OR_PROTECTED);
}
Program: 56669
Project: 56669
Buggy source:
private void checkForEnemies(){
  if (enemyPos != null || delayCtr > Constants.MOVABLE_INTERRUPTS_PER_SECOND * 2) {
    delayCtr=0;
    Path path=super.getGrid().getDijkstra().find(this,super.getPos().getX(),super.getPos().getY(),(short)1,getSearchRadius(),ESearchType.ENEMY);
    if (path != null)     enemyPos=path.getLastTile();
 else     enemyPos=null;
  }
 else {
    delayCtr++;
    enemyPos=null;
  }
}

Fixed version (ground truth):
private void checkForEnemies(){
  if (enemyPos != null || delayCtr > Constants.MOVABLE_INTERRUPTS_PER_SECOND * 2) {
    delayCtr=0;
    Path path=super.getGrid().getDijkstra().find(this,super.getPos().getX(),super.getPos().getY(),(short)1,getSearchRadius(),ESearchType.ENEMY);
    if (path != null)     enemyPos=path.getTargetPos();
 else     enemyPos=null;
  }
 else {
    delayCtr++;
    enemyPos=null;
  }
}
Program: 56670
Project: 56670
Buggy source:
@Override protected void setCalculatedPath(Path path){
  super.getGrid().setMarked(super.getPos(),false);
  super.setCalculatedPath(path);
}

Fixed version (ground truth):
@Override protected void setCalculatedPath(Path path){
  super.getGrid().setMarked(path.getTargetPos(),false);
  super.setCalculatedPath(path);
}
Program: 56671
Project: 56671
Buggy source:
@Override protected void setCalculatedPath(Path path){
  if (currentJob != null && (currentJob.getType() == EBuildingJobType.PRE_SEARCH || currentJob.getType() == EBuildingJobType.PRE_SEARCH_IN_AREA)) {
    this.path=path;
    super.getGrid().setMarked(path.getLastTile(),true);
    jobFinished();
  }
 else {
    super.setCalculatedPath(path);
  }
}

Fixed version (ground truth):
@Override protected void setCalculatedPath(Path path){
  if (currentJob != null && (currentJob.getType() == EBuildingJobType.PRE_SEARCH || currentJob.getType() == EBuildingJobType.PRE_SEARCH_IN_AREA)) {
    this.path=path;
    super.getGrid().setMarked(path.getTargetPos(),true);
    jobFinished();
  }
 else {
    super.setCalculatedPath(path);
  }
}
Program: 56672
Project: 56672
Buggy source:
private void rebuildAll(byte[][] buffer){
  CircleDrawer drawer=new CircleDrawer(buffer){
    @Override protected int convertY(    int mapy){
      if (mapy < map.getHeight()) {
        return mapy;
      }
 else {
        return -1;
      }
    }
  }
;
  for (int x=0; x < map.getWidth(); x++) {
    for (int y=0; y < map.getWidth(); y++) {
      buffer[x][y]=dimDown(buffer[x][y]);
    }
  }
  for (int x=0; x < map.getWidth(); x++) {
    for (int y=0; y < map.getWidth(); y++) {
      int distance=getViewDistanceForPosition(x,y);
      if (distance > 0) {
        drawer.drawCircleToBuffer(x,y,distance);
      }
    }
  }
}

Fixed version (ground truth):
private void rebuildAll(byte[][] buffer){
  CircleDrawer drawer=new CircleDrawer(buffer){
    @Override protected int convertY(    int mapy){
      if (mapy < map.getHeight()) {
        return mapy;
      }
 else {
        return -1;
      }
    }
  }
;
  for (int x=0; x < map.getWidth(); x++) {
    for (int y=0; y < map.getHeight(); y++) {
      buffer[x][y]=dimDown(buffer[x][y]);
    }
  }
  for (int x=0; x < map.getWidth(); x++) {
    for (int y=0; y < map.getHeight(); y++) {
      int distance=getViewDistanceForPosition(x,y);
      if (distance > 0) {
        drawer.drawCircleToBuffer(x,y,distance);
      }
    }
  }
}
Program: 56673
Project: 56673
Buggy source:
/** 
 * This method checks if one of the neighbors of the given position is from the same player to find a matching partition.<br> If multiple neighbors are from the same player but have different partitions, a merge of the partitions is done.
 * @param changedPosition position that needs to get a new partition
 * @param newPlayer player that is now occupying the position
 */
private void addToNewPartiton(final short x,final short y,final byte newPlayer){
  short newPartition=-1;
  for (  ISPosition2D currPos : new MapNeighboursArea(x,y)) {
    if (map.getPlayerAt(currPos) == newPlayer && !this.map.isBlockedForPeople(currPos.getX(),currPos.getY())) {
      if (newPartition == -1) {
        newPartition=map.getPartition(currPos);
        map.setPartition(x,y,newPartition);
        if (this.map.isBlockedForPeople(x,y)) {
          break;
        }
      }
 else {
        if (map.getPartition(currPos) != newPartition) {
          newPartition=map.mergePartitions(currPos.getX(),currPos.getY(),x,y);
        }
      }
    }
  }
  if (newPartition == -1) {
    map.createPartition(x,y,newPlayer);
  }
}

Fixed version (ground truth):
/** 
 * This method checks if one of the neighbors of the given position is from the same player to find a matching partition.<br> If multiple neighbors are from the same player but have different partitions, a merge of the partitions is done.
 * @param changedPosition position that needs to get a new partition
 * @param newPlayer player that is now occupying the position
 */
private void addToNewPartiton(final short x,final short y,final byte newPlayer){
  short newPartition=-1;
  for (  ISPosition2D currPos : new MapNeighboursArea(x,y)) {
    if (map.getPlayerAt(currPos) == newPlayer) {
      if (newPartition == -1) {
        newPartition=map.getPartition(currPos);
        map.setPartition(x,y,newPartition);
        if (this.map.isBlockedForPeople(x,y)) {
          break;
        }
      }
 else       if (!this.map.isBlockedForPeople(currPos.getX(),currPos.getY())) {
        if (map.getPartition(currPos) != newPartition) {
          newPartition=map.mergePartitions(currPos.getX(),currPos.getY(),x,y);
        }
      }
    }
  }
  if (newPartition == -1) {
    map.createPartition(x,y,newPlayer);
  }
}
Program: 56674
Project: 56674
Buggy source:
@Override public float getCost(short sx,short sy,short tx,short ty){
  return Constants.TILE_PATHFINDER_COST;
}

Fixed version (ground truth):
@Override public float getCost(short sx,short sy,short tx,short ty){
  return Constants.TILE_PATHFINDER_COST * (blockedGrid.isProtected(sx,sy) ? 1.7f : 1);
}
Program: 56675
Project: 56675
Buggy source:
@Override public Color getDebugColorAt(int x,int y){
  return blockedGrid.isBlocked((short)x,(short)y) ? new Color(0,0,0,1) : (blockedGrid.isProtected((short)x,(short)y) ? new Color(0,0,1,1) : null);
}

Fixed version (ground truth):
@Override public Color getDebugColorAt(int x,int y){
  return debugColors[x][y];
}
Program: 56676
Project: 56676
Buggy source:
@Override public void leaveBlockedPosition(){
  calculateDijkstraPath(super.getPos(),(short)200,ESearchType.NON_BLOCKED);
}

Fixed version (ground truth):
@Override public void leaveBlockedPosition(){
  calculateDijkstraPath(super.getPos(),(short)200,ESearchType.NON_BLOCKED_OR_PROTECTED);
}
Program: 56677
Project: 56677
Buggy source:
/** 
 * This method checks if one of the neighbors of the given position is from the same player to find a matching partition.<br> If multiple neighbors are from the same player but have different partitions, a merge of the partitions is done.
 * @param changedPosition position that needs to get a new partition
 * @param newPlayer player that is now occupying the position
 */
private void addToNewPartiton(final short x,final short y,final byte newPlayer){
  short newPartition=-1;
  for (  ISPosition2D currPos : new MapNeighboursArea(x,y)) {
    if (map.getPlayerAt(currPos) == newPlayer) {
      if (newPartition == -1) {
        newPartition=map.getPartition(currPos);
        map.setPartition(x,y,newPartition);
        if (this.map.isBlockedForPeople(x,y)) {
          break;
        }
      }
 else       if (!this.map.isBlockedForPeople(currPos.getX(),currPos.getY())) {
        if (map.getPartition(currPos) != newPartition) {
          newPartition=map.mergePartitions(currPos.getX(),currPos.getY(),x,y);
        }
      }
    }
  }
  if (newPartition == -1) {
    map.createPartition(x,y,newPlayer);
  }
}

Fixed version (ground truth):
/** 
 * This method checks if one of the neighbors of the given position is from the same player to find a matching partition.<br> If multiple neighbors are from the same player but have different partitions, a merge of the partitions is done.
 * @param changedPosition position that needs to get a new partition
 * @param newPlayer player that is now occupying the position
 */
private void addToNewPartiton(final short x,final short y,final byte newPlayer){
  short newPartition=-1;
  for (  ISPosition2D currPos : new MapNeighboursArea(x,y)) {
    if (grid.getPlayerAt(currPos) == newPlayer) {
      if (newPartition == -1) {
        newPartition=grid.getPartition(currPos);
        grid.setPartition(x,y,newPartition);
        if (this.grid.isBlockedForPeople(x,y)) {
          break;
        }
      }
 else       if (!this.grid.isBlockedForPeople(currPos.getX(),currPos.getY())) {
        if (grid.getPartition(currPos) != newPartition) {
          newPartition=grid.mergePartitions(currPos.getX(),currPos.getY(),x,y);
        }
      }
    }
  }
  if (newPartition == -1) {
    grid.createPartition(x,y,newPlayer);
  }
}
Program: 56679
Project: 56679
Buggy source:
/** 
 * Constructor of   {@link PartitionsAlgorithm}.
 * @param partitionsMap The  {@link PartitionsAlgorithm} is operating on this map.
 * @param aStarMap This is the map the AStar operates on
 */
public PartitionsAlgorithm(final IPartionsAlgorithmMap partitionsMap,final IAStarPathMap aStarMap){
  this.map=partitionsMap;
  this.aStar=new HexAStar(aStarMap);
  this.aStarPathable=new AStarPathable();
}

Fixed version (ground truth):
/** 
 * Constructor of   {@link PartitionsAlgorithm}.
 * @param partitionsMap The  {@link PartitionsAlgorithm} is operating on this map.
 * @param aStarMap This is the map the AStar operates on
 */
public PartitionsAlgorithm(final IPartionsAlgorithmMap partitionsMap,final IAStarPathMap aStarMap){
  this.grid=partitionsMap;
  this.aStar=new HexAStar(aStarMap);
  this.aStarPathable=new AStarPathable();
}
Program: 56680
Project: 56680
Buggy source:
/** 
 * Calculates the new partition for the given position.<br> It also merges or divides partitions if it became necessary by the given change to position.
 * @param x x coordinate
 * @param y y coordinate
 * @param newPlayer the player that is now occupying the given position.
 */
public void calculateNewPartition(short x,short y,byte newPlayer){
  short oldPartition=map.getPartition(x,y);
  if (newPlayer != -1) {
    addToNewPartiton(x,y,newPlayer);
  }
  if (oldPartition != -1) {
    removeFromOldPartition(x,y,oldPartition);
  }
}

Fixed version (ground truth):
/** 
 * Calculates the new partition for the given position.<br> It also merges or divides partitions if it became necessary by the given change to position.
 * @param x x coordinate
 * @param y y coordinate
 * @param newPlayer the player that is now occupying the given position.
 */
public void calculateNewPartition(short x,short y,byte newPlayer){
  short oldPartition=grid.getPartition(x,y);
  if (newPlayer != -1) {
    addToNewPartiton(x,y,newPlayer);
  }
  if (oldPartition != -1) {
    removeFromOldPartition(x,y,oldPartition);
  }
}
Program: 56681
Project: 56681
Buggy source:
private void nothingTodoAction(){
  if (RandomSingleton.nextF() < Constants.MOVABLE_TURN_PROBABILITY) {
    this.setDirection(direction.getNeighbor(RandomSingleton.getInt(-1,1)));
  }
 else   if (RandomSingleton.nextF() < Constants.MOVABLE_NO_ACTION_STEP_PROBABILITY) {
    for (    EDirection curr : EDirection.values()) {
      IHexMovable movable=grid.getMovable(curr.getNextHexPoint(pos));
      if (movable != null) {
        movable.push(this);
      }
    }
  }
}

Fixed version (ground truth):
private void nothingTodoAction(){
  if (RandomSingleton.nextF() < Constants.MOVABLE_TURN_PROBABILITY) {
    this.setDirection(direction.getNeighbor(RandomSingleton.getInt(-1,1)));
  }
 else   if (RandomSingleton.nextF() < Constants.MOVABLE_NO_ACTION_STEP_PROBABILITY) {
    for (    EDirection curr : EDirection.values()) {
      ISPosition2D point=curr.getNextHexPoint(pos);
      if (grid.isInBounds(point)) {
        IHexMovable movable=grid.getMovable(point);
        if (movable != null) {
          movable.push(this);
        }
      }
    }
  }
}
Program: 56682
Project: 56682
Buggy source:
protected void convertTo(EMovableType movableType){
  this.movable.setStrategy(getTypeStrategy(grid,movableType,movable));
}

Fixed version (ground truth):
protected void convertTo(EMovableType movableType){
  this.movable.setMaterial(EMaterialType.NO_MATERIAL);
  this.movable.setStrategy(getTypeStrategy(grid,movableType,movable));
}
Program: 56683
Project: 56683
Buggy source:
public synchronized Path find(final IPathCalculateable requester,final short cX,final short cY,final short minRadius,final short maxRadius,final ESearchType type){
  if (!isInBounds(cX,cY)) {
    throw new InvalidStartPositionException(cX,cY);
  }
  for (short radius=minRadius; radius < maxRadius; radius++) {
    short x=cX, y=(short)(cY + radius);
    for (byte direction=0; direction < 6; direction++) {
      byte dx=directionIncreaseX[direction];
      byte dy=directionIncreaseY[direction];
      for (short length=0; length < radius; length++) {
        x+=dx;
        y+=dy;
        if (isInBounds(x,y)) {
          map.setDijkstraSearched(x,y);
          if (map.fitsSearchType(x,y,type,requester)) {
            Path path=findPath(requester,x,y);
            if (path != null)             return path;
          }
        }
      }
    }
  }
  return null;
}

Fixed version (ground truth):
public synchronized Path find(final IPathCalculateable requester,final short cX,final short cY,final short minRadius,final short maxRadius,final ESearchType type){
  if (!isInBounds(cX,cY)) {
    throw new InvalidStartPositionException(cX,cY);
  }
  for (short radius=minRadius; radius < maxRadius; radius++) {
    short x=cX, y=(short)(cY - radius);
    for (byte direction=0; direction < 6; direction++) {
      byte dx=directionIncreaseX[direction];
      byte dy=directionIncreaseY[direction];
      for (short length=0; length < radius; length++) {
        x+=dx;
        y+=dy;
        if (isInBounds(x,y)) {
          map.setDijkstraSearched(x,y);
          if (map.fitsSearchType(x,y,type,requester)) {
            Path path=findPath(requester,x,y);
            if (path != null)             return path;
          }
        }
      }
    }
  }
  return null;
}
Program: 56684
Project: 56684
Buggy source:
@Override public Color getDebugColorAt(int x,int y){
  return new Color(partitionsGrid.getPartition((short)x,(short)y) * 0.2f,0,0,1);
}

Fixed version (ground truth):
@Override public Color getDebugColorAt(int x,int y){
  return debugColors[x][y];
}
Program: 56685
Project: 56685
Buggy source:
@Override public Color getDebugColorAt(int x,int y){
  return debugColors[x][y];
}

Fixed version (ground truth):
@Override public Color getDebugColorAt(int x,int y){
  return new Color(partitionsGrid.getPartition((short)x,(short)y) * 0.2f,0,0,1);
}
Program: 56686
Project: 56686
Buggy source:
@Override public void setPartition(ISPosition2D position,short newPartition){
  Partition newPartitionObject=getPartitionObject(newPartition);
  getPartitionObject(position.getX(),position.getY()).removePositionTo(position,newPartitionObject);
  this.partitions[position.getX()][position.getY()]=newPartition;
}

Fixed version (ground truth):
@Override public void setPartition(ISPosition2D position,short newPartition){
  Partition newPartitionObject=getPartitionObject(newPartition);
  short oldPartition=getPartition(position);
  getPartitionObject(position.getX(),position.getY()).removePositionTo(position,newPartitionObject);
  this.partitions[position.getX()][position.getY()]=newPartition;
}
Program: 56687
Project: 56687
Buggy source:
private void relabelPartition(short inX,short inY,short oldPartition,short newPartition){
  final short MAX_LENGTH=1000;
  final short[] pointsBuffer=new short[MAX_LENGTH];
  pointsBuffer[0]=inX;
  pointsBuffer[1]=inY;
  short length=2;
  while (length > 0) {
    short y=pointsBuffer[--length];
    short x=pointsBuffer[--length];
    setPartition(new ShortPoint2D(x,y),newPartition);
    for (byte i=0; i < 12; i+=2) {
      short currX=(short)(x + neighborhoodMatrix[i]);
      short currY=(short)(y + neighborhoodMatrix[i + 1]);
      if (isInBounds(currX,currY) && partitions[currX][currY] == oldPartition) {
        if (length < MAX_LENGTH) {
          pointsBuffer[length++]=currX;
          pointsBuffer[length++]=currY;
        }
 else {
          relabelPartition(currX,currY,oldPartition,newPartition);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void relabelPartition(short inX,short inY,short oldPartition,short newPartition){
  final short MAX_LENGTH=1000;
  final short[] pointsBuffer=new short[MAX_LENGTH];
  pointsBuffer[0]=inX;
  pointsBuffer[1]=inY;
  short length=2;
  while (length > 0) {
    short y=pointsBuffer[--length];
    short x=pointsBuffer[--length];
    if (partitions[x][y] != oldPartition) {
      continue;
    }
    setPartition(new ShortPoint2D(x,y),newPartition);
    for (byte i=0; i < 12; i+=2) {
      short currX=(short)(x + neighborhoodMatrix[i]);
      short currY=(short)(y + neighborhoodMatrix[i + 1]);
      if (isInBounds(currX,currY) && partitions[currX][currY] == oldPartition) {
        if (length < MAX_LENGTH) {
          pointsBuffer[length++]=currX;
          pointsBuffer[length++]=currY;
        }
 else {
          relabelPartition(currX,currY,oldPartition,newPartition);
        }
      }
    }
  }
}
Program: 56688
Project: 56688
Buggy source:
@Override public void run(){
  while (!canceled) {
    if (!positionsQueue.isEmpty()) {
      ISPosition2D position=positionsQueue.poll();
      byte player=grid.getPlayer(position.getX(),position.getY());
      boolean isBorder=false;
      for (      EDirection currDir : EDirection.values()) {
        short currNeighborX=currDir.getNextTileX(position.getX());
        short currNeighborY=currDir.getNextTileY(position.getY());
        if (!grid.isInBounds(currNeighborX,currNeighborY)) {
          continue;
        }
        byte neighborPlayer=grid.getPlayer(currNeighborX,currNeighborY);
        boolean neighborIsBorder=false;
        if (neighborPlayer >= 0) {
          if (neighborPlayer != player) {
            isBorder=true;
          }
          for (          EDirection currNeighborDir : EDirection.values()) {
            short nextX=currNeighborDir.getNextTileX(currNeighborX);
            short nextY=currNeighborDir.getNextTileY(currNeighborY);
            if (grid.isInBounds(nextX,nextY) && grid.getPlayer(nextX,nextY) != neighborPlayer) {
              neighborIsBorder=true;
              break;
            }
          }
        }
        grid.setBorder(currNeighborX,currNeighborY,neighborIsBorder);
      }
      grid.setBorder(position.getX(),position.getY(),isBorder && player >= 0);
    }
 else {
      try {
        Thread.sleep(50);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void run(){
  while (!canceled) {
    if (!positionsQueue.isEmpty()) {
      ISPosition2D position=positionsQueue.poll();
      byte player=grid.getPlayer(position.getX(),position.getY());
      boolean isBorder=false;
      for (      EDirection currDir : EDirection.values()) {
        short currNeighborX=currDir.getNextTileX(position.getX());
        short currNeighborY=currDir.getNextTileY(position.getY());
        if (!grid.isInBounds(currNeighborX,currNeighborY)) {
          continue;
        }
        byte neighborPlayer=grid.getPlayer(currNeighborX,currNeighborY);
        boolean neighborIsBorder=false;
        if (neighborPlayer != player) {
          isBorder=true;
        }
        if (neighborPlayer >= 0) {
          for (          EDirection currNeighborDir : EDirection.values()) {
            short nextX=currNeighborDir.getNextTileX(currNeighborX);
            short nextY=currNeighborDir.getNextTileY(currNeighborY);
            if (grid.isInBounds(nextX,nextY) && grid.getPlayer(nextX,nextY) != neighborPlayer) {
              neighborIsBorder=true;
              break;
            }
          }
        }
        grid.setBorder(currNeighborX,currNeighborY,neighborIsBorder);
      }
      grid.setBorder(position.getX(),position.getY(),isBorder && player >= 0);
    }
 else {
      try {
        Thread.sleep(50);
      }
 catch (      InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
Program: 56689
Project: 56689
Buggy source:
@Override public void keyPressed(KeyEvent e){
  startKeyEvent(KeyEvent.getKeyText(e.getKeyCode()));
}

Fixed version (ground truth):
@Override public void keyPressed(KeyEvent e){
  String text=KeyEvent.getKeyText(e.getKeyCode());
  if (text == null || text.length() != 1) {
switch (e.getKeyCode()) {
case KeyEvent.VK_LEFT:
      text="String_Node_Str";
    break;
case KeyEvent.VK_RIGHT:
  text="String_Node_Str";
break;
case KeyEvent.VK_DOWN:
text="String_Node_Str";
break;
case KeyEvent.VK_UP:
text="String_Node_Str";
break;
case KeyEvent.VK_PAUSE:
text="String_Node_Str";
break;
default :
text="String_Node_Str";
}
}
startKeyEvent(text);
}
Program: 56690
Project: 56690
Buggy source:
protected void endKeyEvent(){
  if (ongoingKeyEvent != null) {
    ongoingKeyEvent.released();
    ongoingKeyEvent=null;
  }
}

Fixed version (ground truth):
protected void endKeyEvent(){
  if (ongoingKeyEvent != null) {
    boolean replaced=replaceKeyEvent(ongoingKeyEvent);
    if (replaced) {
      ongoingKeyEvent.aborted();
      ongoingKeyEvent=null;
    }
 else {
      ongoingKeyEvent.released();
      ongoingKeyEvent=null;
    }
  }
}
Program: 56691
Project: 56691
Buggy source:
@Override public UIPoint getPanDistance(){
  UIPoint real=(this.baseEvent).getPanDistance();
  return new UIPoint(real.getX() - this.displacement.getX(),real.getY() - this.displacement.getY());
}

Fixed version (ground truth):
@Override public UIPoint getPanDistance(){
  UIPoint real=(this.baseEvent).getPanDistance();
  return real;
}
Program: 56692
Project: 56692
Buggy source:
private void drawWithConstructionMask(MapDrawContext context,float maskState,Image image){
  int tiles=6;
  float toplineBottom=maskState;
  float toplineTop=Math.min(1,toplineBottom + .1f);
  float[] tris=new float[(tiles + 2) * 3 * 5];
  addToArray(tris,0,0,0,image);
  addToArray(tris,1,1,0,image);
  addToArray(tris,2,0,toplineBottom,image);
  addToArray(tris,3,1,0,image);
  addToArray(tris,2,1,toplineBottom,image);
  addToArray(tris,2,0,toplineBottom,image);
  for (int i=0; i < tiles; i++) {
    addToArray(tris,6 + i * 3,1.0f / tiles * i,toplineBottom,image);
    addToArray(tris,7 + i * 3,1.0f / tiles * (i + 1),toplineBottom,image);
    addToArray(tris,8 + i * 3,1.0f / tiles * (i + .5f),toplineTop,image);
  }
  GLDrawContext gl=context.getGl();
  gl.drawTrianglesWithTexture(image.getTextureIndex(gl),tris);
}

Fixed version (ground truth):
private void drawWithConstructionMask(MapDrawContext context,float maskState,Image image){
  int tiles=6;
  float toplineBottom=maskState;
  float toplineTop=Math.min(1,toplineBottom + .1f);
  float[] tris=new float[(tiles + 2) * 3 * 5];
  addToArray(tris,0,0,0,image);
  addToArray(tris,1,1,0,image);
  addToArray(tris,2,0,toplineBottom,image);
  addToArray(tris,3,1,0,image);
  addToArray(tris,4,1,toplineBottom,image);
  addToArray(tris,5,0,toplineBottom,image);
  for (int i=0; i < tiles; i++) {
    addToArray(tris,6 + i * 3,1.0f / tiles * i,toplineBottom,image);
    addToArray(tris,7 + i * 3,1.0f / tiles * (i + 1),toplineBottom,image);
    addToArray(tris,8 + i * 3,1.0f / tiles * (i + .5f),toplineTop,image);
  }
  GLDrawContext gl=context.getGl();
  gl.drawTrianglesWithTexture(image.getTextureIndex(gl),tris);
}
Program: 56693
Project: 56693
Buggy source:
protected void changeMousePosition(Point position){
  mousePosition=position;
}

Fixed version (ground truth):
protected void changeMousePosition(Point position){
  mousePosition=position;
  if (controls.containsPoint(position)) {
    tooltipString=controls.getDescriptionFor(position);
    if (tooltipString == null) {
      tooltipString="String_Node_Str";
    }
  }
 else {
    tooltipString="String_Node_Str";
  }
}
Program: 56694
Project: 56694
Buggy source:
@Override public void handleEvent(GOEvent event){
  if (event instanceof GOPanEvent) {
    event.setHandler(new PanHandler(this.context.getScreen()));
  }
 else   if (event instanceof GOCommandEvent) {
    GOCommandEvent commandEvent=(GOCommandEvent)event;
    Action action=handleCommand(commandEvent);
    if (action != null) {
      fireAction(event,action);
    }
  }
 else   if (event instanceof GOKeyEvent) {
    Action actionForKeyboard=getActionForKeyboard(((GOKeyEvent)event).getKeyCode());
    if (actionForKeyboard != null) {
      fireAction(event,actionForKeyboard);
    }
  }
 else   if (event instanceof GODrawEvent) {
    GODrawEvent drawEvent=(GODrawEvent)event;
    handleDraw(drawEvent);
  }
 else   if (event instanceof GOHoverEvent) {
    GOHoverEvent hoverEvent=(GOHoverEvent)event;
    handleHover(hoverEvent);
  }
}

Fixed version (ground truth):
@Override public void handleEvent(GOEvent event){
  if (event instanceof GOPanEvent) {
    event.setHandler(new PanHandler(this.context.getScreen()));
  }
 else   if (event instanceof GOCommandEvent) {
    GOCommandEvent commandEvent=(GOCommandEvent)event;
    Action action=handleCommand(commandEvent);
    if (action != null) {
      fireActionEvent(event,action);
    }
  }
 else   if (event instanceof GOKeyEvent) {
    Action actionForKeyboard=getActionForKeyboard(((GOKeyEvent)event).getKeyCode());
    if (actionForKeyboard != null) {
      fireActionEvent(event,actionForKeyboard);
    }
  }
 else   if (event instanceof GODrawEvent) {
    GODrawEvent drawEvent=(GODrawEvent)event;
    handleDraw(drawEvent);
  }
 else   if (event instanceof GOHoverEvent) {
    GOHoverEvent hoverEvent=(GOHoverEvent)event;
    handleHover(hoverEvent);
  }
}
Program: 56695
Project: 56695
Buggy source:
@Override public void drawContent(GLDrawContext gl,int newWidth,int newHeight){
  if (newWidth != this.context.getScreen().getWidth() || newHeight != this.context.getScreen().getHeight()) {
    resizeTo(newWidth,newHeight);
  }
  IntRectangle newScreen=context.getScreen().getPosition();
  if (!newScreen.equals(oldScreen)) {
    getInterfaceConnector().fireAction(new ScreenChangeAction(context.getScreenArea()));
  }
  oldScreen=newScreen;
  this.context.begin(gl);
  this.context.debugTime("String_Node_Str");
  this.objectDrawer.increaseAnimationStep();
  drawBackground();
  this.context.debugTime("String_Node_Str");
  drawMain();
  this.context.end();
  gl.glTranslatef(0,0,.5f);
  drawSelectionHint(gl);
  controls.drawAt(gl);
  this.context.debugTime("String_Node_Str");
  drawFramerate();
  drawTooltip();
}

Fixed version (ground truth):
@Override public void drawContent(GLDrawContext gl,int newWidth,int newHeight){
  adaptScreenSize(newWidth,newHeight);
  this.objectDrawer.increaseAnimationStep();
  this.context.begin(gl);
  drawBackground();
  drawMain();
  this.context.end();
  gl.glTranslatef(0,0,.5f);
  drawSelectionHint(gl);
  controls.drawAt(gl);
  this.context.debugTime("String_Node_Str");
  drawFramerate();
  drawTooltip();
}
Program: 56696
Project: 56696
Buggy source:
/** 
 * Creates a new map content for the given map.
 * @param map The map.
 */
public MapContent(IGraphicsGrid map){
  this.map=map;
  this.context=new MapDrawContext(map);
  controls=new OriginalControls(map);
  this.connector=new MapInterfaceConnector(this);
}

Fixed version (ground truth):
/** 
 * Creates a new map content for the given map.
 * @param map The map.
 */
public MapContent(IGraphicsGrid map){
  this.map=map;
  this.context=new MapDrawContext(map);
  controls=new OriginalControls(map);
  this.connector=new MapInterfaceConnector(this);
  this.connector.addListener(this);
}
Program: 56698
Project: 56698
Buggy source:
private Action getActionForKeyboard(int keyCode){
switch (keyCode) {
case KeyEvent.VK_F12:
    return new Action(EActionType.FAST_FORWARD);
case KeyEvent.VK_PAUSE:
case KeyEvent.VK_P:
  return new Action(EActionType.SPEED_TOGGLE_PAUSE);
case KeyEvent.VK_PLUS:
return new Action(EActionType.SPEED_FASTER);
case KeyEvent.VK_MINUS:
return new Action(EActionType.SPEED_SLOWER);
case KeyEvent.VK_SPACE:
return new Action(EActionType.SHOW_SELECTION);
case KeyEvent.VK_D:
return new Action(EActionType.DEBUG_ACTION);
case KeyEvent.VK_S:
return new Action(EActionType.STOP_WORKING);
case KeyEvent.VK_Q:
ENABLE_DEBUG=!ENABLE_DEBUG;
break;
}
return null;
}

Fixed version (ground truth):
private Action getActionForKeyboard(int keyCode){
switch (keyCode) {
case KeyEvent.VK_F12:
    return new Action(EActionType.FAST_FORWARD);
case KeyEvent.VK_PAUSE:
case KeyEvent.VK_P:
  return new Action(EActionType.SPEED_TOGGLE_PAUSE);
case KeyEvent.VK_PLUS:
return new Action(EActionType.SPEED_FASTER);
case KeyEvent.VK_MINUS:
return new Action(EActionType.SPEED_SLOWER);
case KeyEvent.VK_SPACE:
return new Action(EActionType.SHOW_SELECTION);
case KeyEvent.VK_D:
return new Action(EActionType.DEBUG_ACTION);
case KeyEvent.VK_S:
return new Action(EActionType.STOP_WORKING);
case KeyEvent.VK_Q:
return new Action(EActionType.TOGGLE_DEBUG);
}
return null;
}
Program: 56699
Project: 56699
Buggy source:
public OriginalControls(IGraphicsGrid map){
  this.map=map;
  constants=new SmallOriginalConstants();
  uiBase=createInterface();
  mainPanel.useConstants(constants);
}

Fixed version (ground truth):
public OriginalControls(IGraphicsGrid map){
  this.map=map;
  minimap=new Minimap(map);
  constants=new SmallOriginalConstants();
  uiBase=createInterface();
  mainPanel.useConstants(constants);
}
Program: 56700
Project: 56700
Buggy source:
private void drawWithConstructionMask(MapDrawContext context,float maskState,Image image){
  int tiles=6;
  float toplineBottom=maskState;
  float toplineTop=Math.min(1,toplineBottom + .2f * image.getHeight());
  float[] tris=new float[(tiles + 2) * 3 * 5];
  addToArray(tris,0,0,0,image);
  addToArray(tris,1,1,0,image);
  addToArray(tris,2,0,toplineBottom,image);
  addToArray(tris,3,1,0,image);
  addToArray(tris,2,1,toplineBottom,image);
  addToArray(tris,2,0,toplineBottom,image);
  for (int i=0; i < tiles; i++) {
    addToArray(tris,6 + i * 3,1.0f / tiles * i,toplineBottom,image);
    addToArray(tris,7 + i * 3,1.0f / tiles * (i + 1),toplineBottom,image);
    addToArray(tris,8 + i * 3,1.0f / tiles * (i + .5f),toplineTop,image);
  }
  GLDrawContext gl=context.getGl();
  gl.drawTrianglesWithTexture(image.getTextureIndex(gl),tris);
}

Fixed version (ground truth):
private void drawWithConstructionMask(MapDrawContext context,float maskState,Image image){
  int tiles=6;
  float toplineBottom=maskState;
  float toplineTop=Math.min(1,toplineBottom + .1f);
  float[] tris=new float[(tiles + 2) * 3 * 5];
  addToArray(tris,0,0,0,image);
  addToArray(tris,1,1,0,image);
  addToArray(tris,2,0,toplineBottom,image);
  addToArray(tris,3,1,0,image);
  addToArray(tris,2,1,toplineBottom,image);
  addToArray(tris,2,0,toplineBottom,image);
  for (int i=0; i < tiles; i++) {
    addToArray(tris,6 + i * 3,1.0f / tiles * i,toplineBottom,image);
    addToArray(tris,7 + i * 3,1.0f / tiles * (i + 1),toplineBottom,image);
    addToArray(tris,8 + i * 3,1.0f / tiles * (i + .5f),toplineTop,image);
  }
  GLDrawContext gl=context.getGl();
  gl.drawTrianglesWithTexture(image.getTextureIndex(gl),tris);
}
Program: 56701
Project: 56701
Buggy source:
public ConstructMarksThread(IConstructionMarkableMap map,byte player){
  super("String_Node_Str");
  this.map=map;
  this.player=player;
}

Fixed version (ground truth):
public ConstructMarksThread(IConstructionMarkableMap map,byte player){
  super("String_Node_Str");
  this.map=map;
  this.player=player;
  this.start();
}
Program: 56702
Project: 56702
Buggy source:
public void setWorkAreaCenter(ISPosition2D workAreaCenter){
}

Fixed version (ground truth):
public void setWorkAreaCenter(@SuppressWarnings("String_Node_Str") ISPosition2D workAreaCenter){
}
Program: 56703
Project: 56703
Buggy source:
@Override public boolean pushMaterial(ISPosition2D position,EMaterialType materialType){
  if (mapObjectsManager.pushMaterial(position,materialType)) {
    partitionsGrid.pushMaterial(position,materialType);
    return true;
  }
 else   return false;
}

Fixed version (ground truth):
@Override public boolean pushMaterial(ISPosition2D position,EMaterialType materialType,boolean offer){
  if (mapObjectsManager.pushMaterial(position,materialType)) {
    if (offer) {
      partitionsGrid.pushMaterial(position,materialType);
    }
    return true;
  }
 else   return false;
}
Program: 56704
Project: 56704
Buggy source:
public Partition(final byte player){
  this.player=player;
  this.manager=new PartitionManager();
}

Fixed version (ground truth):
public Partition(byte player,int size){
  this(player);
  this.counter=size;
}
Program: 56705
Project: 56705
Buggy source:
public void decrement(){
  counter--;
}

Fixed version (ground truth):
private void decrement(){
  counter--;
}
Program: 56706
Project: 56706
Buggy source:
public void increment(){
  counter++;
}

Fixed version (ground truth):
private void increment(){
  counter++;
}
Program: 56707
Project: 56707
Buggy source:
public void request(ISPosition2D position,EMaterialType materialType,byte priority){
  getPartitionObject(position).request(position,materialType,priority);
}

Fixed version (ground truth):
public void request(ISPosition2D position,EMaterialType materialType,byte priority){
  getPartitionObject(position.getX(),position.getY()).request(position,materialType,priority);
}
Program: 56708
Project: 56708
Buggy source:
public PartitionsGrid(final short width,final short height,IAStarPathMap pathfinderMap){
  this.width=width;
  this.height=height;
  this.partitions=new short[width][height];
  this.player=new byte[width][height];
  this.borders=new boolean[width][height];
  this.partitionsManager=new PartitionsAlgorithm(this,pathfinderMap);
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      this.partitions[x][y]=-1;
      this.player[x][y]=-1;
    }
  }
}

Fixed version (ground truth):
public PartitionsGrid(final short width,final short height,IAStarPathMap pathfinderMap){
  this.width=width;
  this.height=height;
  this.partitions=new short[width][height];
  this.player=new byte[width][height];
  this.borders=new boolean[width][height];
  this.partitionsManager=new PartitionsAlgorithm(this,pathfinderMap);
  this.nullPartition=new Partition((byte)-1,height * width);
  for (short x=0; x < width; x++) {
    for (short y=0; y < height; y++) {
      this.partitions[x][y]=-1;
      this.player[x][y]=-1;
    }
  }
}
Program: 56709
Project: 56709
Buggy source:
public void addJobless(IManageableBearer manageable){
  getPartitionObject(manageable.getPos()).addJobless(manageable);
}

Fixed version (ground truth):
public void addJobless(IManageableBearer manageable){
  getPartitionObject(manageable.getPos().getX(),manageable.getPos().getY()).addJobless(manageable);
}
Program: 56710
Project: 56710
Buggy source:
private Partition getPartitionObject(ISPosition2D pos){
  short partition=getPartition(pos);
  if (partition >= 0)   return this.partitionObjects[partition];
 else   return nullPartition;
}

Fixed version (ground truth):
private Partition getPartitionObject(short partition){
  if (partition >= 0)   return this.partitionObjects[partition];
 else   return nullPartition;
}
Program: 56711
Project: 56711
Buggy source:
private void setPartition(short x,short y,short partition){
  decrement(getPartition(x,y));
  this.partitions[x][y]=partition;
  increment(partition);
}

Fixed version (ground truth):
@Override public void setPartition(ISPosition2D position,short newPartition){
  Partition newPartitionObject=getPartitionObject(newPartition);
  getPartitionObject(position.getX(),position.getY()).removePositionTo(position,newPartitionObject);
  this.partitions[position.getX()][position.getY()]=newPartition;
}
Program: 56712
Project: 56712
Buggy source:
private void relabelPartition(short inX,short inY,short oldPartition,short newPartition){
  final short MAX_LENGTH=1000;
  final short[] points=new short[MAX_LENGTH];
  points[0]=inX;
  points[1]=inY;
  short length=2;
  while (length > 0) {
    short y=points[--length];
    short x=points[--length];
    setPartition(x,y,newPartition);
    for (byte i=0; i < 12; i+=2) {
      short currX=(short)(x + neighborhoodMatrix[i]);
      short currY=(short)(y + neighborhoodMatrix[i + 1]);
      if (isInBounds(currX,currY) && partitions[currX][currY] == oldPartition) {
        if (length < MAX_LENGTH) {
          points[length++]=currX;
          points[length++]=currY;
        }
 else {
          relabelPartition(currX,currY,oldPartition,newPartition);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void relabelPartition(short inX,short inY,short oldPartition,short newPartition){
  final short MAX_LENGTH=1000;
  final short[] pointsBuffer=new short[MAX_LENGTH];
  pointsBuffer[0]=inX;
  pointsBuffer[1]=inY;
  short length=2;
  while (length > 0) {
    short y=pointsBuffer[--length];
    short x=pointsBuffer[--length];
    setPartition(new ShortPoint2D(x,y),newPartition);
    for (byte i=0; i < 12; i+=2) {
      short currX=(short)(x + neighborhoodMatrix[i]);
      short currY=(short)(y + neighborhoodMatrix[i + 1]);
      if (isInBounds(currX,currY) && partitions[currX][currY] == oldPartition) {
        if (length < MAX_LENGTH) {
          pointsBuffer[length++]=currX;
          pointsBuffer[length++]=currY;
        }
 else {
          relabelPartition(currX,currY,oldPartition,newPartition);
        }
      }
    }
  }
}
Program: 56713
Project: 56713
Buggy source:
public boolean pushMaterial(ISPosition2D position,EMaterialType materialType){
  return getPartitionObject(position).pushMaterial(position,materialType);
}

Fixed version (ground truth):
public boolean pushMaterial(ISPosition2D position,EMaterialType materialType){
  return getPartitionObject(position.getX(),position.getY()).pushMaterial(position,materialType);
}
Program: 56714
Project: 56714
Buggy source:
/** 
 * @param position position to be removed from this manager and added to the given manager
 * @param newManager new manager of the given position <br> NOTE: the new manager MUST NOT be null!
 */
public void removePositionTo(IMapArea area,PartitionManager newManager){
  Iterator<Offer> offerIter=offers.iterator();
  while (offerIter.hasNext()) {
    Offer currOffer=offerIter.next();
    if (area.contains(currOffer.position)) {
      newManager.offers.set(currOffer.position,currOffer);
    }
  }
  Iterator<Request> requestIter=requests.iterator();
  while (requestIter.hasNext()) {
    if (area.contains(requestIter.next().position)) {
      requestIter.remove();
    }
  }
}

Fixed version (ground truth):
/** 
 * @param position position to be removed from this manager and added to the given manager
 * @param newManager new manager of the given position <br> NOTE: the new manager MUST NOT be null!
 */
public void removePositionTo(ISPosition2D position,PartitionManager newManager){
  Offer removedOffer=offers.removeObjectAt(position);
  if (removedOffer != null) {
    newManager.offers.set(position,removedOffer);
  }
  java.util.Iterator<Request> requestIter=requests.iterator();
  while (requestIter.hasNext()) {
    if (requestIter.next().position.equals(position)) {
      requestIter.remove();
    }
  }
}
Program: 56715
Project: 56715
Buggy source:
/** 
 * Places the given material at the given position.
 * @param position position the material should be placed
 * @param materialType {@link EMaterialType} of the material to be placed
 * @return true if the material had been placed,<br>false otherwise.
 */
boolean pushMaterial(ISPosition2D position,EMaterialType materialType);

Fixed version (ground truth):
/** 
 * Places the given material at the given position.
 * @param position position the material should be placed
 * @param materialType {@link EMaterialType} of the material to be placed
 * @param offer if true, the pushed material will be offered to the manager<br> if false it won't be offered to the manager
 * @return true if the material had been placed,<br>false otherwise.
 */
boolean pushMaterial(ISPosition2D position,EMaterialType materialType,boolean offer);
Program: 56716
Project: 56716
Buggy source:
@Override protected void pathRequestFailed(){
switch (state) {
case CARRY_TAKE:
    super.getGrid().pushMaterial(super.getPos(),materialType);
case CARRY_DROP:
}
}

Fixed version (ground truth):
@Override protected void pathRequestFailed(){
switch (state) {
case CARRY_TAKE:
    super.getGrid().pushMaterial(super.getPos(),materialType,true);
case CARRY_DROP:
}
}
Program: 56717
Project: 56717
Buggy source:
@Override protected boolean actionFinished(){
  if (!super.actionFinished()) {
switch (state) {
case CARRY_TAKE:
      super.getGrid().popMaterial(super.getPos(),materialType);
    super.calculatePathTo(request);
  state=EBearerState.CARRY_DROP;
break;
case CARRY_DROP:
super.getGrid().pushMaterial(super.getPos(),materialType);
this.state=EBearerState.JOBLESS;
super.setAction(EAction.NO_ACTION,-1);
super.setMaterial(EMaterialType.NO_MATERIAL);
super.getGrid().addJobless(this);
break;
case CARRY_INIT:
super.setAction(EAction.NO_ACTION,-1);
default :
super.setAction(EAction.NO_ACTION,-1);
}
}
return true;
}

Fixed version (ground truth):
@Override protected boolean actionFinished(){
  if (!super.actionFinished()) {
switch (state) {
case CARRY_TAKE:
      super.getGrid().popMaterial(super.getPos(),materialType);
    super.calculatePathTo(request);
  state=EBearerState.CARRY_DROP;
break;
case CARRY_DROP:
super.getGrid().pushMaterial(super.getPos(),materialType,false);
this.state=EBearerState.JOBLESS;
super.setAction(EAction.NO_ACTION,-1);
super.setMaterial(EMaterialType.NO_MATERIAL);
super.getGrid().addJobless(this);
break;
case CARRY_INIT:
super.setAction(EAction.NO_ACTION,-1);
default :
super.setAction(EAction.NO_ACTION,-1);
}
}
return true;
}
Program: 56718
Project: 56718
Buggy source:
@Override protected boolean actionFinished(){
  if (!super.actionFinished()) {
    if (currentJob != null) {
      boolean success=true;
      if (currentJob.getType() == EBuildingJobType.DROP && currentJob.getMaterial() != EMaterialType.NO_MATERIAL) {
        success=super.getGrid().pushMaterial(super.getPos(),currentJob.getMaterial());
      }
      if (success) {
        jobFinished();
      }
 else {
        jobFailed();
      }
    }
 else {
      super.setAction(EAction.NO_ACTION,-1);
    }
  }
  return true;
}

Fixed version (ground truth):
@Override protected boolean actionFinished(){
  if (!super.actionFinished()) {
    if (currentJob != null) {
      boolean success=true;
      if (currentJob.getType() == EBuildingJobType.DROP && currentJob.getMaterial() != EMaterialType.NO_MATERIAL) {
        success=super.getGrid().pushMaterial(super.getPos(),currentJob.getMaterial(),true);
      }
      if (success) {
        jobFinished();
      }
 else {
        jobFailed();
      }
    }
 else {
      super.setAction(EAction.NO_ACTION,-1);
    }
  }
  return true;
}