nus-yam/ex-repair huggingface dataset:
Program: 55891
Project: 55891
Buggy source:
public short[] getPreviewImage(int width,int height){
  if ((previewWidth == width) && (previewHeight == height) && (previewImage != null)) {
    return previewImage;
  }
  short[] outImg=new short[width * height];
  MapResourceInfo filePart=findResource(OriginalMapFileDataStructs.EMapFilePartType.PREVIEW);
  if (filePart == null)   return outImg;
  if (filePart.size < 4)   return outImg;
  if (!doDecrypt(filePart))   return outImg;
  int pos=filePart.offset;
  int wh=readBEWordFrom(pos);
  pos+=2;
  int unknown=readBEWordFrom(pos);
  pos+=2;
  float scaleX=wh / width;
  float scaleY=wh / height;
  int outIndex=0;
  int offset=pos;
  for (int y=0; y < height; y++) {
    int srcRow=offset + ((int)(Math.floor(scaleY * y)) * wh) * 2;
    for (int x=0; x < width; x++) {
      int inIndex=srcRow + ((int)Math.floor(x * scaleX)) * 2;
      int colorValue=((mapContent[inIndex] & 0xFF)) | ((mapContent[inIndex + 1] & 0xFF) << 8);
      outImg[outIndex]=(short)(1 | colorValue << 1);
      outIndex++;
    }
  }
  return outImg;
}

Fixed version (ground truth):
public short[] getPreviewImage(int width,int height){
  if ((previewWidth == width) && (previewHeight == height) && (previewImage != null)) {
    return previewImage;
  }
  short[] outImg=new short[width * height];
  MapResourceInfo filePart=findResource(OriginalMapFileDataStructs.EMapFilePartType.PREVIEW);
  if (filePart == null)   return outImg;
  if (filePart.size < 4)   return outImg;
  if (!doDecrypt(filePart))   return outImg;
  int pos=filePart.offset;
  int wh=readBEWordFrom(pos);
  pos+=2;
  @SuppressWarnings("String_Node_Str") int unknown=readBEWordFrom(pos);
  pos+=2;
  float scaleX=wh / width;
  float scaleY=wh / height;
  int outIndex=0;
  int offset=pos;
  for (int y=0; y < height; y++) {
    int srcRow=offset + ((int)(Math.floor(scaleY * y)) * wh) * 2;
    for (int x=0; x < width; x++) {
      int inIndex=srcRow + ((int)Math.floor(x * scaleX)) * 2;
      int colorValue=((mapContent[inIndex] & 0xFF)) | ((mapContent[inIndex + 1] & 0xFF) << 8);
      outImg[outIndex]=(short)(1 | colorValue << 1);
      outIndex++;
    }
  }
  return outImg;
}
Program: 55892
Project: 55892
Buggy source:
private void bindTexture(TextureHandle texture) throws IllegalBufferException {
  int id;
  if (texture == null) {
    id=0;
  }
 else {
    if (!texture.isValid()) {
      throw new IllegalBufferException("String_Node_Str" + texture);
    }
    id=texture.getInternalId();
    gl2.glBindTexture(GL.GL_TEXTURE_2D,id);
  }
}

Fixed version (ground truth):
private void bindTexture(TextureHandle texture) throws IllegalBufferException {
  int id;
  if (texture == null) {
    id=0;
  }
 else {
    if (!texture.isValid()) {
      throw new IllegalBufferException("String_Node_Str" + texture);
    }
    id=texture.getInternalId();
  }
  gl2.glBindTexture(GL.GL_TEXTURE_2D,id);
}
Program: 55893
Project: 55893
Buggy source:
private boolean isMilitaryBuildingInHinterland(Building militaryBuilding,byte playerId){
  for (  ShortPoint2D occupiedPosition : new MapCircle(militaryBuilding.getPos(),CommonConstants.TOWER_RADIUS)) {
    if (getBorderLandNextToFreeLandForPlayer(playerId).contains(occupiedPosition) && partitionsGrid.getTowerCountAt(occupiedPosition.x,occupiedPosition.y) == 1) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
private boolean isMilitaryBuildingInHinterland(Building militaryBuilding,byte playerId){
  for (  ShortPoint2D influencedPositions : new MapCircle(militaryBuilding.getPos(),CommonConstants.TOWER_RADIUS + TOWER_RADIUS_OVERLAP)) {
    if (!mainGrid.isInBounds(influencedPositions.x,influencedPositions.y)) {
      continue;
    }
    if (positionIsBorderLandAndIsProtectedOnlyFromOneTower(playerId,influencedPositions) || positionIsOtherPlayersLand(influencedPositions,playerId)) {
      return false;
    }
  }
  return true;
}
Program: 55894
Project: 55894
Buggy source:
public void readBasicMapInformation(){
  fileChecksum=0;
  widthHeight=0;
  hasBuildings=false;
  if (mapContent == null)   return;
  if (mapContent.length < 100)   return;
  fileChecksum=readBEIntFrom(0);
  readMapInfo();
  readPlayerInfo();
  readMapQuestText();
  readMapQuestTip();
  widthHeight=0;
  MapResourceInfo filePart=findResource(OriginalMapFileDataStructs.EMapFilePartType.AREA);
  if (filePart == null)   return;
  if (filePart.size < 4)   return;
  if (!doDecrypt(filePart))   return;
  int pos=filePart.offset;
  widthHeight=readBEIntFrom(pos);
}

Fixed version (ground truth):
public void readBasicMapInformation(int previewWidth,int previewHeight){
  fileChecksum=0;
  widthHeight=0;
  hasBuildings=false;
  if (mapContent == null)   return;
  if (mapContent.length < 100)   return;
  fileChecksum=readBEIntFrom(0);
  readMapInfo();
  readPlayerInfo();
  readMapQuestText();
  readMapQuestTip();
  if ((previewWidth > 0) && (previewHeight > 0)) {
    this.previewImage=getPreviewImage(previewWidth,previewHeight);
    this.previewWidth=(short)previewWidth;
    this.previewHeight=(short)previewHeight;
  }
  MapResourceInfo filePart=findResource(OriginalMapFileDataStructs.EMapFilePartType.AREA);
  if (filePart == null)   return;
  if (filePart.size < 4)   return;
  if (!doDecrypt(filePart))   return;
  int pos=filePart.offset;
  widthHeight=readBEIntFrom(pos);
}
Program: 55895
Project: 55895
Buggy source:
private boolean doDecrypt(MapResourceInfo filePart){
  if (filePart == null)   return false;
  if (mapContent == null) {
    System.err.println("String_Node_Str");
    return false;
  }
  if (filePart.hasBeenDecrypted)   return true;
  int length=filePart.size;
  if (length <= 0)   return true;
  int pos=filePart.offset;
  int key=(filePart.cryptKey & 0xFF);
  for (int i=length; i > 0; i--) {
    int byt=(mapContent[pos] ^ key) & 0xFF;
    mapContent[pos]=(byte)byt;
    pos++;
    if (pos >= mapContent.length) {
      System.err.println("String_Node_Str");
      return false;
    }
    key=((key << 1) & 0xFF) ^ byt;
  }
  filePart.hasBeenDecrypted=true;
  return true;
}

Fixed version (ground truth):
private boolean doDecrypt(MapResourceInfo filePart){
  if (filePart == null)   return false;
  if (mapContent == null) {
    System.err.println("String_Node_Str");
    return false;
  }
  if (filePart.hasBeenDecrypted)   return true;
  int length=filePart.size;
  if (length <= 0)   return true;
  int pos=filePart.offset;
  if ((pos + length) >= mapContent.length) {
    System.err.println("String_Node_Str");
    return false;
  }
  int key=(filePart.cryptKey & 0xFF);
  for (int i=length; i > 0; i--) {
    int byt=(mapContent[pos] ^ key);
    key=(key << 1) ^ byt;
    mapContent[pos]=(byte)byt;
    pos++;
  }
  filePart.hasBeenDecrypted=true;
  return true;
}
Program: 55896
Project: 55896
Buggy source:
public int readBEWordFrom(int offset){
  if (mapContent == null)   return 0;
  return ((mapContent[offset] & 0xFF) << 0) | ((mapContent[offset + 1] & 0xFF) << 8);
}

Fixed version (ground truth):
public int readBEWordFrom(int offset){
  if (mapContent == null)   return 0;
  return ((mapContent[offset] & 0xFF)) | ((mapContent[offset + 1] & 0xFF) << 8);
}
Program: 55897
Project: 55897
Buggy source:
public int readBEIntFrom(int offset){
  if (mapContent == null)   return 0;
  return ((mapContent[offset] & 0xFF) << 0) | ((mapContent[offset + 1] & 0xFF) << 8) | ((mapContent[offset + 2] & 0xFF) << 16)| ((mapContent[offset + 3] & 0xFF) << 24);
}

Fixed version (ground truth):
public int readBEIntFrom(int offset){
  if (mapContent == null)   return 0;
  return ((mapContent[offset] & 0xFF)) | ((mapContent[offset + 1] & 0xFF) << 8) | ((mapContent[offset + 2] & 0xFF) << 16)| ((mapContent[offset + 3] & 0xFF) << 24);
}
Program: 55898
Project: 55898
Buggy source:
public String readCStrFrom(int offset,int length){
  if (mapContent == null)   return "String_Node_Str";
  if (mapContent.length <= offset + length)   return "String_Node_Str";
  String outStr="String_Node_Str";
  int pos=offset;
  for (int i=length; i > 0; i--) {
    byte b=mapContent[pos];
    pos++;
    if (b == 0)     break;
    outStr+=new String(new byte[]{b});
  }
  return outStr;
}

Fixed version (ground truth):
public String readCStrFrom(int offset,int length){
  if (mapContent == null)   return "String_Node_Str";
  if (mapContent.length <= offset + length)   return "String_Node_Str";
  int i=0;
  for (; i < length; i++) {
    if (mapContent[offset + i] == 0) {
      break;
    }
  }
  if (i == 0) {
    return "String_Node_Str";
  }
  return new String(mapContent,offset,i - 1,TEXT_CHARSET);
}
Program: 55899
Project: 55899
Buggy source:
boolean isChecksumValid(){
  int fileChecksum=readBEIntFrom(0);
  mapData.fileChecksum=fileChecksum;
  int count=mapContent.length & 0xFFFFFFFC;
  int currentChecksum=0;
  for (int i=8; i < count; i+=4) {
    int currentInt=readBEIntFrom(i);
    currentChecksum=((currentChecksum >>> 31) | ((currentChecksum << 1) ^ currentInt));
  }
  return (currentChecksum == fileChecksum);
}

Fixed version (ground truth):
boolean isChecksumValid(){
  int fileChecksum=readBEIntFrom(0);
  mapData.fileChecksum=fileChecksum;
  int count=mapContent.length & 0xFFFFFFFC;
  int currentChecksum=0;
  for (int i=8; i < count; i+=4) {
    int currentInt=((mapContent[i] & 0xFF)) | ((mapContent[i + 1] & 0xFF) << 8) | ((mapContent[i + 2] & 0xFF) << 16)| ((mapContent[i + 3] & 0xFF) << 24);
    currentChecksum=((currentChecksum >>> 31) | ((currentChecksum << 1) ^ currentInt));
  }
  return (currentChecksum == fileChecksum);
}
Program: 55900
Project: 55900
Buggy source:
private final boolean isValidPosition(IPathCalculatable requester,int x,int y,boolean blockedAtStart){
  return isInBounds(x,y) && (!isBlocked(requester,x,y) || blockedAtStart);
}

Fixed version (ground truth):
private final boolean isValidPosition(IPathCalculatable requester,int x,int y,short blockedAtStartPartition){
  return isInBounds(x,y) && (blockedAtStartPartition >= 0 && map.getBlockedPartition(x,y) == blockedAtStartPartition || !isBlocked(requester,x,y));
}
Program: 55902
Project: 55902
Buggy source:
private Building determineTowerToAttack(byte enemyToAttackId){
  List<ShortPoint2D> myMilitaryBuildings=aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.TOWER,player.playerId);
  myMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.BIG_TOWER,player.playerId));
  myMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.CASTLE,player.playerId));
  ShortPoint2D myBaseAveragePoint=aiStatistics.calculateAveragePointFromList(myMilitaryBuildings);
  List<ShortPoint2D> enemyMilitaryBuildings=aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.TOWER,enemyToAttackId);
  enemyMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.BIG_TOWER,enemyToAttackId));
  enemyMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.CASTLE,enemyToAttackId));
  if (enemyMilitaryBuildings.size() == 0) {
    return null;
  }
  return aiStatistics.getBuildingAt(AiStatistics.detectNearestPointFromList(myBaseAveragePoint,enemyMilitaryBuildings));
}

Fixed version (ground truth):
private Building determineTowerToAttack(byte enemyToAttackId){
  List<ShortPoint2D> myMilitaryBuildings=new ArrayList<>();
  myMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.TOWER,player.playerId));
  myMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.BIG_TOWER,player.playerId));
  myMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.CASTLE,player.playerId));
  ShortPoint2D myBaseAveragePoint=aiStatistics.calculateAveragePointFromList(myMilitaryBuildings);
  List<ShortPoint2D> enemyMilitaryBuildings=new ArrayList<>();
  enemyMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.TOWER,enemyToAttackId));
  enemyMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.BIG_TOWER,enemyToAttackId));
  enemyMilitaryBuildings.addAll(aiStatistics.getBuildingPositionsOfTypeForPlayer(EBuildingType.CASTLE,enemyToAttackId));
  if (enemyMilitaryBuildings.size() == 0) {
    return null;
  }
  return aiStatistics.getBuildingAt(AiStatistics.detectNearestPointFromList(myBaseAveragePoint,enemyMilitaryBuildings));
}
Program: 55903
Project: 55903
Buggy source:
@Override protected void strategyKilledEvent(ShortPoint2D pathTarget){
  if (pathTarget != null) {
    super.getStrategyGrid().setMarked(pathTarget,false);
  }
  if (state == EDiggerState.JOBLESS) {
    super.getStrategyGrid().removeJobless(this);
  }
  if (requester != null) {
    abortJob();
  }
  state=EDiggerState.DEAD_OBJECT;
}

Fixed version (ground truth):
@Override protected void strategyKilledEvent(ShortPoint2D pathTarget){
  if (pathTarget != null) {
    super.getStrategyGrid().setMarked(pathTarget,false);
  }
switch (state) {
case JOBLESS:
    super.getStrategyGrid().removeJobless(this);
  break;
case PLAYING_ACTION:
super.getStrategyGrid().setMarked(super.getPos(),false);
break;
default :
break;
}
if (requester != null) {
abortJob();
}
state=EDiggerState.DEAD_OBJECT;
}
Program: 55904
Project: 55904
Buggy source:
/** 
 * Occupies the given area for the given player.
 * @param player
 * @param influencingArea
 */
void occupyAreaByTower(Player player,MapCircle influencingArea);

Fixed version (ground truth):
/** 
 * Occupies the given area for the given player.
 * @param player
 * @param influencingArea
 */
void occupyAreaByTower(Player player,MapCircle influencingArea,final FreeMapArea groundArea);
Program: 55905
Project: 55905
Buggy source:
private final void occupyAreaIfNeeded(){
  if (!occupiedArea) {
    MapCircle occupying=new MapCircle(super.getPos(),CommonConstants.TOWER_RADIUS);
    super.getGrid().occupyAreaByTower(super.getPlayer(),occupying);
    occupiedArea=true;
  }
}

Fixed version (ground truth):
private final void occupyAreaIfNeeded(){
  if (!occupiedArea) {
    MapCircle occupying=new MapCircle(super.getPos(),CommonConstants.TOWER_RADIUS);
    super.getGrid().occupyAreaByTower(super.getPlayer(),occupying,getGroundArea());
    occupiedArea=true;
  }
}
Program: 55906
Project: 55906
Buggy source:
@Override public void occupyAreaByTower(Player player,MapCircle influencingArea){
  partitionsGrid.addTowerAndOccupyArea(player.playerId,influencingArea);
  checkAllPositionsForEnclosedBlockedAreas(influencingArea);
}

Fixed version (ground truth):
@Override public void occupyAreaByTower(Player player,MapCircle influencingArea,FreeMapArea groundArea){
  partitionsGrid.addTowerAndOccupyArea(player.playerId,influencingArea,groundArea);
  checkAllPositionsForEnclosedBlockedAreas(influencingArea);
}
Program: 55907
Project: 55907
Buggy source:
/** 
 * Occupies the given area for the given playerId if it is not already occupied by towers of an enemy.
 * @param playerId The id of the occupying player.
 * @param influencingArea The area affected by the tower.
 */
public void addTowerAndOccupyArea(byte playerId,MapCircle influencingArea){
  IMapArea filteredArea=new FilteredMapArea(influencingArea,new ISerializablePredicate<ShortPoint2D>(){
    private static final long serialVersionUID=-6460916149912865762L;
    @Override public boolean evaluate(    ShortPoint2D pos){
      return 0 <= pos.x && pos.x < width && 0 <= pos.y && pos.y < height;
    }
  }
);
  occupyArea(playerId,filteredArea,influencingArea.getBorders());
  occupyingTowers.add(new PartitionOccupyingTower(playerId,influencingArea.getCenter(),filteredArea,influencingArea.getBorders(),(int)influencingArea.getRadius()));
}

Fixed version (ground truth):
/** 
 * Occupies the given area for the given playerId if it is not already occupied by towers of an enemy.
 * @param playerId The id of the occupying player.
 * @param influencingArea The area affected by the tower.
 * @param groundArea The ground area of the tower.
 */
public void addTowerAndOccupyArea(byte playerId,MapCircle influencingArea,FreeMapArea groundArea){
  IMapArea filteredArea=new FilteredMapArea(influencingArea,new ISerializablePredicate<ShortPoint2D>(){
    private static final long serialVersionUID=-6460916149912865762L;
    @Override public boolean evaluate(    ShortPoint2D pos){
      return 0 <= pos.x && pos.x < width && 0 <= pos.y && pos.y < height;
    }
  }
);
  PartitionOccupyingTower tower=new PartitionOccupyingTower(playerId,influencingArea.getCenter(),filteredArea,influencingArea.getBorders(),(int)influencingArea.getRadius());
  occupyAreaOfTower(groundArea,tower);
}
Program: 55908
Project: 55908
Buggy source:
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,new FreeMapArea(pos,EBuildingType.TOWER.getProtectedTiles()));
}

Fixed version (ground truth):
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,getGroundArea(pos));
}
Program: 55909
Project: 55909
Buggy source:
private void addTower(int playerId,int x,int y,int radius){
  grid.addTowerAndOccupyArea((byte)playerId,getTowerCircle(x,y,radius));
}

Fixed version (ground truth):
private void addTower(int playerId,int x,int y,int radius){
  grid.addTowerAndOccupyArea((byte)playerId,getTowerCircle(x,y,radius),getGroundArea(new ShortPoint2D(x,y)));
}
Program: 55910
Project: 55910
Buggy source:
private void addTower(int playerId,int x,int y,int radius){
  blockArea(getTowerBlockArea(x,y),true);
  grid.addTowerAndOccupyArea((byte)playerId,new MapCircle(new ShortPoint2D(x,y),radius));
}

Fixed version (ground truth):
private void addTower(int playerId,int x,int y,int radius){
  blockArea(getTowerBlockArea(x,y),true);
  grid.addTowerAndOccupyArea((byte)playerId,new MapCircle(new ShortPoint2D(x,y),radius),getGroundArea(new ShortPoint2D(x,y)));
}
Program: 55911
Project: 55911
Buggy source:
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,new FreeMapArea(pos,EBuildingType.TOWER.getProtectedTiles()));
}

Fixed version (ground truth):
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,getGroundArea(pos));
}
Program: 55913
Project: 55913
Buggy source:
@Override protected void pathAborted(ShortPoint2D pathTarget){
  state=ESoldierState.AGGRESSIVE;
}

Fixed version (ground truth):
@Override protected void pathAborted(ShortPoint2D pathTarget){
switch (state) {
case INIT_GOTO_TOWER:
case GOING_TO_TOWER:
    notifyTowerThatRequestFailed();
  break;
default :
state=ESoldierState.AGGRESSIVE;
break;
}
}
Program: 55915
Project: 55915
Buggy source:
@Override protected boolean checkPathStepPreconditions(ShortPoint2D pathTarget,int step){
  boolean result=!((state == ESoldierState.SEARCH_FOR_ENEMIES || state == ESoldierState.HITTING) && step >= 2);
  if (!result && oldPathTarget == null) {
    oldPathTarget=pathTarget;
  }
  if (state == ESoldierState.GOING_TO_TOWER && (!building.isNotDestroyed() || building.getPlayer() != super.getPlayer())) {
    result=false;
  }
  if (enemy != null && state == ESoldierState.SEARCH_FOR_ENEMIES && isEnemyAttackable(enemy,false)) {
    result=false;
  }
  return result;
}

Fixed version (ground truth):
@Override protected boolean checkPathStepPreconditions(ShortPoint2D pathTarget,int step){
  if (state == ESoldierState.INIT_GOTO_TOWER) {
    return false;
  }
  boolean result=!((state == ESoldierState.SEARCH_FOR_ENEMIES || state == ESoldierState.HITTING) && step >= 2);
  if (!result && oldPathTarget == null) {
    oldPathTarget=pathTarget;
  }
  if (state == ESoldierState.GOING_TO_TOWER && (!building.isNotDestroyed() || building.getPlayer() != super.getPlayer())) {
    result=false;
  }
  if (enemy != null && state == ESoldierState.SEARCH_FOR_ENEMIES && isEnemyAttackable(enemy,false)) {
    result=false;
  }
  return result;
}
Program: 55916
Project: 55916
Buggy source:
private PlayerSetting[] determinePlayerSettings(boolean[] availablePlayers){
  boolean aiPlayersEnabled=iAmTheHost;
  PlayerSetting[] playerSettings=new PlayerSetting[availablePlayers.length];
  for (byte i=0; i < playersList.getItems().size(); i++) {
    playerSettings[i]=new PlayerSetting(true);
  }
  for (byte i=(byte)playersList.getItems().size(); i < availablePlayers.length; i++) {
    playerSettings[i]=new PlayerSetting(CommonConstants.ENABLE_AI && aiPlayersEnabled,EWhatToDoAiType.getTypeByIndex(i));
  }
  return playerSettings;
}

Fixed version (ground truth):
private PlayerSetting[] determinePlayerSettings(boolean[] availablePlayers){
  PlayerSetting[] playerSettings=new PlayerSetting[availablePlayers.length];
  byte i=0;
  for (; i < playersList.getItems().size(); i++) {
    playerSettings[i]=new PlayerSetting(true);
  }
  EWhatToDoAiType aiType=iAmTheHost ? EWhatToDoAiType.ROMAN_VERY_HARD : null;
  for (; i < availablePlayers.length; i++) {
    playerSettings[i]=new PlayerSetting(true,aiType);
  }
  return playerSettings;
}
Program: 55917
Project: 55917
Buggy source:
private final void setPositionsToMap(boolean[][] areaMap,List<ShortPoint2D> positions){
  for (  ShortPoint2D curr : positions) {
    areaMap[getMapX(curr)][getMapY(curr)]=true;
  }
}

Fixed version (ground truth):
/** 
 * Sets the positions to the map and returns the upper left position
 * @param areaMap
 * @param positions
 * @return
 */
private final ShortPoint2D setPositionsToMap(boolean[][] areaMap,List<ShortPoint2D> positions){
  if (positions.isEmpty()) {
    return null;
  }
  ShortPoint2D upperLeft=positions.get(0);
  for (  ShortPoint2D curr : positions) {
    areaMap[getMapX(curr)][getMapY(curr)]=true;
    if (curr.y < upperLeft.y || curr.y == upperLeft.y && curr.x < upperLeft.x) {
      upperLeft=curr;
    }
  }
  return upperLeft;
}
Program: 55918
Project: 55918
Buggy source:
@Override public final boolean contains(ShortPoint2D pos){
  return isValidPos(pos) && areaMap[getMapX(pos)][getMapY(pos)];
}

Fixed version (ground truth):
public boolean contains(int x,int y){
  int dx=x - xOffset;
  int dy=y - yOffset;
  return isValidMapPos(dx,dy) && areaMap[dx][dy];
}
Program: 55920
Project: 55920
Buggy source:
@Test public void testDividePartitionsByRemovingTower(){
  addTower(0,50,100,40);
  PartitionManager partition=grid.getPartitionAt(50,100);
  ShortPoint2D materialPos=new ShortPoint2D(75,100);
  partition.addOffer(materialPos,EMaterialType.STONE);
  partition.addOffer(materialPos,EMaterialType.STONE);
  addTower(0,150,100,40);
  assertTrue(grid.getPartitionIdAt(50,100) != grid.getPartitionIdAt(150,100));
  addTower(0,100,100,40);
  assertEquals(grid.getPartitionIdAt(50,100),grid.getPartitionIdAt(150,100));
  assertEquals(grid.getPartitionIdAt(100,100),grid.getPartitionIdAt(150,100));
  addTower(1,75,55,42);
  addTower(1,125,150,42);
  assertEquals(grid.getPartitionIdAt(50,100),grid.getPartitionIdAt(150,100));
  removeTower(100,100);
  assertTrue(grid.getPartitionIdAt(50,100) != grid.getPartitionIdAt(150,100));
  assertCircleIs(getTowerCircle(50,100,40),grid.getPartitionIdAt(50,100));
  assertCircleIs(getTowerCircle(150,100,40),grid.getPartitionIdAt(150,100));
  assertEquals(grid.getPartitionIdAt(75,55),grid.getPartitionIdAt(125,150));
  assertOfferAt(materialPos,EMaterialType.STONE,2);
}

Fixed version (ground truth):
@Test public void testDividePartitionsByRemovingTower(){
  addTower(0,50,100,40);
  PartitionManager partition=grid.getPartitionAt(50,100);
  ShortPoint2D materialPos=new ShortPoint2D(75,100);
  partition.addOffer(materialPos,EMaterialType.STONE);
  partition.addOffer(materialPos,EMaterialType.STONE);
  addTower(0,150,100,40);
  assertTrue(grid.getPartitionIdAt(50,100) != grid.getPartitionIdAt(150,100));
  addTower(0,100,100,40);
  assertEquals(grid.getPartitionIdAt(50,100),grid.getPartitionIdAt(150,100));
  assertEquals(grid.getPartitionIdAt(100,100),grid.getPartitionIdAt(150,100));
  addTower(1,75,55,42);
  addTower(1,120,145,42);
  assertEquals(grid.getPartitionIdAt(50,100),grid.getPartitionIdAt(150,100));
  removeTower(100,100);
  assertTrue(grid.getPartitionIdAt(50,100) != grid.getPartitionIdAt(150,100));
  assertCircleIs(getTowerCircle(50,100,40),grid.getPartitionIdAt(50,100));
  assertCircleIs(getTowerCircle(150,100,40),grid.getPartitionIdAt(150,100));
  assertEquals(grid.getPartitionIdAt(75,55),grid.getPartitionIdAt(120,145));
  assertEquals(grid.getPartitionIdAt(74,55),grid.getPartitionIdAt(120,145));
  assertEquals(grid.getPartitionIdAt(75,55),grid.getPartitionIdAt(121,145));
  assertOfferAt(materialPos,EMaterialType.STONE,2);
}
Program: 55921
Project: 55921
Buggy source:
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer,getGroundArea(pos));
}

Fixed version (ground truth):
private void changePlayerOfTower(int x,int y,int newPlayer){
  ShortPoint2D pos=new ShortPoint2D(x,y);
  grid.changePlayerOfTower(pos,(byte)newPlayer);
}
Program: 55923
Project: 55923
Buggy source:
/** 
 * kills this movable.
 */
@Override public final void kill(){
  if (health <= -100) {
    return;
  }
  grid.leavePosition(this.position,this);
  this.health=-200;
  this.strategy.strategyKilledEvent(path != null ? path.getTargetPos() : null);
  movablesByID.remove(this.getID());
  allMovables.remove(this);
  grid.addSelfDeletingMapObject(position,EMapObjectType.GHOST,Constants.GHOST_PLAY_DURATION,player);
}

Fixed version (ground truth):
/** 
 * kills this movable.
 */
@Override public final void kill(){
  if (state == EMovableState.DEAD) {
    return;
  }
  grid.leavePosition(this.position,this);
  this.health=-200;
  this.strategy.strategyKilledEvent(path != null ? path.getTargetPos() : null);
  this.state=EMovableState.DEAD;
  movablesByID.remove(this.getID());
  allMovables.remove(this);
  grid.addSelfDeletingMapObject(position,EMapObjectType.GHOST,Constants.GHOST_PLAY_DURATION,player);
}
Program: 55924
Project: 55924
Buggy source:
private void pathingAction(){
  if (!path.hasNextStep() || !strategy.checkPathStepPreconditions(path.getTargetPos(),path.getStep())) {
    setState(EMovableState.DOING_NOTHING);
    movableAction=EAction.NO_ACTION;
    path=null;
    checkPlayerOfCurrentPosition();
    return;
  }
  direction=EDirection.getDirection(position.x,position.y,path.nextX(),path.nextY());
  Movable blockingMovable=grid.getMovableAt(path.nextX(),path.nextY());
  if (blockingMovable == null) {
    if (grid.isValidNextPathPosition(this,path.getNextPos(),path.getTargetPos())) {
      goSinglePathStep();
    }
 else {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
      Path newPath=grid.calculatePathTo(this,path.getTargetPos());
      if (newPath == null) {
        setState(EMovableState.DOING_NOTHING);
        movableAction=EAction.NO_ACTION;
        strategy.pathAborted(path.getTargetPos());
        path=null;
      }
 else {
        this.path=newPath;
        if (grid.hasNoMovableAt(path.nextX(),path.nextY())) {
          goSinglePathStep();
        }
      }
    }
  }
 else {
    movableAction=EAction.NO_ACTION;
    boolean pushedSuccessful=blockingMovable.push(this);
    if (!pushedSuccessful) {
      path=strategy.findWayAroundObstacle(direction,position,path);
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
 else     if (movableAction == EAction.NO_ACTION) {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
  }
}

Fixed version (ground truth):
private void pathingAction(){
  if (!path.hasNextStep() || !strategy.checkPathStepPreconditions(path.getTargetPos(),path.getStep())) {
    setState(EMovableState.DOING_NOTHING);
    movableAction=EAction.NO_ACTION;
    path=null;
    return;
  }
  direction=EDirection.getDirection(position.x,position.y,path.nextX(),path.nextY());
  Movable blockingMovable=grid.getMovableAt(path.nextX(),path.nextY());
  if (blockingMovable == null) {
    if (grid.isValidNextPathPosition(this,path.getNextPos(),path.getTargetPos())) {
      goSinglePathStep();
    }
 else {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
      Path newPath=grid.calculatePathTo(this,path.getTargetPos());
      if (newPath == null) {
        setState(EMovableState.DOING_NOTHING);
        movableAction=EAction.NO_ACTION;
        strategy.pathAborted(path.getTargetPos());
        path=null;
      }
 else {
        this.path=newPath;
        if (grid.hasNoMovableAt(path.nextX(),path.nextY())) {
          goSinglePathStep();
        }
      }
    }
  }
 else {
    movableAction=EAction.NO_ACTION;
    boolean pushedSuccessful=blockingMovable.push(this);
    if (!pushedSuccessful) {
      path=strategy.findWayAroundObstacle(direction,position,path);
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
 else     if (movableAction == EAction.NO_ACTION) {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
  }
}
Program: 55926
Project: 55926
Buggy source:
private void pathingAction(){
  if (!path.hasNextStep() || !strategy.checkPathStepPreconditions(path.getTargetPos(),path.getStep())) {
    setState(EMovableState.DOING_NOTHING);
    movableAction=EAction.NO_ACTION;
    path=null;
    return;
  }
  direction=EDirection.getDirection(position.x,position.y,path.nextX(),path.nextY());
  Movable blockingMovable=grid.getMovableAt(path.nextX(),path.nextY());
  if (blockingMovable == null) {
    if (grid.isValidNextPathPosition(this,path.getNextPos(),path.getTargetPos())) {
      goSinglePathStep();
    }
 else {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
      Path newPath=grid.calculatePathTo(this,path.getTargetPos());
      if (newPath == null) {
        setState(EMovableState.DOING_NOTHING);
        movableAction=EAction.NO_ACTION;
        strategy.pathAborted(path.getTargetPos());
        path=null;
      }
 else {
        this.path=newPath;
        if (grid.hasNoMovableAt(path.nextX(),path.nextY())) {
          goSinglePathStep();
        }
      }
    }
  }
 else {
    movableAction=EAction.NO_ACTION;
    boolean pushedSuccessful=blockingMovable.push(this);
    if (!pushedSuccessful) {
      path=strategy.findWayAroundObstacle(direction,position,path);
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
 else     if (movableAction == EAction.NO_ACTION) {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
  }
}

Fixed version (ground truth):
private void pathingAction(){
  if (!path.hasNextStep() || !strategy.checkPathStepPreconditions(path.getTargetPos(),path.getStep())) {
    setState(EMovableState.DOING_NOTHING);
    movableAction=EAction.NO_ACTION;
    path=null;
    return;
  }
  direction=EDirection.getDirection(position.x,position.y,path.nextX(),path.nextY());
  Movable blockingMovable=grid.getMovableAt(path.nextX(),path.nextY());
  if (blockingMovable == null) {
    if (grid.isValidNextPathPosition(this,path.getNextPos(),path.getTargetPos())) {
      goSinglePathStep();
    }
 else {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
      Path newPath=grid.calculatePathTo(this,path.getTargetPos());
      if (newPath == null) {
        setState(EMovableState.DOING_NOTHING);
        movableAction=EAction.NO_ACTION;
        strategy.pathAborted(path.getTargetPos());
        path=null;
      }
 else {
        this.path=newPath;
        if (grid.hasNoMovableAt(path.nextX(),path.nextY())) {
          goSinglePathStep();
        }
      }
    }
  }
 else {
    movableAction=EAction.NO_ACTION;
    boolean pushedSuccessfully=blockingMovable.push(this);
    if (!pushedSuccessfully) {
      path=strategy.findWayAroundObstacle(direction,position,path);
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
 else     if (movableAction == EAction.NO_ACTION) {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
  }
}
Program: 55927
Project: 55927
Buggy source:
@Override protected boolean checkPathStepPreconditions(ShortPoint2D pathTarget,int step){
  return step <= 2;
}

Fixed version (ground truth):
@Override protected boolean checkPathStepPreconditions(ShortPoint2D pathTarget,int step){
  if (lastCheckedPathStep == step) {
    pathStepCheckedCounter++;
    searchesCounter++;
  }
 else {
    pathStepCheckedCounter=0;
    lastCheckedPathStep=(short)step;
  }
  return !super.isValidPosition(super.getPos()) && pathStepCheckedCounter < 5;
}
Program: 55928
Project: 55928
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 || MatchConstants.random().nextFloat() < 0.10) {
        turnNextTime=false;
        newDirection=currentDirection.getNeighbor(MatchConstants.random().nextInt(-1,1));
      }
 else {
        newDirection=currentDirection;
      }
      ShortPoint2D newPos=newDirection.getNextHexPoint(position);
      if (super.getStrategyGrid().isFreePosition(newPos)) {
        super.goInDirection(newDirection,true);
        turnNextTime=MatchConstants.random().nextInt(7) == 0;
      }
 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_FLEEING_DIJKSTRA_RADIUS,ESearchType.VALID_FREE_POSITION) || super.preSearchPath(false,position.x,position.y,Constants.MOVABLE_FLEEING_MAX_RADIUS,ESearchType.VALID_FREE_POSITION)) {
      lastCheckedPathStep=Integer.MIN_VALUE;
      super.followPresearchedPath();
    }
 else {
      EDirection currentDirection=super.getMovable().getDirection();
      EDirection newDirection;
      if (turnNextTime || MatchConstants.random().nextFloat() < 0.10) {
        turnNextTime=false;
        newDirection=currentDirection.getNeighbor(MatchConstants.random().nextInt(-1,1));
      }
 else {
        newDirection=currentDirection;
      }
      ShortPoint2D newPos=newDirection.getNextHexPoint(position);
      if (super.getStrategyGrid().isFreePosition(newPos)) {
        super.goInDirection(newDirection,true);
        turnNextTime=MatchConstants.random().nextInt(7) == 0;
      }
 else {
        super.lookInDirection(newDirection);
        turnNextTime=true;
      }
    }
    searchesCounter++;
  }
 else {
    super.convertTo(super.getMovable().getMovableType());
  }
}
Program: 55929
Project: 55929
Buggy source:
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
  ois.defaultReadObject();
  updateCombatStrengths();
}

Fixed version (ground truth):
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
  ois.defaultReadObject();
  combatStrengthInfo=new CombatStrengthInformation();
  updateCombatStrengths();
}
Program: 55930
Project: 55930
Buggy source:
private void updateCombatStrengths(){
  int amountOfGold=getAmountOf(EMaterialType.GOLD);
  this.combatStrengthInfo=CombatStrengthCalculator.calculateCombatStrengthInformation(numberOfPlayers,amountOfGold);
}

Fixed version (ground truth):
private void updateCombatStrengths(){
  int amountOfGold=getAmountOf(EMaterialType.GOLD);
  this.combatStrengthInfo.updateGoldCombatStrength(numberOfPlayers,amountOfGold);
}
Program: 55932
Project: 55932
Buggy source:
private void calculateForPosition(ShortPoint2D position){
  short x=position.x;
  short y=position.y;
  byte player=grid.getPlayerIdAt(x,y);
  boolean isBorder=false;
  if (grid.getBlockedPartition(x,y) > 0) {
    for (    EDirection currDir : EDirection.values) {
      short currNeighborX=currDir.getNextTileX(x);
      short currNeighborY=currDir.getNextTileY(y);
      if (!grid.isInBounds(currNeighborX,currNeighborY)) {
        continue;
      }
      byte neighborPlayer=grid.getPlayerIdAt(currNeighborX,currNeighborY);
      boolean neighborIsBorder=false;
      if (neighborPlayer != player) {
        isBorder=true;
      }
      if (grid.getBlockedPartition(currNeighborX,currNeighborY) <= 0) {
        continue;
      }
      if (neighborPlayer >= 0) {
        for (        EDirection currNeighborDir : EDirection.values) {
          short nextX=currNeighborDir.getNextTileX(currNeighborX);
          short nextY=currNeighborDir.getNextTileY(currNeighborY);
          if (grid.isInBounds(nextX,nextY) && grid.getPlayerIdAt(nextX,nextY) != neighborPlayer && grid.getBlockedPartition(nextX,nextY) > 0) {
            neighborIsBorder=true;
            break;
          }
        }
      }
      grid.setBorderAt(currNeighborX,currNeighborY,neighborIsBorder);
    }
  }
  grid.setBorderAt(x,y,isBorder && player >= 0);
}

Fixed version (ground truth):
private void calculateForPosition(ShortPoint2D position){
  short x=position.x;
  short y=position.y;
  byte player=grid.getPlayerIdAt(x,y);
  boolean isBorder=false;
  if (grid.getBlockedPartition(x,y) > 0) {
    for (    EDirection currDir : EDirection.values) {
      short currNeighborX=currDir.getNextTileX(x);
      short currNeighborY=currDir.getNextTileY(y);
      if (!grid.isInBounds(currNeighborX,currNeighborY)) {
        continue;
      }
      if (grid.getBlockedPartition(currNeighborX,currNeighborY) <= 0) {
        continue;
      }
      byte neighborPlayer=grid.getPlayerIdAt(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.getPlayerIdAt(nextX,nextY) != neighborPlayer && grid.getBlockedPartition(nextX,nextY) > 0) {
            neighborIsBorder=true;
            break;
          }
        }
      }
      grid.setBorderAt(currNeighborX,currNeighborY,neighborIsBorder);
    }
  }
  grid.setBorderAt(x,y,isBorder && player >= 0);
}
Program: 55933
Project: 55933
Buggy source:
private void pathingAction(){
  if (!path.hasNextStep() || !strategy.checkPathStepPreconditions(path.getTargetPos(),path.getStep())) {
    setState(EMovableState.DOING_NOTHING);
    movableAction=EAction.NO_ACTION;
    path=null;
    checkPlayerOfCurrentPosition();
    return;
  }
  direction=EDirection.getDirection(position.x,position.y,path.nextX(),path.nextY());
  Movable blockingMovable=grid.getMovableAt(path.nextX(),path.nextY());
  if (blockingMovable == null) {
    if (!grid.isValidNextPathPosition(this,path.getNextPos(),path.getTargetPos())) {
      Path newPath=grid.calculatePathTo(this,path.getTargetPos());
      if (newPath == null) {
        setState(EMovableState.DOING_NOTHING);
        movableAction=EAction.NO_ACTION;
        strategy.pathAborted(path.getTargetPos());
        path=null;
        return;
      }
 else {
        this.path=newPath;
      }
    }
    goSinglePathStep();
  }
 else {
    movableAction=EAction.NO_ACTION;
    boolean pushedSuccessful=blockingMovable.push(this);
    if (!pushedSuccessful) {
      path=strategy.findWayAroundObstacle(direction,position,path);
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
 else     if (movableAction == EAction.NO_ACTION) {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
  }
}

Fixed version (ground truth):
private void pathingAction(){
  if (!path.hasNextStep() || !strategy.checkPathStepPreconditions(path.getTargetPos(),path.getStep())) {
    setState(EMovableState.DOING_NOTHING);
    movableAction=EAction.NO_ACTION;
    path=null;
    checkPlayerOfCurrentPosition();
    return;
  }
  direction=EDirection.getDirection(position.x,position.y,path.nextX(),path.nextY());
  Movable blockingMovable=grid.getMovableAt(path.nextX(),path.nextY());
  if (blockingMovable == null) {
    if (grid.isValidNextPathPosition(this,path.getNextPos(),path.getTargetPos())) {
      goSinglePathStep();
    }
 else {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
      Path newPath=grid.calculatePathTo(this,path.getTargetPos());
      if (newPath == null) {
        setState(EMovableState.DOING_NOTHING);
        movableAction=EAction.NO_ACTION;
        strategy.pathAborted(path.getTargetPos());
        path=null;
      }
 else {
        this.path=newPath;
      }
    }
  }
 else {
    movableAction=EAction.NO_ACTION;
    boolean pushedSuccessful=blockingMovable.push(this);
    if (!pushedSuccessful) {
      path=strategy.findWayAroundObstacle(direction,position,path);
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
 else     if (movableAction == EAction.NO_ACTION) {
      animationDuration=Constants.MOVABLE_INTERRUPT_PERIOD;
    }
  }
}
Program: 55934
Project: 55934
Buggy source:
protected Path findWayAroundObstacle(EDirection direction,ShortPoint2D position,Path path){
  if (!path.hasOverNextStep()) {
    return path;
  }
  AbstractStrategyGrid grid=movable.getStrategyGrid();
  EDirection leftDir=direction.getNeighbor(-1);
  EDirection rightDir=direction.getNeighbor(1);
  ShortPoint2D leftPos=leftDir.getNextHexPoint(position);
  ShortPoint2D leftStraightPos=direction.getNextHexPoint(leftPos);
  ShortPoint2D rightPos=rightDir.getNextHexPoint(position);
  ShortPoint2D rightStraightPos=direction.getNextHexPoint(rightPos);
  ShortPoint2D twoStraight=direction.getNextHexPoint(position,2);
  ShortPoint2D overNextPos=path.getOverNextPos();
  if (twoStraight.equals(overNextPos)) {
    if (isValidPosition(leftPos) && grid.hasNoMovableAt(leftPos.x,leftPos.y) && isValidPosition(leftStraightPos)) {
      path.goToNextStep();
      path=new Path(path,leftPos,leftStraightPos);
    }
 else     if (isValidPosition(rightPos) && grid.hasNoMovableAt(rightPos.x,rightPos.y) && isValidPosition(rightStraightPos)) {
      path.goToNextStep();
      path=new Path(path,rightPos,rightStraightPos);
    }
 else {
    }
  }
 else   if (leftStraightPos.equals(overNextPos) && grid.hasNoMovableAt(leftPos.x,leftPos.y)) {
    path.goToNextStep();
    path=new Path(path,leftPos);
  }
 else   if (rightStraightPos.equals(overNextPos) && grid.hasNoMovableAt(rightPos.x,rightPos.y)) {
    path.goToNextStep();
    path=new Path(path,rightPos);
  }
 else {
  }
  return path;
}

Fixed version (ground truth):
protected Path findWayAroundObstacle(EDirection direction,ShortPoint2D position,Path path){
  if (!path.hasOverNextStep()) {
    return path;
  }
  AbstractStrategyGrid grid=movable.getStrategyGrid();
  EDirection leftDir=direction.getNeighbor(-1);
  EDirection rightDir=direction.getNeighbor(1);
  ShortPoint2D leftPos=leftDir.getNextHexPoint(position);
  ShortPoint2D leftStraightPos=direction.getNextHexPoint(leftPos);
  ShortPoint2D rightPos=rightDir.getNextHexPoint(position);
  ShortPoint2D rightStraightPos=direction.getNextHexPoint(rightPos);
  ShortPoint2D twoStraight=direction.getNextHexPoint(position,2);
  ShortPoint2D overNextPos=path.getOverNextPos();
  if (twoStraight.equals(overNextPos)) {
    if (isValidPosition(leftPos) && grid.hasNoMovableAt(leftPos.x,leftPos.y) && isValidPosition(leftStraightPos)) {
      path.goToNextStep();
      path=new Path(path,leftPos,leftStraightPos);
    }
 else     if (isValidPosition(rightPos) && grid.hasNoMovableAt(rightPos.x,rightPos.y) && isValidPosition(rightStraightPos)) {
      path.goToNextStep();
      path=new Path(path,rightPos,rightStraightPos);
    }
 else {
    }
  }
 else   if (leftStraightPos.equals(overNextPos) && isValidPosition(leftPos) && grid.hasNoMovableAt(leftPos.x,leftPos.y)) {
    path.goToNextStep();
    path=new Path(path,leftPos);
  }
 else   if (rightStraightPos.equals(overNextPos) && isValidPosition(rightPos) && grid.hasNoMovableAt(rightPos.x,rightPos.y)) {
    path.goToNextStep();
    path=new Path(path,rightPos);
  }
 else {
  }
  return path;
}
Program: 55935
Project: 55935
Buggy source:
private void handleWorkerRequest(){
  WorkerRequest workerRequest=workerRequests.poll();
  if (workerRequest != null) {
    IManageableWorker worker=joblessWorkers.removeObjectNextTo(workerRequest.getPos(),new MovableTypeAcceptor(workerRequest.movableType));
    if (worker != null) {
      worker.setWorkerJob(workerRequest.building);
    }
 else {
      if (!workerRequest.creationRequested) {
        workerRequest.creationRequested=true;
        createNewToolUser(workerRequest);
      }
      workerRequests.offerLast(workerRequest);
    }
  }
}

Fixed version (ground truth):
private void handleWorkerRequest(){
  WorkerRequest workerRequest=workerRequests.poll();
  if (workerRequest != null) {
    IManageableWorker worker=joblessWorkers.removeObjectNextTo(workerRequest.getPos(),new MovableTypeAcceptor(workerRequest.movableType));
    if (worker != null && worker.isAlive()) {
      worker.setWorkerJob(workerRequest.building);
    }
 else {
      if (!workerRequest.creationRequested) {
        workerRequest.creationRequested=true;
        createNewToolUser(workerRequest);
      }
      workerRequests.offerLast(workerRequest);
    }
  }
}
Program: 55936
Project: 55936
Buggy source:
@Override protected void strategyKilledEvent(ShortPoint2D pathTarget){
  dropCurrentMaterial();
  if (building != null) {
    building.leaveBuilding(this);
  }
  if (isJobless()) {
    super.getStrategyGrid().removeJobless(this);
  }
}

Fixed version (ground truth):
@Override protected void strategyKilledEvent(ShortPoint2D pathTarget){
  killed=true;
  dropCurrentMaterial();
  if (isJobless()) {
    super.getStrategyGrid().removeJobless(this);
  }
 else {
    super.enableNothingToDoAction(true);
    currentJob=null;
  }
  if (building != null) {
    building.leaveBuilding(this);
  }
}