nus-yam/ex-repair huggingface dataset:
Program: 40115
Project: 40115
Buggy source:
public static void main(String[] args){
  GameMap gameMap=new GameMap(MapDriver.readMap("String_Node_Str"));
  Score score=new Score();
  score.init(gameMap,Color.BLACK);
  Analyzer analyzer=new Analyzer(gameMap,Color.WHITE,gameMap.getNeighbor(),score,false);
  List<Point> points=getExpandPoints(analyzer,gameMap);
  ConsolePrinter.printMapWithPoints(gameMap,points);
  System.out.println(points);
}

Fixed version (ground truth):
public static void main(String[] args){
  GameMap gameMap=new GameMap(MapDriver.readMap());
  Score score=new Score();
  score.init(gameMap,Color.BLACK);
  Analyzer analyzer=new Analyzer(gameMap,Color.BLACK,gameMap.getNeighbor(),score,false);
  List<Point> points=getExpandPoints(analyzer,gameMap);
  ConsolePrinter.printMapWithPoints(gameMap,points);
  System.out.println(points);
}
Program: 40117
Project: 40117
Buggy source:
public static Color[][] readMap(String filePath){
  File file=new File(resourcePath + filePath);
  BufferedReader reader=null;
  try {
    reader=new BufferedReader(new FileReader(file));
    String tempString=reader.readLine();
    int size=Integer.valueOf(tempString);
    Color[][] map=new Color[size][size];
    for (int i=0; i < size; i++) {
      tempString=reader.readLine();
      for (int j=0; j < size; j++) {
switch (tempString.charAt(j)) {
case '.':
          map[i][j]=Color.NULL;
        break;
case '□':
      map[i][j]=Color.NULL;
    break;
case '×':
  map[i][j]=Color.BLACK;
break;
case '●':
map[i][j]=Color.WHITE;
break;
}
}
}
reader.close();
return map;
}
 catch (IOException e) {
e.printStackTrace();
}
 finally {
if (reader != null) {
try {
reader.close();
}
 catch (IOException ignored) {
}
}
}
return null;
}

Fixed version (ground truth):
public static Color[][] readMap(String filePath){
  File file=new File(resourcePath + filePath);
  BufferedReader reader=null;
  try {
    reader=new BufferedReader(new FileReader(file));
    String tempString=reader.readLine();
    int size=Integer.valueOf(tempString);
    Color[][] map=new Color[size][size];
    for (int i=0; i < size; i++) {
      tempString=reader.readLine();
      for (int j=0; j < size; j++) {
switch (tempString.charAt(j)) {
case '.':
          map[i][j]=Color.NULL;
        break;
case '□':
      map[i][j]=Color.NULL;
    break;
case '×':
  map[i][j]=Color.BLACK;
break;
case '●':
map[i][j]=Color.WHITE;
break;
case 'x':
map[i][j]=Color.BLACK;
break;
case 'o':
map[i][j]=Color.WHITE;
break;
}
}
}
reader.close();
return map;
}
 catch (IOException e) {
e.printStackTrace();
}
 finally {
if (reader != null) {
try {
reader.close();
}
 catch (IOException ignored) {
}
}
}
return null;
}
Program: 40119
Project: 40119
Buggy source:
public static void main(String[] args) throws TimeOutException {
  Color[][] colors=MapDriver.readMap();
  GameMap gameMap=new GameMap(colors);
  ConsolePrinter.printMap(gameMap);
  Score score=new Score();
  Color color=Color.BLACK;
  score.init(gameMap,color);
  long time=System.currentTimeMillis();
  Config config=new Config();
  config.comboDeep=15;
  ComboProcessor comboProcessor=new ComboProcessor();
  comboProcessor.init(gameMap,score,new Counter(),new Cache(config,gameMap));
  System.out.println(comboProcessor.canKill(color,15,System.currentTimeMillis(),config.comboTimeOut).point);
  System.out.println(System.currentTimeMillis() - time + "String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args) throws TimeOutException {
  Color[][] colors=MapDriver.readMap();
  GameMap gameMap=new GameMap(colors);
  ConsolePrinter.printMap(gameMap);
  Score score=new Score();
  Color color=Color.WHITE;
  score.init(gameMap,color);
  long time=System.currentTimeMillis();
  Config config=new Config();
  config.comboDeep=15;
  ComboProcessor comboProcessor=new ComboProcessor();
  comboProcessor.init(gameMap,score,new Counter(),new Cache(config,gameMap));
  System.out.println(comboProcessor.canKill(color,config.comboDeep,System.currentTimeMillis(),config.comboTimeOut).point);
  System.out.println(System.currentTimeMillis() - time + "String_Node_Str");
}
Program: 40120
Project: 40120
Buggy source:
ComboResult canKill(Color targetColor,int level,long startTime,long limitTime){
  if (level % 2 == 1) {
    level--;
  }
  this.startTime=startTime;
  this.limitTime=limitTime;
  currentLevel=level;
  result=new ComboResult();
  result.point=null;
  cache.clear();
  dfsKill(gameMap,targetColor,targetColor,level,score,ComboTye.FOUR,null,null,null);
  if (result.point != null) {
    result.fourWin=true;
    return result;
  }
  result.point=null;
  cache.clear();
  dfsKill(gameMap,targetColor.getOtherColor(),targetColor.getOtherColor(),level,score,ComboTye.FOUR,null,null,null);
  if (result.point != null) {
    result.point=null;
    result.fourWin=true;
    return result;
  }
  result.point=null;
  cache.clear();
  dfsKill(gameMap,targetColor,targetColor,level,score,ComboTye.THREE,null,null,null);
  result.fourWin=false;
  return result;
}

Fixed version (ground truth):
ComboResult canKill(Color targetColor,int level,long startTime,long limitTime){
  if (level % 2 == 0) {
    level++;
  }
  this.startTime=startTime;
  this.limitTime=limitTime;
  currentLevel=level;
  result=new ComboResult();
  result.point=null;
  cache.clear();
  dfsKill(gameMap,targetColor,targetColor,level,score,ComboTye.FOUR,null,null,null);
  if (result.point != null) {
    result.fourWin=true;
    return result;
  }
  result.point=null;
  cache.clear();
  dfsKill(gameMap,targetColor.getOtherColor(),targetColor.getOtherColor(),level,score,ComboTye.FOUR,null,null,null);
  if (result.point != null) {
    result.point=null;
    result.fourWin=true;
    return result;
  }
  result.point=null;
  cache.clear();
  dfsKill(gameMap,targetColor,targetColor,level,score,ComboTye.THREE,null,null,null);
  result.fourWin=false;
  return result;
}
Program: 40121
Project: 40121
Buggy source:
private int getValueByCount(int blackCount,int whiteCount,Color color){
  int ONE=4;
  int TWO=20;
  int THREE=40;
  int FOUR=100;
  float weight=1.0f;
  int valueWhite=0;
  if (blackCount == 0) {
    if (whiteCount == 1)     valueWhite+=ONE;
    if (whiteCount == 2)     valueWhite+=TWO;
    if (whiteCount == 3)     valueWhite+=THREE;
    if (whiteCount == 4)     valueWhite+=FOUR;
  }
  int valueBlack=0;
  if (whiteCount == 0) {
    if (blackCount == 1)     valueBlack+=ONE;
    if (blackCount == 2)     valueBlack+=TWO;
    if (blackCount == 3)     valueBlack+=THREE;
    if (blackCount == 4)     valueBlack+=FOUR;
  }
  int value=0;
  if (color == Color.BLACK) {
    return valueBlack - (int)(valueWhite * weight);
  }
  if (color == Color.WHITE) {
    return valueWhite - (int)(valueBlack * weight);
  }
  return value;
}

Fixed version (ground truth):
private int getValueByCount(int blackCount,int whiteCount,Color color){
  int ONE=4;
  int TWO=20;
  int THREE=40;
  int FOUR=90;
  float weight=1.0f;
  int valueWhite=0;
  if (blackCount == 0) {
    if (whiteCount == 1)     valueWhite+=ONE;
    if (whiteCount == 2)     valueWhite+=TWO;
    if (whiteCount == 3)     valueWhite+=THREE;
    if (whiteCount == 4)     valueWhite+=FOUR;
  }
  int valueBlack=0;
  if (whiteCount == 0) {
    if (blackCount == 1)     valueBlack+=ONE;
    if (blackCount == 2)     valueBlack+=TWO;
    if (blackCount == 3)     valueBlack+=THREE;
    if (blackCount == 4)     valueBlack+=FOUR;
  }
  int value=0;
  if (color == Color.BLACK) {
    return valueBlack - (int)(valueWhite * weight);
  }
  if (color == Color.WHITE) {
    return valueWhite - (int)(valueBlack * weight);
  }
  return value;
}
Program: 40123
Project: 40123
Buggy source:
public static void main(String[] args){
  GameMap gameMap=new GameMap(MapDriver.readMap("String_Node_Str"));
  ConsolePrinter.printMap(gameMap);
  Score score=new Score();
  score.init(gameMap,Color.WHITE);
  Analyzer analyzer=new Analyzer(gameMap,Color.WHITE,gameMap.getNeighbor(),score,new Counter());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getFiveAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getFourAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getFourDefence());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getThreeOpenAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getThreeDefence());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getTwoAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getNotKey());
}

Fixed version (ground truth):
public static void main(String[] args){
  GameMap gameMap=new GameMap(MapDriver.readMap());
  ConsolePrinter.printMap(gameMap);
  Score score=new Score();
  score.init(gameMap,Color.BLACK);
  Analyzer analyzer=new Analyzer(gameMap,Color.WHITE,gameMap.getNeighbor(),score,new Counter());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getFiveAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getFourAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getFourDefence());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getThreeOpenAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getThreeDefence());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getTwoAttack());
  System.out.println("String_Node_Str");
  System.out.println(analyzer.getNotKey());
}
Program: 40124
Project: 40124
Buggy source:
public static void main(String[] args) throws TimeOutException {
  Color[][] colors=MapDriver.readMap();
  GameMap gameMap=new GameMap(colors);
  ConsolePrinter.printMap(gameMap);
  Score score=new Score();
  Color color=Color.WHITE;
  score.init(gameMap,color);
  long time=System.currentTimeMillis();
  Config config=new Config();
  config.comboDeep=15;
  ComboProcessor comboProcessor=new ComboProcessor();
  comboProcessor.init(gameMap,score,new Counter(),new Cache(config,gameMap,new Counter()));
  System.out.println(comboProcessor.canKill(color,15,System.currentTimeMillis(),config.comboTimeOut).point);
  System.out.println(System.currentTimeMillis() - time + "String_Node_Str");
}

Fixed version (ground truth):
public static void main(String[] args) throws TimeOutException {
  Color[][] colors=MapDriver.readMap();
  GameMap gameMap=new GameMap(colors);
  ConsolePrinter.printMap(gameMap);
  Score score=new Score();
  Color color=Color.BLACK;
  score.init(gameMap,color);
  long time=System.currentTimeMillis();
  Config config=new Config();
  config.comboDeep=15;
  ComboProcessor comboProcessor=new ComboProcessor();
  comboProcessor.init(gameMap,score,new Counter(),new Cache(config,gameMap,new Counter()));
  System.out.println(comboProcessor.canKill(color,15,System.currentTimeMillis(),config.comboTimeOut).point);
  System.out.println(System.currentTimeMillis() - time + "String_Node_Str");
}
Program: 40126
Project: 40126
Buggy source:
private int getValueByCount(int blackCount,int whiteCount,Color color){
  int ONE=2;
  int TWO=10;
  int THREE=20;
  int FOUR=50;
  float weight=1.0f;
  int valueWhite=0;
  if (blackCount == 0) {
    if (whiteCount == 1)     valueWhite+=ONE;
    if (whiteCount == 2)     valueWhite+=TWO;
    if (whiteCount == 3)     valueWhite+=THREE;
    if (whiteCount == 4)     valueWhite+=FOUR;
  }
  int valueBlack=0;
  if (whiteCount == 0) {
    if (blackCount == 1)     valueBlack+=ONE;
    if (blackCount == 2)     valueBlack+=TWO;
    if (blackCount == 3)     valueBlack+=THREE;
    if (blackCount == 4)     valueBlack+=FOUR;
  }
  int value=0;
  if (color == Color.BLACK) {
    return valueBlack - (int)(valueWhite * weight);
  }
  if (color == Color.WHITE) {
    return valueWhite - (int)(valueBlack * weight);
  }
  return value;
}

Fixed version (ground truth):
private int getValueByCount(int blackCount,int whiteCount,Color color){
  int ONE=2;
  int TWO=10;
  int THREE=20;
  int FOUR=40;
  float weight=1.0f;
  int valueWhite=0;
  if (blackCount == 0) {
    if (whiteCount == 1)     valueWhite+=ONE;
    if (whiteCount == 2)     valueWhite+=TWO;
    if (whiteCount == 3)     valueWhite+=THREE;
    if (whiteCount == 4)     valueWhite+=FOUR;
  }
  int valueBlack=0;
  if (whiteCount == 0) {
    if (blackCount == 1)     valueBlack+=ONE;
    if (blackCount == 2)     valueBlack+=TWO;
    if (blackCount == 3)     valueBlack+=THREE;
    if (blackCount == 4)     valueBlack+=FOUR;
  }
  int value=0;
  if (color == Color.BLACK) {
    return valueBlack - (int)(valueWhite * weight);
  }
  if (color == Color.WHITE) {
    return valueWhite - (int)(valueBlack * weight);
  }
  return value;
}
Program: 40127
Project: 40127
Buggy source:
/** 
 * Main method to be called to start the program.
 * @param args unused
 */
public static void main(String[] args) throws Exception {
  Coordinate startCoord=new Coordinate(7568,1507);
  Coordinate endCoord=new Coordinate(7568,1727);
  String mapPath="String_Node_Str";
  MarsRover rover=new MarsRover(6,startCoord,endCoord,mapPath,3);
  Algorithm algorithm=new AlgorithmLimitedIDAStar(rover,"String_Node_Str");
  try {
    algorithm.findPath();
  }
 catch (  Exception expectedException) {
  }
  TerminalInterface ti=new TerminalInterface();
  ti.promptUser();
}

Fixed version (ground truth):
/** 
 * Main method to be called to start the program.
 * @param args unused
 */
public static void main(String[] args) throws Exception {
  Coordinate startCoord=new Coordinate(7568,1507);
  Coordinate endCoord=new Coordinate(7568,1727);
  String mapPath="String_Node_Str";
  MarsRover rover=new MarsRover(6,startCoord,endCoord,mapPath,50);
  Algorithm algorithm=new AlgorithmUnlimitedBestFirst(rover,"String_Node_Str");
  try {
    algorithm.findPath();
  }
 catch (  Exception expectedException) {
  }
  OutputFactory.getOutput(algorithm);
  TerminalInterface ti=new TerminalInterface();
  ti.promptUser();
}
Program: 40128
Project: 40128
Buggy source:
/** 
 * Heuristic function for BestFirst implementing diagonal distance between two nodes
 * @param current current node
 * @param goal goal node
 * @return diagonal distance
 */
private double estimateHeuristic(Coordinate current,Coordinate goal){
  double currentXPos=current.getX();
  double currentYPos=current.getY();
  double goalXPos=goal.getX();
  double goalYPos=goal.getY();
  return Math.max(Math.abs(currentXPos - goalXPos),Math.abs(currentYPos - goalYPos));
}

Fixed version (ground truth):
/** 
 * Heuristic function for BestFirst implementing diagonal distance between two nodes
 * @param current current node
 * @param goal goal node
 * @return diagonal distance
 */
private double estimateHeuristic(Coordinate current,Coordinate goal){
  double currentXPos=current.getX();
  double currentYPos=current.getY();
  double goalXPos=goal.getX();
  double goalYPos=goal.getY();
  return (Math.abs(currentXPos - goalXPos) + Math.abs(currentYPos - goalYPos));
}
Program: 40129
Project: 40129
Buggy source:
private BestFirstCoordinate getLowestFScore(ArrayList<BestFirstCoordinate> list){
  BestFirstCoordinate lowest=list.get(0);
  for (  BestFirstCoordinate n : list) {
    if (estimateHeuristic(n,goal) < estimateHeuristic(lowest,goal)) {
      lowest=n;
    }
  }
  return lowest;
}

Fixed version (ground truth):
private BestFirstCoordinate getLowestFScore(ArrayList<BestFirstCoordinate> list){
  BestFirstCoordinate lowest=list.get(0);
  for (  BestFirstCoordinate n : list) {
    if (estimateHeuristic(n,interimGoal) < estimateHeuristic(lowest,interimGoal)) {
      lowest=n;
    }
  }
  return lowest;
}
Program: 40130
Project: 40130
Buggy source:
public AlgorithmLimitedBestFirst(MarsRover r,String output){
  rover=r;
  map=rover.getMap();
  goal=r.getEndPosition();
  fieldOfView=r.getFieldOfView();
}

Fixed version (ground truth):
public AlgorithmLimitedBestFirst(MarsRover r,String output){
  rover=r;
  map=rover.getMap();
  goal=r.getEndPosition();
  fieldOfView=r.getFieldOfView();
  outputClass=output;
}
Program: 40131
Project: 40131
Buggy source:
public AlgorithmLimitedDijkstra(MarsRover r,String output){
  rover=r;
  map=r.getMap();
  goal=new DijkstraNode(r.getEndPosition());
  fieldOfView=r.getFieldOfView();
}

Fixed version (ground truth):
public AlgorithmLimitedDijkstra(MarsRover r,String output){
  rover=r;
  map=r.getMap();
  goal=new DijkstraNode(r.getEndPosition());
  fieldOfView=r.getFieldOfView();
  outputClass=output;
}
Program: 40132
Project: 40132
Buggy source:
/** 
 * Find a path from start to goal with IDA*. Then output it. Throw an exception if a path cannot be found.
 * @param thisNode The coordinate being considered by the algorithm.
 */
public ArrayList<AStarCoordinate> IDAStar(AStarCoordinate thisNode,Coordinate currentGoal) throws Exception {
  ArrayList<AStarCoordinate> currentPath=constructPath(thisNode);
  if (coordIsInSet(thisNode,currentPath.subList(0,currentPath.size() - 1))) {
    throw new Exception("String_Node_Str");
  }
  if (thisNode == null) {
    if (getDistanceToPoint(bestNode,interimGoal) < (fieldOfView - 1)) {
      return constructPath(bestNode);
    }
    throw new Exception("String_Node_Str");
  }
 else {
    if (thisNode.equals(interimGoal)) {
      return constructPath(thisNode);
    }
 else {
      ArrayList<AStarCoordinate> neighbors=getReachableNeighbors(thisNode);
      sortCoordinatesByCost(neighbors);
      if (neighbors.get(0).getDistanceToGoal() < bestNode.getDistanceToGoal()) {
        bestNode=neighbors.get(0);
      }
      for (      AStarCoordinate n : neighbors) {
        try {
          return IDAStar(n,currentGoal);
        }
 catch (        Exception e) {
        }
      }
    }
  }
  throw new Exception("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Find a path from start to goal with IDA*. Then output it. Throw an exception if a path cannot be found.
 * @param thisNode The coordinate being considered by the algorithm.
 */
public ArrayList<AStarCoordinate> IDAStar(AStarCoordinate thisNode,Coordinate currentGoal) throws Exception {
  ArrayList<AStarCoordinate> currentPath=constructPath(thisNode);
  if (thisNode == null) {
    if (getDistanceToPoint(bestNode,interimGoal) < (fieldOfView - 1)) {
      return constructPath(bestNode);
    }
    throw new Exception("String_Node_Str");
  }
 else {
    if (thisNode.equals(interimGoal)) {
      return constructPath(thisNode);
    }
 else {
      ArrayList<AStarCoordinate> neighbors=getReachableNeighbors(thisNode);
      sortCoordinatesByCost(neighbors);
      if (neighbors.get(0).getDistanceToGoal() < bestNode.getDistanceToGoal()) {
        bestNode=neighbors.get(0);
      }
      for (      AStarCoordinate n : neighbors) {
        try {
          return IDAStar(n,currentGoal);
        }
 catch (        Exception e) {
        }
      }
    }
  }
  throw new Exception("String_Node_Str");
}
Program: 40133
Project: 40133
Buggy source:
public void writeToOutput() throws IOException {
  for (int i=1; i <= resultList.size(); i++) {
    int x=resultList.get(i - 1).getX();
    int y=resultList.get(i - 1).getY();
    writer.append(Integer.toString(x) + ',' + Integer.toString(y)+ '\n');
  }
  writer.close();
}

Fixed version (ground truth):
public void writeToOutput() throws IOException {
  try {
    for (int i=1; i <= resultList.size(); i++) {
      int x=resultList.get(i - 1).getX();
      int y=resultList.get(i - 1).getY();
      writer.append(Integer.toString(x) + ',' + Integer.toString(y)+ '\n');
    }
  }
 catch (  Exception e) {
    System.out.println(e.getMessage());
  }
  writer.close();
}
Program: 40134
Project: 40134
Buggy source:
public void AStarSearch(ArrayList<AStarCoordinate> coords) throws Exception {
  AStarCoordinate thisCoord=coords.get(0);
  double goalAngle;
  Coordinate interimGoal;
  ArrayList<AStarCoordinate> tempPath=new ArrayList<AStarCoordinate>();
  while (!thisCoord.equals(goal)) {
    goalAngle=getAngleToGoal(thisCoord,goal);
    if (getDistanceToPoint(thisCoord,goal) > fieldOfView) {
      interimGoal=new Coordinate((int)(thisCoord.getX() + (fieldOfView * Math.cos(goalAngle))),(int)(thisCoord.getY() + (fieldOfView * Math.sin(goalAngle))));
    }
 else {
      interimGoal=goal;
    }
    tempPath.clear();
    tempPath.add(thisCoord);
    try {
      tempPath=AStar(tempPath,interimGoal);
    }
 catch (    Exception e) {
      throw e;
    }
    coords.addAll(tempPath);
    thisCoord=coords.get(coords.size() - 1);
  }
  output=new TerminalOutput(path);
}

Fixed version (ground truth):
public void AStarSearch(ArrayList<AStarCoordinate> coords) throws Exception {
  AStarCoordinate thisCoord=coords.get(0);
  double goalAngle;
  ArrayList<AStarCoordinate> tempPath=new ArrayList<AStarCoordinate>();
  while (!thisCoord.equals(goal)) {
    goalAngle=getAngleToGoal(thisCoord,goal);
    if (getDistanceToPoint(thisCoord,goal) > fieldOfView) {
      interimGoal=new Coordinate((int)(thisCoord.getX() + ((fieldOfView - 1) * Math.cos(Math.toRadians(goalAngle)))),(int)(thisCoord.getY() + ((fieldOfView - 1) * Math.sin(Math.toRadians(goalAngle)))));
    }
 else {
      interimGoal=goal;
    }
    tempPath.clear();
    tempPath.add(new AStarCoordinate(thisCoord.getX(),thisCoord.getY()));
    try {
      tempPath=AStar(tempPath,interimGoal);
    }
 catch (    Exception e) {
      throw e;
    }
    coords.addAll(tempPath);
    thisCoord=coords.get(coords.size() - 1);
  }
  output=new TerminalOutput(path);
}
Program: 40135
Project: 40135
Buggy source:
/** 
 * Find a path from start to goal with A*. Then output it. Throw an exception if a path cannot be found.
 * @param unvisitedCoords The list of coordinates being considered by the algorithm.
 */
public ArrayList<AStarCoordinate> AStar(ArrayList<AStarCoordinate> unvisitedCoords,Coordinate currentGoal) throws Exception {
  if (unvisitedCoords.isEmpty()) {
    throw new Exception("String_Node_Str");
  }
 else {
    AStarCoordinate thisCoord=unvisitedCoords.get(0);
    visitedCoords.add(thisCoord);
    if (thisCoord.equals(goal)) {
      return constructPath(thisCoord);
    }
 else {
      ArrayList<AStarCoordinate> unvisitedNeighbors=getReachableUnvisitedNeighbors(thisCoord);
      for (      AStarCoordinate n : unvisitedNeighbors) {
        if (!coordIsInSet(n,unvisitedCoords))         unvisitedCoords.add(n);
      }
      sortCoordinatesByCost(unvisitedCoords);
      unvisitedCoords.remove(thisCoord);
      return AStar(unvisitedCoords,currentGoal);
    }
  }
}

Fixed version (ground truth):
/** 
 * Find a path from start to goal with A*. Then output it. Throw an exception if a path cannot be found.
 * @param unvisitedCoords The list of coordinates being considered by the algorithm.
 */
public ArrayList<AStarCoordinate> AStar(ArrayList<AStarCoordinate> unvisitedCoords,Coordinate currentGoal) throws Exception {
  if (unvisitedCoords.isEmpty()) {
    throw new Exception("String_Node_Str");
  }
 else {
    AStarCoordinate thisCoord=unvisitedCoords.get(0);
    visitedCoords.add(thisCoord);
    if (thisCoord.equals(currentGoal)) {
      return constructPath(thisCoord);
    }
 else {
      ArrayList<AStarCoordinate> unvisitedNeighbors=getReachableUnvisitedNeighbors(thisCoord);
      for (      AStarCoordinate n : unvisitedNeighbors) {
        if (!coordIsInSet(n,unvisitedCoords))         unvisitedCoords.add(n);
      }
      sortCoordinatesByCost(unvisitedCoords);
      unvisitedCoords.remove(thisCoord);
      return AStar(unvisitedCoords,currentGoal);
    }
  }
}
Program: 40136
Project: 40136
Buggy source:
/** 
 * Given a set of coordinates, sort them according to their overall cost, which is the euclidean distance to the rover's goal coordinate plus the distance traveled from the start to a coordinate.
 */
public void sortCoordinatesByCost(ArrayList<AStarCoordinate> coords){
  for (  AStarCoordinate c : coords) {
    c.setDistanceToGoal(getDistanceToPoint(c,goal));
  }
  Collections.sort(coords);
}

Fixed version (ground truth):
/** 
 * Given a set of coordinates, sort them according to their overall cost, which is the euclidean distance to the rover's goal coordinate plus the distance traveled from the start to a coordinate.
 */
public void sortCoordinatesByCost(ArrayList<AStarCoordinate> coords){
  for (  AStarCoordinate c : coords) {
    c.setDistanceToGoal(getDistanceToPoint(c,interimGoal));
  }
  Collections.sort(coords);
}
Program: 40138
Project: 40138
Buggy source:
public void AStarSearch(ArrayList<AStarCoordinate> coords) throws Exception {
  AStarCoordinate thisCoord=coords.get(0);
  double goalAngle;
  ArrayList<AStarCoordinate> tempPath=new ArrayList<AStarCoordinate>();
  while (!thisCoord.equals(goal)) {
    goalAngle=getAngleToGoal(thisCoord,goal);
    if (getDistanceToPoint(thisCoord,goal) > fieldOfView) {
      interimGoal=new Coordinate((int)(thisCoord.getX() + ((fieldOfView - 1) * Math.cos(Math.toRadians(goalAngle)))),(int)(thisCoord.getY() + ((fieldOfView - 1) * Math.sin(Math.toRadians(goalAngle)))));
    }
 else {
      interimGoal=goal;
    }
    tempPath.clear();
    tempPath.add(new AStarCoordinate(thisCoord.getX(),thisCoord.getY()));
    try {
      tempPath=AStar(tempPath,interimGoal);
    }
 catch (    Exception e) {
      throw e;
    }
    coords.addAll(tempPath);
    thisCoord=coords.get(coords.size() - 1);
  }
  output=new TerminalOutput(path);
}

Fixed version (ground truth):
public void AStarSearch(ArrayList<AStarCoordinate> coords) throws Exception {
  AStarCoordinate thisCoord=coords.get(0);
  AStarCoordinate backCoord;
  int backtrackDistance=0;
  double goalAngle;
  ArrayList<AStarCoordinate> tempPath=new ArrayList<AStarCoordinate>();
  while (!thisCoord.equals(goal)) {
    goalAngle=getAngleToGoal(thisCoord,goal);
    if (getDistanceToPoint(thisCoord,goal) > fieldOfView) {
      interimGoal=new Coordinate((int)(thisCoord.getX() + ((fieldOfView) * Math.cos(Math.toRadians(goalAngle)))),(int)(thisCoord.getY() + ((fieldOfView) * Math.sin(Math.toRadians(goalAngle)))));
    }
 else {
      interimGoal=goal;
    }
    tempPath.clear();
    visitedCoords.clear();
    tempPath.add(new AStarCoordinate(thisCoord.getX(),thisCoord.getY()));
    tempPath.get(0).setCostSoFar(0);
    try {
      tempPath=AStar(tempPath,interimGoal);
      if (tempPath.get(tempPath.size() - 1).equals(goal)) {
        coords.addAll(tempPath.subList(1,tempPath.size()));
      }
 else {
        coords.addAll(tempPath.subList(1,tempPath.size()));
      }
      backtrackDistance=0;
    }
 catch (    Exception e) {
      if (coords.get(0).equals(thisCoord)) {
        throw e;
      }
 else {
        System.out.printf("String_Node_Str");
        backtrackDistance++;
        backCoord=coords.get(coords.size() - 1 - backtrackDistance);
        coords.add(backCoord);
        backtrackDistance++;
      }
    }
    thisCoord=coords.get(coords.size() - 1);
    System.out.println((thisCoord.getX()) + "String_Node_Str" + (thisCoord.getY()));
  }
  output=new TerminalOutput(path);
  output=new MapImageOutput(path,map.getMapPath());
}
Program: 40139
Project: 40139
Buggy source:
/** 
 * Find a path from start to goal with A*. Then output it. Throw an exception if a path cannot be found.
 * @param unvisitedCoords The list of coordinates being considered by the algorithm.
 */
public ArrayList<AStarCoordinate> AStar(ArrayList<AStarCoordinate> unvisitedCoords,Coordinate currentGoal) throws Exception {
  if (unvisitedCoords.isEmpty()) {
    throw new Exception("String_Node_Str");
  }
 else {
    AStarCoordinate thisCoord=unvisitedCoords.get(0);
    visitedCoords.add(thisCoord);
    if (thisCoord.equals(currentGoal)) {
      return constructPath(thisCoord);
    }
 else {
      ArrayList<AStarCoordinate> unvisitedNeighbors=getReachableUnvisitedNeighbors(thisCoord);
      for (      AStarCoordinate n : unvisitedNeighbors) {
        if (!coordIsInSet(n,unvisitedCoords))         unvisitedCoords.add(n);
      }
      sortCoordinatesByCost(unvisitedCoords);
      unvisitedCoords.remove(thisCoord);
      return AStar(unvisitedCoords,currentGoal);
    }
  }
}

Fixed version (ground truth):
/** 
 * Find a path from start to goal with A*. Then output it. Throw an exception if a path cannot be found.
 * @param unvisitedCoords The list of coordinates being considered by the algorithm.
 */
public ArrayList<AStarCoordinate> AStar(ArrayList<AStarCoordinate> unvisitedCoords,Coordinate currentGoal) throws Exception {
  if (unvisitedCoords.isEmpty()) {
    AStarCoordinate targetCoord=new AStarCoordinate(0,0);
    for (    AStarCoordinate n : visitedCoords) {
      if (n.getDistanceToGoal() < targetCoord.getDistanceToGoal()) {
        targetCoord=n;
      }
    }
    if (targetCoord.getDistanceToGoal() < (fieldOfView - 1)) {
      return constructPath(targetCoord);
    }
 else {
      throw new Exception("String_Node_Str");
    }
  }
 else {
    AStarCoordinate thisCoord=unvisitedCoords.get(0);
    visitedCoords.add(thisCoord);
    if (thisCoord.equals(currentGoal)) {
      return constructPath(thisCoord);
    }
 else {
      ArrayList<AStarCoordinate> unvisitedNeighbors=getReachableUnvisitedNeighbors(thisCoord);
      for (      AStarCoordinate n : unvisitedNeighbors) {
        if (!coordIsInSet(n,unvisitedCoords))         unvisitedCoords.add(n);
      }
      sortCoordinatesByCost(unvisitedCoords);
      unvisitedCoords.remove(thisCoord);
      return AStar(unvisitedCoords,currentGoal);
    }
  }
}
Program: 40142
Project: 40142
Buggy source:
public void startAlgorithm(){
  if (alg.equalsIgnoreCase("String_Node_Str")) {
    MarsRover r=new MarsRover(slope,startCoords,endCoords,mapPath);
    algorithm=new OptimalAlgorithm(map,r);
    algorithm.findPath();
  }
 else   if (alg.equalsIgnoreCase("String_Node_Str")) {
    MarsRover r=new MarsRover(slope,startCoords,endCoords,mapPath,fieldOfView);
    algorithm=new SuboptimalAlgorithm(map,r);
    algorithm.findPath();
  }
 else {
    System.out.println("String_Node_Str");
  }
}

Fixed version (ground truth):
public void startAlgorithm(){
  if (alg.equalsIgnoreCase("String_Node_Str")) {
    MarsRover r=new MarsRover(slope,startCoords,endCoords,mapPath);
    algorithm=new AlgorithmUnlimitedScope(map,r);
    algorithm.findPath();
  }
 else   if (alg.equalsIgnoreCase("String_Node_Str")) {
    MarsRover r=new MarsRover(slope,startCoords,endCoords,mapPath,fieldOfView);
    algorithm=new AlgorithmLimitedScope(map,r);
    algorithm.findPath();
  }
 else {
    System.out.println("String_Node_Str");
  }
}
Program: 40144
Project: 40144
Buggy source:
/** 
 * Create a resized image to fill the maxWidth/maxHeight values,the quality value and the angle value
 * @param realPath
 * @param initialWidth
 * @param initialHeight
 * @return resized file
 */
private File getResizedImage(final String realPath,final int initialWidth,final int initialHeight){
  Bitmap photo=BitmapFactory.decodeFile(realPath);
  Bitmap scaledphoto=null;
  if (maxWidth == 0) {
    maxWidth=initialWidth;
  }
  if (maxHeight == 0) {
    maxHeight=initialHeight;
  }
  double widthRatio=(double)maxWidth / initialWidth;
  double heightRatio=(double)maxHeight / initialHeight;
  double ratio=(widthRatio < heightRatio) ? widthRatio : heightRatio;
  Matrix matrix=new Matrix();
  matrix.postRotate(angle);
  matrix.postScale((float)ratio,(float)ratio);
  scaledphoto=Bitmap.createBitmap(photo,0,0,photo.getWidth(),photo.getHeight(),matrix,true);
  ByteArrayOutputStream bytes=new ByteArrayOutputStream();
  scaledphoto.compress(Bitmap.CompressFormat.JPEG,quality,bytes);
  File f=createNewFile();
  FileOutputStream fo;
  try {
    fo=new FileOutputStream(f);
    try {
      fo.write(bytes.toByteArray());
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
  if (photo != null) {
    photo.recycle();
    photo=null;
  }
  return f;
}

Fixed version (ground truth):
/** 
 * Create a resized image to fill the maxWidth/maxHeight values,the quality value and the angle value
 * @param realPath
 * @param initialWidth
 * @param initialHeight
 * @return resized file
 */
private File getResizedImage(final String realPath,final int initialWidth,final int initialHeight){
  Bitmap photo=BitmapFactory.decodeFile(realPath);
  Bitmap scaledphoto=null;
  if (maxWidth == 0) {
    maxWidth=initialWidth;
  }
  if (maxHeight == 0) {
    maxHeight=initialHeight;
  }
  double widthRatio=(double)maxWidth / initialWidth;
  double heightRatio=(double)maxHeight / initialHeight;
  double ratio=(widthRatio < heightRatio) ? widthRatio : heightRatio;
  Matrix matrix=new Matrix();
  matrix.postRotate(angle);
  matrix.postScale((float)ratio,(float)ratio);
  scaledphoto=Bitmap.createBitmap(photo,0,0,photo.getWidth(),photo.getHeight(),matrix,true);
  ByteArrayOutputStream bytes=new ByteArrayOutputStream();
  scaledphoto.compress(Bitmap.CompressFormat.JPEG,quality,bytes);
  File f=createNewFile();
  FileOutputStream fo;
  try {
    fo=new FileOutputStream(f);
    try {
      fo.write(bytes.toByteArray());
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
  if (photo != null) {
    scaledphoto.recycle();
    photo.recycle();
    scaledphoto=null;
    photo=null;
  }
  return f;
}
Program: 40145
Project: 40145
Buggy source:
public List<PlayerBoard> getPlayerBoards(){
  List<PlayerBoard> playerList=new ArrayList<>();
  for (  PlayerBoard playerBoard : brainySnakePlayers.values()) {
    playerList.add(playerBoard);
  }
  return playerList;
}

Fixed version (ground truth):
/** 
 * @return List of {@link PlayerBoard}
 */
public List<PlayerBoard> getPlayerBoards(){
  List<PlayerBoard> playerList=new ArrayList<>();
  for (  PlayerBoard playerBoard : brainySnakePlayers.values()) {
    playerList.add(playerBoard);
  }
  return playerList;
}
Program: 40146
Project: 40146
Buggy source:
public void reset(){
  gameMaster=new GameMaster(new Level(HEIGHT,WIDTH,Color.WHITE));
}

Fixed version (ground truth):
public void reset(){
  GameBoard.getINSTANCE().reset();
}
Program: 40147
Project: 40147
Buggy source:
/** 
 * Creates a sorted Map of the players according to the points
 * @return Keys are the score as Integer and the value is a ArrayList with the PlayerHandlers with this score
 */
public SortedMap<Long,ArrayList<PlayerBoard>> createSortedWinnerMap(){
  SortedMap<Long,ArrayList<PlayerBoard>> sortedMap=new TreeMap<>();
  for (  PlayerBoard playerHandler : GameBoard.getINSTANCE().getPlayerBoards()) {
    if (sortedMap.containsKey(playerHandler.getSize())) {
      sortedMap.get(playerHandler.getSize()).add(playerHandler);
    }
 else {
      ArrayList<PlayerBoard> playerHandlers=new ArrayList<PlayerBoard>(){
{
          add(playerHandler);
        }
      }
;
      sortedMap.put(playerHandler.getSize(),playerHandlers);
    }
  }
  return sortedMap;
}

Fixed version (ground truth):
/** 
 * Creates a sorted Map of the players according to the points
 * @return Keys are the score as Integer and the value is a ArrayList with the PlayerHandlers with this score
 */
public SortedMap<Long,ArrayList<PlayerBoard>> createSortedWinnerMap(){
  SortedMap<Long,ArrayList<PlayerBoard>> sortedMap=new TreeMap<>();
  for (  PlayerBoard playerBoard : GameBoard.getINSTANCE().getPlayerBoards()) {
    if (sortedMap.containsKey(playerBoard.getSize())) {
      sortedMap.get(playerBoard.getSize()).add(playerBoard);
    }
 else {
      ArrayList<PlayerBoard> playerHandlers=new ArrayList<PlayerBoard>(){
{
          add(playerBoard);
        }
      }
;
      sortedMap.put(playerBoard.getSize(),playerHandlers);
    }
  }
  return sortedMap;
}
Program: 40149
Project: 40149
Buggy source:
public GameMaster(){
  brainySnake=new BrainySnake();
  brainySnake.initialize();
  brainySnake.create();
  levelBoard=new LevelBoard(Config.LEVEL_WIDTH,Config.LEVEL_HEIGHT);
  GameBoard gameBoard=GameBoard.getINSTANCE();
  GlobalGameState.initialize(gameBoard.getRemainingRoundsToPlay());
  playerController=new PlayerController(gameBoard.getBrainySnakePlayers(),levelBoard);
}

Fixed version (ground truth):
public GameMaster(GameBoard gameBoard){
  brainySnake=new BrainySnake();
  brainySnake.initialize();
  brainySnake.create();
  levelBoard=new LevelBoard(Config.LEVEL_WIDTH,Config.LEVEL_HEIGHT);
  this.gameBoard=gameBoard;
  GlobalGameState.initialize(gameBoard.getRemainingRoundsToPlay());
  playerController=new PlayerController(gameBoard.getBrainySnakePlayers(),levelBoard);
}
Program: 40150
Project: 40150
Buggy source:
/** 
 * Updates the meta information of the game and the player in the gameboard
 */
private void updateGameBaordData(){
  GameBoard.getINSTANCE().updateGameBoard(GlobalGameState.movesRemaining());
}

Fixed version (ground truth):
/** 
 * Updates the meta information of the game and the player in the gameboard
 */
private void updateGameBaordData(){
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    playerHandler.updatePlayerBoard();
  }
  gameBoard.updateGameBoard(GlobalGameState.movesRemaining());
}
Program: 40151
Project: 40151
Buggy source:
private void validateEvents(PlayerHandler playerHandler,PlayerChoice playerChoice){
  List<RoundEvent> roundEvents=playerHandler.getRoundEvents();
  if (playerHandler.isDead() || playerHandler.getSnake().countPoints() <= 1) {
    roundEvents.add(DIED);
    playerHandler.kill();
    return;
  }
  if (!playerChoice.isHasChosen() || !playerHandler.isOrientationValid(playerChoice.getOrientation())) {
    roundEvents.add(CONFUSED);
    playerHandler.setConfused(true);
    return;
  }
  Point2D nextPosition=playerHandler.getNextPositionBy(playerChoice.getOrientation());
  if (levelBoard.checkCollision(nextPosition)) {
    roundEvents.add(COLLISION_WITH_LEVEL);
    playerHandler.setConfused(true);
    return;
  }
  playerHandler.setCurrentOrientation(playerChoice.getOrientation());
  roundEvents.add(MOVED);
  playerHandler.setConfused(false);
  for (  PlayerHandler player : playerController.getPlayerHandlerList()) {
    if (!playerHandler.isGhostMode() && player.gotBitten(nextPosition)) {
      if (player.equals(playerHandler)) {
        roundEvents.add(BIT_HIMSELF);
      }
 else {
        roundEvents.add(BIT_AGENT);
        player.getRoundEvents().add(BIT_BY_PLAYER);
      }
      playerHandler.setGhostMode();
    }
  }
  if (!playerHandler.isGhostMode() && levelBoard.tryConsumePoint(nextPosition)) {
    roundEvents.add(CONSUMED_POINT);
  }
}

Fixed version (ground truth):
private void validateEvents(PlayerHandler playerHandler,PlayerChoice playerChoice){
  List<RoundEvent> roundEvents=playerHandler.getRoundEvents();
  if (playerHandler.isDead() || playerHandler.getSnake().countPoints() <= 1) {
    roundEvents.add(DIED);
    return;
  }
  if (!playerChoice.isHasChosen() || !playerHandler.isOrientationValid(playerChoice.getOrientation())) {
    roundEvents.add(CONFUSED);
    playerHandler.setConfused(true);
    return;
  }
  Point2D nextPosition=playerHandler.getNextPositionBy(playerChoice.getOrientation());
  if (levelBoard.checkCollision(nextPosition)) {
    roundEvents.add(COLLISION_WITH_LEVEL);
    playerHandler.setConfused(true);
    return;
  }
  playerHandler.setCurrentOrientation(playerChoice.getOrientation());
  roundEvents.add(MOVED);
  playerHandler.setConfused(false);
  for (  PlayerHandler player : playerController.getPlayerHandlerList()) {
    if (!playerHandler.isGhostMode() && player.gotBitten(nextPosition)) {
      if (player.equals(playerHandler)) {
        roundEvents.add(BIT_HIMSELF);
      }
 else {
        roundEvents.add(BIT_AGENT);
        player.getRoundEvents().add(BIT_BY_PLAYER);
      }
      playerHandler.setGhostMode();
    }
  }
  if (!playerHandler.isGhostMode() && levelBoard.tryConsumePoint(nextPosition)) {
    roundEvents.add(CONSUMED_POINT);
  }
}
Program: 40152
Project: 40152
Buggy source:
public void updateGame(){
  brainySnake.updateLevelPoints(levelBoard.getPoints(),levelBoard.getBarriers(),levelBoard.getWalls());
  List<LevelObject> snakes=new ArrayList<>();
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    Snake snake=playerHandler.getSnake();
    snakes.add(snake.getHead());
    snakes.add(snake.getBody());
    if (Config.RENDER_PLAYERVIEW && playerHandler.getPlayerView() != null) {
      snakes.addAll(drawPlayerView(playerHandler.getPlayerView()));
    }
  }
  brainySnake.updateSnakes(snakes);
  brainySnake.render();
}

Fixed version (ground truth):
public void updateGame(){
  brainySnake.updateLevelPoints(levelBoard.getPoints(),levelBoard.getBarriers(),levelBoard.getWalls());
  List<LevelObject> snakes=new ArrayList<>();
  for (  PlayerHandler playerHandler : playerController.getPlayerHandlerList()) {
    Snake snake=playerHandler.getSnake();
    if (Config.RENDER_PLAYERVIEW && playerHandler.getPlayerView() != null) {
      snakes.addAll(drawPlayerView(playerHandler.getPlayerView()));
    }
    snakes.add(snake.getBody());
    snakes.add(snake.getHead());
  }
  brainySnake.updateSnakes(snakes);
  brainySnake.render();
}
Program: 40154
Project: 40154
Buggy source:
public PlayerController(Map<Long,PlayerBoard> playerMap,LevelBoard levelBoard){
  for (  PlayerBoard player : playerMap.values()) {
    Snake newPlayerSnake=levelBoard.createStartingGameObject(Config.INITIAL_PLAYER_LENGTH,player.getColor());
    playerHandlerList.add(new PlayerHandler(player.getBrainySnakePlayer(),newPlayerSnake));
  }
  playerStatePushExecutorService=new PlayerStatePushExecutorService(playerHandlerList,Config.MAX_AGENT_PROCESSING_TIME_MS);
  playerUpdateGetExecutorService=new PlayerUpdateGetExecutorService(playerHandlerList,Config.MAX_AGENT_PROCESSING_TIME_MS);
}

Fixed version (ground truth):
public PlayerController(Map<Long,PlayerBoard> playerMap,LevelBoard levelBoard){
  for (  PlayerBoard player : playerMap.values()) {
    Snake newPlayerSnake=levelBoard.createStartingGameObject(Config.INITIAL_PLAYER_LENGTH,player.getColor());
    playerHandlerList.add(new PlayerHandler(player,newPlayerSnake));
  }
  playerStatePushExecutorService=new PlayerStatePushExecutorService(playerHandlerList,Config.MAX_AGENT_PROCESSING_TIME_MS);
  playerUpdateGetExecutorService=new PlayerUpdateGetExecutorService(playerHandlerList,Config.MAX_AGENT_PROCESSING_TIME_MS);
}
Program: 40155
Project: 40155
Buggy source:
public PlayerHandler(BrainySnakePlayer brainySnakePlayer,Snake snake){
  this.brainySnakePlayer=brainySnakePlayer;
  this.currentOrientation=snake.getStartOrientation();
  this.snake=snake;
  this.playerIdentifier=UUID.randomUUID();
}

Fixed version (ground truth):
public PlayerHandler(PlayerBoard playerBoard,Snake snake){
  this.playerBoard=playerBoard;
  this.currentOrientation=snake.getStartOrientation();
  this.snake=snake;
  this.playerIdentifier=UUID.randomUUID();
}
Program: 40156
Project: 40156
Buggy source:
public void penalty(){
  if (snake.countPoints() <= 1) {
    dead=true;
  }
 else {
    snake.removeTail();
  }
}

Fixed version (ground truth):
public void penalty(){
  if (snake.countPoints() <= 1) {
    kill();
    LOGGER.info("String_Node_Str",playerBoard.getName());
  }
 else {
    snake.removeTail();
  }
}
Program: 40157
Project: 40157
Buggy source:
public void update(){
  if (dead) {
    return;
  }
  if (ghostMode) {
    ghostMode();
  }
 else   if (confused) {
    blink();
  }
 else {
    snake.reset();
  }
}

Fixed version (ground truth):
public void update(){
  if (isDead) {
    return;
  }
  if (isGhostMode) {
    ghostMode();
  }
 else   if (isConfused) {
    blink();
  }
 else {
    snake.reset();
  }
}
Program: 40158
Project: 40158
Buggy source:
private void ghostMode(){
  if (ghostTime++ > Config.GHOST_TIME) {
    ghostTime=0;
    snake.reset();
    ghostMode=false;
  }
 else {
    snake.setGhostMode();
  }
}

Fixed version (ground truth):
private void ghostMode(){
  if (ghostTime++ > Config.GHOST_TIME) {
    ghostTime=0;
    snake.reset();
    isGhostMode=false;
  }
 else {
    snake.setGhostMode();
  }
}
Program: 40159
Project: 40159
Buggy source:
private void blink(){
  if (blinkTime++ > Config.BLINK_TIME) {
    blinkTime=0;
    blinked=!blinked;
  }
  if (blinked) {
    snake.reset();
  }
 else {
    snake.blink();
  }
}

Fixed version (ground truth):
private void blink(){
  if (blinkTime++ > Config.BLINK_TIME) {
    blinkTime=0;
    isBlinking=!isBlinking;
  }
  if (isBlinking) {
    snake.reset();
  }
 else {
    snake.blink();
  }
}
Program: 40160
Project: 40160
Buggy source:
public void setGhostMode(){
  ghostMode=true;
  ghostTime=0;
}

Fixed version (ground truth):
public void setGhostMode(){
  isGhostMode=true;
  ghostTime=0;
}
Program: 40161
Project: 40161
Buggy source:
public boolean isDead(){
  return dead;
}

Fixed version (ground truth):
public boolean isDead(){
  return isDead;
}
Program: 40162
Project: 40162
Buggy source:
public boolean isGhostMode(){
  return ghostMode;
}

Fixed version (ground truth):
public boolean isGhostMode(){
  return isGhostMode;
}
Program: 40163
Project: 40163
Buggy source:
public void moveToNextPosition(){
  this.snake.setNextPosition(nextPositionIs(currentOrientation));
  confused=false;
}

Fixed version (ground truth):
public void moveToNextPosition(){
  this.snake.setNextPosition(nextPositionIs(currentOrientation));
  isConfused=false;
}
Program: 40164
Project: 40164
Buggy source:
public void setConfused(boolean confused){
  this.confused=confused;
}

Fixed version (ground truth):
public void setConfused(boolean confused){
  this.isConfused=confused;
}
Program: 40165
Project: 40165
Buggy source:
/** 
 * Requests the next Update (step) from the Agent (Player) Warning: Call this Method from Thread or Test only
 * @return PlayerUpdate (this can be null
 */
PlayerUpdate requestPlayerUpdate(){
  return brainySnakePlayer.tellPlayerUpdate();
}

Fixed version (ground truth):
/** 
 * Requests the next Update (step) from the Agent (Player) Warning: Call this Method from Thread or Test only
 * @return PlayerUpdate (this can be null
 */
PlayerUpdate requestPlayerUpdate(){
  return playerBoard.getBrainySnakePlayer().tellPlayerUpdate();
}
Program: 40166
Project: 40166
Buggy source:
public void kill(){
  dead=true;
  Gdx.app.log("String_Node_Str","String_Node_Str" + brainySnakePlayer.getPlayerName() + "String_Node_Str");
}

Fixed version (ground truth):
public void kill(){
  isDead=true;
  snake.clear();
}
Program: 40167
Project: 40167
Buggy source:
/** 
 * Sends the last PlayerState to the Agent Warning: Call this Method from Thread or Test only
 * @return if processing was successful. (This can be ignored)
 */
Boolean sendPlayerState(){
  return this.brainySnakePlayer.handlePlayerStatusUpdate(this.lastPlayerState);
}

Fixed version (ground truth):
/** 
 * Sends the last PlayerState to the Agent Warning: Call this Method from Thread or Test only
 * @return if processing was successful. (This can be ignored)
 */
Boolean sendPlayerState(){
  return playerBoard.getBrainySnakePlayer().handlePlayerStatusUpdate(this.lastPlayerState);
}
Program: 40168
Project: 40168
Buggy source:
/** 
 * Calculates the next PlayerState from global GameData
 */
public void calculatePlayerState(){
  int points=snake.countPoints();
  Point2D head=snake.getHeadPosition();
  Point2D tail;
  if (points > 1) {
    tail=snake.getTailPosition();
  }
 else {
    tail=null;
  }
  int ghostModeRemaining=Config.GHOST_TIME - ghostTime;
  boolean bitByPlayer=false;
  boolean moved=false;
  boolean collisionWithLevel=false;
  for (  RoundEvent roundEvent : roundEvents) {
switch (roundEvent) {
case BIT_BY_PLAYER:
      bitByPlayer=true;
    break;
case MOVED:
  moved=true;
break;
case COLLISION_WITH_LEVEL:
collisionWithLevel=true;
break;
}
}
this.lastPlayerState=new PlayerState(GlobalGameState.getPastRounds(),GlobalGameState.movesRemaining(),points,head,tail,ghostMode,ghostModeRemaining,bitByPlayer,moved,collisionWithLevel,playerView);
}

Fixed version (ground truth):
/** 
 * Calculates the next PlayerState from global GameData
 */
public void calculatePlayerState(){
  int points=snake.countPoints();
  Point2D head=snake.getHeadPosition();
  Point2D tail;
  if (points > 1) {
    tail=snake.getTailPosition();
  }
 else {
    tail=null;
  }
  int ghostModeRemaining=Config.GHOST_TIME - ghostTime;
  boolean bitByPlayer=false;
  boolean moved=false;
  boolean collisionWithLevel=false;
  for (  RoundEvent roundEvent : roundEvents) {
switch (roundEvent) {
case BIT_BY_PLAYER:
      bitByPlayer=true;
    break;
case MOVED:
  moved=true;
break;
case COLLISION_WITH_LEVEL:
collisionWithLevel=true;
break;
}
}
this.lastPlayerState=new PlayerState(GlobalGameState.getPastRounds(),GlobalGameState.movesRemaining(),points,head,tail,isGhostMode,ghostModeRemaining,bitByPlayer,moved,collisionWithLevel,playerView);
}