nus-yam/ex-repair huggingface dataset:
Program: 40485
Project: 40485
Buggy source:
/** 
 * Run every scan in the background, with 10 seconds between scans.
 */
@Scheduled(fixedDelay=1000) public void scanTransactions(){
  try {
    Integer limit=50;
    for (Integer offset=0; offset < scanDepthTransactions; offset+=limit) {
      arkClient.getTransactions(offset).stream().forEach(transaction -> {
        if (StringUtils.isEmpty(transaction.getVendorField())) {
          return;
        }
        Message message=messageRepository.findOneByToken(transaction.getVendorField());
        if (message != null) {
          TransactionMatch transactionMatch=new TransactionMatch(transaction.getId(),message.getToken());
          try {
            log.info("String_Node_Str" + message.getCallbackUrl() + "String_Node_Str"+ message);
            callbackRestTemplate.postForEntity(message.getCallbackUrl(),transactionMatch,Void.class);
          }
 catch (          RestClientResponseException e) {
            log.error("String_Node_Str" + message.getCallbackUrl(),e);
            throw e;
          }
        }
      }
);
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * Run every scan in the background, with 10 seconds between scans.
 */
@Scheduled(fixedDelay=1000) public void scanTransactions(){
  try {
    Integer limit=50;
    for (Integer offset=0; offset < scanDepthTransactions; offset+=limit) {
      arkClient.getTransactions(offset).stream().forEach(transaction -> {
        if (StringUtils.isEmpty(transaction.getVendorField())) {
          return;
        }
        Message message=messageRepository.findOneByToken(transaction.getVendorField());
        if (message != null) {
          TransactionMatch transactionMatch=new TransactionMatch(transaction.getId(),message.getToken());
          try {
            callbackRestTemplate.postForEntity(message.getCallbackUrl(),transactionMatch,Void.class);
          }
 catch (          RestClientResponseException e) {
            log.error("String_Node_Str" + message.getCallbackUrl(),e);
            throw e;
          }
        }
      }
);
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str",e);
  }
}
Program: 40486
Project: 40486
Buggy source:
private static ValiWapper getFieldsFromCache(Class c){
  ValiWapper wapper=cache.get(c);
  if (wapper == null) {
    wapper=new ValiWapper();
    Field[] cFields=c.getDeclaredFields();
    NotNull notNull;
    Reg reg;
    for (    Field field : cFields) {
      notNull=field.getAnnotation(NotNull.class);
      reg=field.getAnnotation(Reg.class);
      if (notNull != null || reg != null) {
        if (notNull != null) {
          ValiModel valiModel=new ValiModel(notNull.order(),notNull.error(),null,field);
          wapper.addValiModel(valiModel);
        }
        if (reg != null) {
          ValiModel valiModel=new ValiModel(reg.order(),reg.error(),reg.reg(),field);
          wapper.addValiModel(valiModel);
        }
      }
    }
    Method[] methods=c.getMethods();
    for (    Method method : methods) {
      ValiSuccess valiSuccess=method.getAnnotation(ValiSuccess.class);
      if (valiSuccess != null) {
        wapper.setMethod(method);
      }
    }
    cache.put(c,wapper);
  }
  return wapper;
}

Fixed version (ground truth):
private static ValiWapper getFieldsFromCache(Class c){
  ValiWapper wapper=cache.get(c);
  if (wapper == null) {
    wapper=new ValiWapper();
    Field[] cFields=c.getDeclaredFields();
    NotNull notNull;
    Reg reg;
    for (    Field field : cFields) {
      field.setAccessible(true);
      notNull=field.getAnnotation(NotNull.class);
      reg=field.getAnnotation(Reg.class);
      if (notNull != null || reg != null) {
        if (notNull != null) {
          ValiModel valiModel=new ValiModel(notNull.order(),notNull.error(),null,field);
          wapper.addValiModel(valiModel);
        }
        if (reg != null) {
          ValiModel valiModel=new ValiModel(reg.order(),reg.error(),reg.reg(),field);
          wapper.addValiModel(valiModel);
        }
      }
    }
    Method[] methods=c.getMethods();
    for (    Method method : methods) {
      ValiSuccess valiSuccess=method.getAnnotation(ValiSuccess.class);
      if (valiSuccess != null) {
        wapper.setMethod(method);
      }
    }
    cache.put(c,wapper);
  }
  return wapper;
}
Program: 40489
Project: 40489
Buggy source:
/** 
 * Initializes the Engine and performs the main ticking loop.
 */
public Engine(GameGUI gameGUI,EngineContext engineContext) throws LoadMapFailedException {
  generateCPUScript();
  this.engineContext=engineContext;
  this.gameGUI=gameGUI;
  Map mp;
  try {
    mp=loadGameMap();
  }
 catch (  ResourceAlreadyLoadedException rale) {
    if (CACHEDMAP == null) {
      throw rale;
    }
    mp=CACHEDMAP;
    ENGINE_LOGGER.info("String_Node_Str");
  }
  this.gameGUI._map=mp;
  if (mp == null) {
    throw new LoadMapFailedException("String_Node_Str");
  }
  EntityMap em=parseEntityMap(mp);
  this.game=new Game(em);
  ENGINE_LOGGER.info("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Initializes the Engine and performs the main ticking loop.
 */
public Engine(GameGUI gameGUI,EngineContext engineContext) throws LoadMapFailedException {
  this.engineContext=engineContext;
  generateCPUScript();
  this.gameGUI=gameGUI;
  Map mp;
  try {
    mp=loadGameMap();
  }
 catch (  ResourceAlreadyLoadedException rale) {
    if (CACHEDMAP == null) {
      throw rale;
    }
    mp=CACHEDMAP;
    ENGINE_LOGGER.info("String_Node_Str");
  }
  this.gameGUI._map=mp;
  if (mp == null) {
    throw new LoadMapFailedException("String_Node_Str");
  }
  EntityMap em=parseEntityMap(mp);
  this.game=new Game(em);
  ENGINE_LOGGER.info("String_Node_Str");
}
Program: 40490
Project: 40490
Buggy source:
public EngineContext(String difficulty){
switch (difficulty.toLowerCase()) {
case "String_Node_Str":
    MAP_URL=ALL_MAP_URL[0];
  break;
case "String_Node_Str":
MAP_URL=ALL_MAP_URL[2];
break;
case "String_Node_Str":
default :
MAP_URL=ALL_MAP_URL[1];
}
}

Fixed version (ground truth):
public EngineContext(String difficulty){
switch (difficulty.toLowerCase()) {
case "String_Node_Str":
    MAP_URL=ALL_MAP_URL[0];
  this.difficulty="String_Node_Str";
break;
case "String_Node_Str":
MAP_URL=ALL_MAP_URL[2];
this.difficulty="String_Node_Str";
break;
case "String_Node_Str":
default :
MAP_URL=ALL_MAP_URL[1];
this.difficulty="String_Node_Str";
}
}
Program: 40491
Project: 40491
Buggy source:
/** 
 * Gets player tiles from Player layer Will need to refactor.  Basically first two objects found are added to list. 0 being player, 1 being opponent
 * @param map
 * @return
 */
private ArrayList<EntityTile> getPlayerTiles(Map map){
  ArrayList<Tile> playerTiles=new ArrayList<>();
  TileLayer playerLayer=(TileLayer)map.getLayer(2);
  int height;
  int width;
  try {
    height=playerLayer.getBounds().height;
    width=playerLayer.getBounds().width;
  }
 catch (  NullPointerException npe) {
    playerLayer.setOffset(0,0);
    height=playerLayer.getBounds().height;
    width=playerLayer.getBounds().width;
  }
  Point playerLocation=null;
  Point opponentLocation=null;
  Tile tile;
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      tile=playerLayer.getTileAt(x,y);
      if (tile == null) {
        continue;
      }
 else {
        if (playerTiles.size() == 0) {
          playerLocation=new Point(x,y);
        }
 else {
          opponentLocation=new Point(x,y);
        }
        playerTiles.add(tile);
      }
    }
  }
  Tile playerTile=playerTiles.get(0);
  Tile opponentTile=playerTiles.get(1);
  EntityTile playerEntityTile=new EntityTile(playerLocation,new Player(0,playerLocation),playerTile);
  EntityTile opponentEntityTile=new EntityTile(opponentLocation,new Player(1,opponentLocation),opponentTile);
  ArrayList<EntityTile> playerEntityTiles=new ArrayList<>();
  playerEntityTiles.add(playerEntityTile);
  playerEntityTiles.add(opponentEntityTile);
  return playerEntityTiles;
}

Fixed version (ground truth):
/** 
 * Gets player tiles from Player layer Will need to refactor.  Basically first two objects found are added to list. 0 being player, 1 being opponent
 * @param map
 * @return
 */
private ArrayList<EntityTile> getPlayerTiles(Map map){
  TileLayer playerLayer=(TileLayer)map.getLayer(PLAYER_LAYER);
  int height;
  int width;
  try {
    height=playerLayer.getBounds().height;
    width=playerLayer.getBounds().width;
  }
 catch (  NullPointerException npe) {
    playerLayer.setOffset(0,0);
    height=playerLayer.getBounds().height;
    width=playerLayer.getBounds().width;
  }
  ArrayList<Tile> playerTiles=new ArrayList<>();
  Point playerLocation=null;
  Point opponentLocation=null;
  Tile tile;
  for (int y=0; y < height; y++) {
    for (int x=0; x < width; x++) {
      tile=playerLayer.getTileAt(x,y);
      if (tile == null) {
        continue;
      }
 else {
        if (playerTiles.size() == 0) {
          playerLocation=new Point(x,y);
        }
 else {
          opponentLocation=new Point(x,y);
        }
        playerTiles.add(tile);
      }
    }
  }
  Tile playerTile=playerTiles.get(0);
  Tile opponentTile=playerTiles.get(1);
  EntityTile playerEntityTile=new EntityTile(playerLocation,new Player(0,playerLocation),playerTile);
  EntityTile opponentEntityTile=new EntityTile(opponentLocation,new Player(1,opponentLocation),opponentTile);
  ArrayList<EntityTile> playerEntityTiles=new ArrayList<>();
  playerEntityTiles.add(playerEntityTile);
  playerEntityTiles.add(opponentEntityTile);
  return playerEntityTiles;
}
Program: 40492
Project: 40492
Buggy source:
public void removeTile(Point location){
  EntityTile entityTile=this._entityTiles[location.x][location.y];
  getPlayerLayer().removeTile(entityTile.getTile());
  this._entityTiles[location.x][location.y]=new EntityTile(location,new Empty(location),getPlayerLayer().getTileAt(location.x,location.y));
}

Fixed version (ground truth):
/** 
 * Removes tile at specified location from map
 * @param location
 */
public void removeTile(Point location){
  EntityTile entityTile=this._entityTiles[location.x][location.y];
  getPlayerLayer().removeTile(entityTile.getTile());
  this._entityTiles[location.x][location.y]=new EntityTile(location,new Empty(location),getPlayerLayer().getTileAt(location.x,location.y));
}
Program: 40493
Project: 40493
Buggy source:
public boolean isInsideMap(Point point){
  if (point.x >= this._numberOfColumns || point.x < 0 || point.y >= this._numberOfRows || point.y < 0) {
    return false;
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Determines whether a point is inside the bounds of the game map
 * @param point
 * @return
 */
public boolean isInsideMap(Point point){
  if (point.x >= this._numberOfColumns || point.x < 0 || point.y >= this._numberOfRows || point.y < 0) {
    return false;
  }
  return true;
}
Program: 40494
Project: 40494
Buggy source:
/** 
 * Initializes a 2D representation of the game map
 * @param columns Number of columns
 * @param rows    Number of rows
 */
private void initializeMap(int columns,int rows){
  for (int x=0; x < columns; x++) {
    for (int y=0; y < rows; y++) {
      Point currentLocation=new Point(x,y);
      if (_playerTile.getLocation().equals(currentLocation)) {
        _entityTiles[x][y]=_playerTile;
      }
 else       if (_opponentTile.getLocation().equals(currentLocation)) {
        _entityTiles[x][y]=_opponentTile;
      }
 else {
        TileLayer playerLayer=(TileLayer)this._gameMap.getLayer(2);
        _entityTiles[x][y]=new EntityTile(currentLocation,new Empty(currentLocation),playerLayer.getTileAt(currentLocation.x,currentLocation.y));
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Initializes a 2D representation of the game map
 * @param columns Number of columns
 * @param rows    Number of rows
 */
private void initializeMap(int columns,int rows){
  for (int x=0; x < columns; x++) {
    for (int y=0; y < rows; y++) {
      Point currentLocation=new Point(x,y);
      if (_playerTile.getLocation().equals(currentLocation)) {
        _entityTiles[x][y]=_playerTile;
      }
 else       if (_opponentTile.getLocation().equals(currentLocation)) {
        _entityTiles[x][y]=_opponentTile;
      }
 else {
        TileLayer playerLayer=(TileLayer)this._gameMap.getLayer(PLAYER_LAYER);
        _entityTiles[x][y]=new EntityTile(currentLocation,new Empty(currentLocation),playerLayer.getTileAt(currentLocation.x,currentLocation.y));
      }
    }
  }
}
Program: 40495
Project: 40495
Buggy source:
/** 
 * Command to do nothing
 */
public void doNothing(int playerId){
  getPlayer(playerId).setShielding(false);
  return;
}

Fixed version (ground truth):
/** 
 * Command to do nothing
 */
public void doNothing(int playerId){
  getPlayer(playerId).setShielding(false);
}
Program: 40496
Project: 40496
Buggy source:
/** 
 * Evades from opposing player.  Will move in direction that is one space away from player.  Will only evade 87.5% of time
 * @param playerId
 * @param opponentId
 * @return
 */
public boolean evade(int playerId,int opponentId){
  stopDefending(playerId);
  if (getRandomBoolean()) {
    if (getRandomBoolean()) {
      if (getRandomBoolean()) {
        return false;
      }
    }
  }
  Player player=getPlayer(playerId);
  Player opponent=getPlayer(opponentId);
  int currentDistance=pathDistanceToLocation(player.getLocation(),opponent.getLocation());
  ArrayList<Point> potentialMoveLocations=getAllPossibleMoves(getPlayer(playerId).getLocation());
  Point playerCurrentLocation=getPlayer(playerId).getLocation();
  double longestDistance=-1;
  int longestMoveIndex=-1;
  for (int i=0; i < potentialMoveLocations.size(); i++) {
    Point moveLocation=getNewLocation(playerCurrentLocation,potentialMoveLocations.get(i));
    int distanceCandidate=pathDistanceToLocation(moveLocation,opponent.getLocation());
    if (distanceCandidate > longestDistance) {
      longestDistance=distanceCandidate;
      longestMoveIndex=i;
    }
    if (distanceCandidate == longestDistance) {
      if (getRandomBoolean()) {
        longestDistance=distanceCandidate;
        longestMoveIndex=i;
      }
    }
  }
  if (longestDistance > currentDistance) {
    return move(playerId,potentialMoveLocations.get(longestMoveIndex).x,potentialMoveLocations.get(longestMoveIndex).y);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Evades from opposing player.  Will move in direction that is one space away from player.  Will evade 87.5% of time
 * @param playerId
 * @param opponentId
 * @return
 */
public boolean evade(int playerId,int opponentId){
  stopDefending(playerId);
  if (getRandomBoolean()) {
    if (getRandomBoolean()) {
      if (getRandomBoolean()) {
        return false;
      }
    }
  }
  Player player=getPlayer(playerId);
  Player opponent=getPlayer(opponentId);
  int currentDistance=pathDistanceToLocation(player.getLocation(),opponent.getLocation());
  ArrayList<Point> potentialMoveLocations=getAllPossibleMoves(getPlayer(playerId).getLocation());
  Point playerCurrentLocation=getPlayer(playerId).getLocation();
  double longestDistance=-1;
  int longestMoveIndex=-1;
  for (int i=0; i < potentialMoveLocations.size(); i++) {
    Point moveLocation=getNewLocation(playerCurrentLocation,potentialMoveLocations.get(i));
    int distanceCandidate=pathDistanceToLocation(moveLocation,opponent.getLocation());
    if (distanceCandidate > longestDistance) {
      longestDistance=distanceCandidate;
      longestMoveIndex=i;
    }
    if (distanceCandidate == longestDistance) {
      if (getRandomBoolean()) {
        longestDistance=distanceCandidate;
        longestMoveIndex=i;
      }
    }
  }
  if (longestDistance > currentDistance) {
    return move(playerId,potentialMoveLocations.get(longestMoveIndex).x,potentialMoveLocations.get(longestMoveIndex).y);
  }
  return false;
}
Program: 40497
Project: 40497
Buggy source:
/** 
 * @param entityMap
 */
public Game(EntityMap entityMap){
  this._entityMap=entityMap;
  _previousLocations.add(getPlayer(PLAYER_ID).getLocation());
  _previousLocations.add(getPlayer(OPPONENT_ID).getLocation());
  _numberOfStalemateTurns.add(1);
  _numberOfStalemateTurns.add(1);
  _previousHealth.add(getPlayer(PLAYER_ID).getHealth());
  _previousHealth.add(getPlayer(OPPONENT_ID).getHealth());
}

Fixed version (ground truth):
/** 
 * Constructor for Game Object.  Need to pass in a reference to an EntityMap Object. Initialization of Tiled Map must occur before beginning game
 * @param entityMap Fully initialized entity map
 */
public Game(EntityMap entityMap){
  this._entityMap=entityMap;
  _previousLocations.add(getPlayer(PLAYER_ID).getLocation());
  _previousLocations.add(getPlayer(OPPONENT_ID).getLocation());
  _previousHealth.add(getPlayer(PLAYER_ID).getHealth());
  _previousHealth.add(getPlayer(OPPONENT_ID).getHealth());
  _numberOfStalemateTurns.add(1);
  _numberOfStalemateTurns.add(1);
}
Program: 40498
Project: 40498
Buggy source:
public int pathDistanceToLocation(Point location1,Point location2){
  int distanceX=location1.x - location2.x;
  int distanceY=location1.y - location2.y;
  return (Math.abs(distanceX) + Math.abs(distanceY)) - 1;
}

Fixed version (ground truth):
/** 
 * Number of tiles to get to target location using only horizontal and vertical movement
 * @param location1
 * @param location2
 * @return
 */
public int pathDistanceToLocation(Point location1,Point location2){
  int distanceX=location1.x - location2.x;
  int distanceY=location1.y - location2.y;
  return (Math.abs(distanceX) + Math.abs(distanceY)) - 1;
}
Program: 40499
Project: 40499
Buggy source:
/** 
 * Builds the set of Check objects from the present enumerators
 * @param scriptingObjects List of Scripting Enumerators to be parsed
 * @return Returns all check objects extracted from scriptingObjects
 */
private static ArrayList<Check> constructChecks(ArrayList<String> scriptingObjects){
  ArrayList<Check> checks=new ArrayList<>();
  for (int i=0; i < scriptingObjects.size(); i++) {
    String object=scriptingObjects.get(i);
    if (ScriptingTypes.DATA.list().contains(object)) {
      Operator op;
      try {
        op=getOperator(scriptingObjects.get(i + 1));
      }
 catch (      InstanceNotFoundException e) {
        e.printStackTrace();
        return null;
      }
      Check check=new Check(scriptingObjects.get(i),scriptingObjects.get(i + 2),op);
      checks.add(check);
      i=i + 2;
    }
  }
  return checks;
}

Fixed version (ground truth):
/** 
 * Builds the set of Check objects from the present enumerators
 * @param scriptingObjects List of Scripting Enumerators to be parsed
 * @return Returns all check objects extracted from scriptingObjects
 */
private static ArrayList<Check> constructChecks(ArrayList<String> scriptingObjects){
  ArrayList<Check> checks=new ArrayList<>();
  for (int i=0; i < scriptingObjects.size(); i++) {
    String object=scriptingObjects.get(i);
    if (ScriptingTypes.DATA.list().contains(object) || object.matches("String_Node_Str")) {
      Operator op;
      try {
        op=getOperator(scriptingObjects.get(i + 1));
      }
 catch (      InstanceNotFoundException e) {
        e.printStackTrace();
        return null;
      }
      Check check=new Check(scriptingObjects.get(i),scriptingObjects.get(i + 2),op);
      checks.add(check);
      i=i + 2;
    }
  }
  return checks;
}
Program: 40500
Project: 40500
Buggy source:
/** 
 * @return The current state of the game (inactive, running, won, lost, stalemate)
 */
public GameStatus getGameState(){
  System.out.println(game.getState());
  return game.getState();
}

Fixed version (ground truth):
/** 
 * @return The current state of the game (inactive, running, won, lost, stalemate)
 */
public GameStatus getGameState(){
  return game.getState();
}
Program: 40502
Project: 40502
Buggy source:
/** 
 * Based on the current game state data, returns if condition is true.
 * @param game takes in the model
 * @return if defined condition is true
 */
boolean conditionIsTrue(Game game){
  int data1=getData(this.data1,game);
  int data2=getData(this.data2,game);
switch (this.operator) {
case LESS_THAN:
    return data1 < data2;
case GREATER_THAN:
  return data1 > data2;
case LESS_THAN_OR_EQUAL_TO:
return data1 <= data2;
case GREATER_THAN_OR_EQUAL_TO:
return data1 >= data2;
case EQUALS:
return data1 == data2;
default :
return false;
}
}

Fixed version (ground truth):
/** 
 * Based on the current game state data, returns if condition is true.
 * @param game takes in the model
 * @return if defined condition is true
 */
boolean conditionIsTrue(Game game,int id){
  int data1=getData(this.data1,game,id);
  int data2=getData(this.data2,game,id);
switch (this.operator) {
case LESS_THAN:
    return data1 < data2;
case GREATER_THAN:
  return data1 > data2;
case LESS_THAN_OR_EQUAL_TO:
return data1 <= data2;
case GREATER_THAN_OR_EQUAL_TO:
return data1 >= data2;
case EQUALS:
return data1 == data2;
default :
return false;
}
}
Program: 40503
Project: 40503
Buggy source:
/** 
 * Based on the current game state data, returns if condition is true.
 * @param data takes in the data to be returned
 * @param game is the pointer to the game model
 * @return the integer value of the game data that has been looked up
 */
private int getData(String data,Game game){
  if (data.equals(Data.USER_HEALTH.text())) {
    return game.getPlayer(Game.PLAYER_ID).getHealth();
  }
 else   if (data.equals(Data.OPPONENT_HEALTH.text())) {
    return game.getPlayer(Game.OPPONENT_ID).getHealth();
  }
 else   if (data.equals(Data.DISTANCE_FROM_OPPONENT.text())) {
    return game.pathDistanceToPlayer(Game.PLAYER_ID,Game.OPPONENT_ID);
  }
 else {
    try {
      return Integer.parseInt(data);
    }
 catch (    Exception ex) {
      System.out.println("String_Node_Str" + data + "String_Node_Str");
      return -1;
    }
  }
}

Fixed version (ground truth):
/** 
 * Based on the current game state data, returns if condition is true.
 * @param data takes in the data to be returned
 * @param game is the pointer to the game model
 * @return the integer value of the game data that has been looked up
 */
private int getData(String data,Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (data.equals(Data.USER_HEALTH.text())) {
    return game.getPlayer(id).getHealth();
  }
 else   if (data.equals(Data.OPPONENT_HEALTH.text())) {
    return game.getPlayer(otherId).getHealth();
  }
 else   if (data.equals(Data.DISTANCE_FROM_OPPONENT.text())) {
    return game.pathDistanceToPlayer(id,otherId);
  }
 else {
    try {
      return Integer.parseInt(data);
    }
 catch (    Exception ex) {
      LOGGER.critical("String_Node_Str" + data + "String_Node_Str");
      return -1;
    }
  }
}
Program: 40504
Project: 40504
Buggy source:
/** 
 * Method called to excecute a 'line' of the interpreter.
 * @param game the instance of the game class passed in
 * @param id the id of the player excecuting this script
 * @return true if the command excecuted
 */
public boolean doCommand(Game game,int id){
  for (  Check c : this.checks) {
    if (!c.conditionIsTrue(game)) {
      return false;
    }
  }
  executeFunction(game,id);
  return true;
}

Fixed version (ground truth):
/** 
 * Method called to excecute a 'line' of the interpreter.
 * @param game the instance of the game class passed in
 * @param id the id of the player excecuting this script
 * @return true if the command excecuted
 */
public boolean doCommand(Game game,int id){
  for (  Check c : this.checks) {
    if (!c.conditionIsTrue(game,id)) {
      return false;
    }
  }
  executeFunction(game,id);
  return true;
}
Program: 40505
Project: 40505
Buggy source:
/** 
 * Called by doCommand to actually modify the game data with built-in functions
 * @param game the instance of the game class passed in
 * @param id the id of the player executing this script
 */
private void executeFunction(Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (id == 1) {
    System.out.println("String_Node_Str" + id + "String_Node_Str"+ this.command);
  }
switch (this.command) {
case APPROACH:
    game.approach(id,otherId);
  break;
case ATTACK:
game.attack(id);
break;
case HEAL:
game.heal(id,9);
break;
case EVADE:
game.evade(id,otherId);
case DO_NOTHING:
game.doNothing(id);
break;
case DEFEND:
game.defend(id);
break;
default :
game.doNothing(id);
break;
}
}

Fixed version (ground truth):
/** 
 * Called by doCommand to actually modify the game data with built-in functions
 * @param game the instance of the game class passed in
 * @param id the id of the player executing this script
 */
private void executeFunction(Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (id == 1) {
    LOGGER.debug("String_Node_Str" + id + "String_Node_Str"+ this.command);
  }
switch (this.command) {
case APPROACH:
    game.approach(id,otherId);
  break;
case ATTACK:
game.attack(id);
break;
case HEAL:
game.heal(id,9);
break;
case EVADE:
game.evade(id,otherId);
case DO_NOTHING:
game.doNothing(id);
break;
case DEFEND:
game.defend(id);
break;
default :
game.doNothing(id);
break;
}
}
Program: 40506
Project: 40506
Buggy source:
/** 
 * @return Random Movement Value
 */
public int pickRandomElement(int listSize){
  int seed=ThreadLocalRandom.current().nextInt(0,listSize);
  System.out.println(seed);
  System.out.println(listSize);
  return seed;
}

Fixed version (ground truth):
/** 
 * @return Random Movement Value
 */
public int pickRandomElement(int listSize){
  int seed=ThreadLocalRandom.current().nextInt(0,listSize);
  return seed;
}
Program: 40507
Project: 40507
Buggy source:
/** 
 * If opponent is within one tile horizontally or vertically, player will attack that tile.  If not, returns false
 * @param playerId Player
 * @return If player was able to attack
 */
public boolean attack(int playerId){
  stopDefending(playerId);
  System.out.println("String_Node_Str" + playerId);
  if (attackLocation(playerId,0,1)) {
    return true;
  }
 else   if (attackLocation(playerId,0,-1)) {
    return true;
  }
 else   if (attackLocation(playerId,1,0)) {
    return true;
  }
 else   if (attackLocation(playerId,-1,0)) {
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * If opponent is within one tile horizontally or vertically, player will attack that tile.  If not, returns false
 * @param playerId Player
 * @return If player was able to attack
 */
public boolean attack(int playerId){
  stopDefending(playerId);
  LOGGER.debug("String_Node_Str" + playerId);
  if (attackLocation(playerId,0,1)) {
    return true;
  }
 else   if (attackLocation(playerId,0,-1)) {
    return true;
  }
 else   if (attackLocation(playerId,1,0)) {
    return true;
  }
 else   if (attackLocation(playerId,-1,0)) {
    return true;
  }
 else {
    return false;
  }
}
Program: 40508
Project: 40508
Buggy source:
/** 
 * Used by external classes to acquire game state.
 * @return The GameStatus pertaining to the current state of the game.
 */
public GameStatus getState(){
  if (!isGameOver()) {
    return GameStatus.RUNNING;
  }
  if (isStalemate()) {
    return GameStatus.STALEMATE;
  }
  LOGGER.warning("String_Node_Str");
  if (isDead(0)) {
    return GameStatus.LOST;
  }
 else   if (isDead(1)) {
    System.out.println(getPlayer(1).getHealth());
    return GameStatus.WON;
  }
  throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Used by external classes to acquire game state.
 * @return The GameStatus pertaining to the current state of the game.
 */
public GameStatus getState(){
  if (!isGameOver()) {
    return GameStatus.RUNNING;
  }
  if (isStalemate()) {
    return GameStatus.STALEMATE;
  }
  LOGGER.warning("String_Node_Str");
  if (isDead(0)) {
    return GameStatus.LOST;
  }
 else   if (isDead(1)) {
    LOGGER.debug("String_Node_Str" + getPlayer(1).getHealth());
    return GameStatus.WON;
  }
  throw new RuntimeException("String_Node_Str");
}
Program: 40509
Project: 40509
Buggy source:
/** 
 * Based on the current game state data, returns if condition is true.
 * @param data takes in the data to be returned
 * @param game is the pointer to the game model
 * @return the integer value of the game data that has been looked up
 */
private int getData(String data,Game game){
  if (data.equals(Data.USER_HEALTH.text())) {
    return game.getPlayer(Game.PLAYER_ID).getHealth();
  }
 else   if (data.equals(Data.OPPONENT_HEALTH.text())) {
    return game.getPlayer(Game.OPPONENT_ID).getHealth();
  }
 else   if (data.equals(Data.DISTANCE_FROM_OPPONENT.text())) {
    return (int)Math.round(game.distanceToOpponent(Game.PLAYER_ID,Game.OPPONENT_ID));
  }
 else {
    try {
      return Integer.parseInt(data);
    }
 catch (    Exception ex) {
      System.out.println("String_Node_Str" + data + "String_Node_Str");
      return -1;
    }
  }
}

Fixed version (ground truth):
/** 
 * Based on the current game state data, returns if condition is true.
 * @param data takes in the data to be returned
 * @param game is the pointer to the game model
 * @return the integer value of the game data that has been looked up
 */
private int getData(String data,Game game){
  if (data.equals(Data.USER_HEALTH.text())) {
    return game.getPlayer(Game.PLAYER_ID).getHealth();
  }
 else   if (data.equals(Data.OPPONENT_HEALTH.text())) {
    return game.getPlayer(Game.OPPONENT_ID).getHealth();
  }
 else   if (data.equals(Data.DISTANCE_FROM_OPPONENT.text())) {
    return game.pathDistanceToPlayer(Game.PLAYER_ID,Game.OPPONENT_ID);
  }
 else {
    try {
      return Integer.parseInt(data);
    }
 catch (    Exception ex) {
      System.out.println("String_Node_Str" + data + "String_Node_Str");
      return -1;
    }
  }
}
Program: 40510
Project: 40510
Buggy source:
/** 
 * Called by doCommand to actually modify the game data with built-in functions
 * @param game the instance of the game class passed in
 * @param id the id of the player executing this script
 */
private void executeFunction(Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (id == 1) {
    System.out.println("String_Node_Str" + id + "String_Node_Str"+ this.command);
  }
switch (this.command) {
case APPROACH:
    game.approach(id,otherId);
  break;
case ATTACK:
game.attack(id);
break;
case HEAL:
game.heal(id,20);
break;
case EVADE:
game.evade(id,otherId);
case DO_NOTHING:
game.doNothing(id);
break;
case DEFEND:
game.defend(id);
break;
default :
game.doNothing(id);
break;
}
}

Fixed version (ground truth):
/** 
 * Called by doCommand to actually modify the game data with built-in functions
 * @param game the instance of the game class passed in
 * @param id the id of the player executing this script
 */
private void executeFunction(Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (id == 1) {
    System.out.println("String_Node_Str" + id + "String_Node_Str"+ this.command);
  }
switch (this.command) {
case APPROACH:
    game.approach(id,otherId);
  break;
case ATTACK:
game.attack(id);
break;
case HEAL:
game.heal(id,9);
break;
case EVADE:
game.evade(id,otherId);
case DO_NOTHING:
game.doNothing(id);
break;
case DEFEND:
game.defend(id);
break;
default :
game.doNothing(id);
break;
}
}
Program: 40511
Project: 40511
Buggy source:
public double distance(Point location1,Point location2){
  return Math.hypot(location1.x - location2.x,location1.y - location2.y);
}

Fixed version (ground truth):
/** 
 * Returns a double of the distance between two points on graph.  This includes diagonal distance
 * @param location1
 * @param location2
 * @return
 */
public double distance(Point location1,Point location2){
  return Math.hypot(location1.x - location2.x,location1.y - location2.y);
}
Program: 40512
Project: 40512
Buggy source:
/** 
 * Evades from opposing player.  Will move in direction that is one space away from player.  Will only evade 50% of time
 * @param playerId
 * @param opponentId
 * @return
 */
public boolean evade(int playerId,int opponentId){
  stopDefending(playerId);
  if (getRandomBoolean()) {
    return false;
  }
  Player player=getPlayer(playerId);
  Player opponent=getPlayer(opponentId);
  int currentDistance=pathDistanceToLocation(player.getLocation(),opponent.getLocation());
  ArrayList<Point> potentialMoveLocations=getAllPossibleMoves(getPlayer(playerId).getLocation());
  Point playerCurrentLocation=getPlayer(playerId).getLocation();
  double longestDistance=-1;
  int longestMoveIndex=-1;
  for (int i=0; i < potentialMoveLocations.size(); i++) {
    Point moveLocation=getNewLocation(playerCurrentLocation,potentialMoveLocations.get(i));
    int distanceCandidate=pathDistanceToLocation(moveLocation,opponent.getLocation());
    if (distanceCandidate > longestDistance) {
      longestDistance=distanceCandidate;
      longestMoveIndex=i;
    }
  }
  if (longestDistance > currentDistance) {
    return move(playerId,potentialMoveLocations.get(longestMoveIndex).x,potentialMoveLocations.get(longestMoveIndex).y);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Evades from opposing player.  Will move in direction that is one space away from player.  Will only evade 87.5% of time
 * @param playerId
 * @param opponentId
 * @return
 */
public boolean evade(int playerId,int opponentId){
  stopDefending(playerId);
  if (getRandomBoolean()) {
    if (getRandomBoolean()) {
      if (getRandomBoolean()) {
        return false;
      }
    }
  }
  Player player=getPlayer(playerId);
  Player opponent=getPlayer(opponentId);
  int currentDistance=pathDistanceToLocation(player.getLocation(),opponent.getLocation());
  ArrayList<Point> potentialMoveLocations=getAllPossibleMoves(getPlayer(playerId).getLocation());
  Point playerCurrentLocation=getPlayer(playerId).getLocation();
  double longestDistance=-1;
  int longestMoveIndex=-1;
  for (int i=0; i < potentialMoveLocations.size(); i++) {
    Point moveLocation=getNewLocation(playerCurrentLocation,potentialMoveLocations.get(i));
    int distanceCandidate=pathDistanceToLocation(moveLocation,opponent.getLocation());
    if (distanceCandidate > longestDistance) {
      longestDistance=distanceCandidate;
      longestMoveIndex=i;
    }
    if (distanceCandidate == longestDistance) {
      if (getRandomBoolean()) {
        longestDistance=distanceCandidate;
        longestMoveIndex=i;
      }
    }
  }
  if (longestDistance > currentDistance) {
    return move(playerId,potentialMoveLocations.get(longestMoveIndex).x,potentialMoveLocations.get(longestMoveIndex).y);
  }
  return false;
}
Program: 40513
Project: 40513
Buggy source:
/** 
 * Number of tiles to get to opponent using only horizontal and vertical movement
 * @param playerId
 * @param opponentId
 * @return
 */
public int pathDistanceToPlayer(int playerId,int opponentId){
  Point distances=getDeltaDistances(playerId,opponentId);
  return (Math.abs(distances.x) + Math.abs(distances.y)) - 1;
}

Fixed version (ground truth):
/** 
 * Number of tiles to get to opponent using only horizontal and vertical movement
 * @param playerId
 * @param opponentId
 * @return
 */
public int pathDistanceToPlayer(int playerId,int opponentId){
  Point distances=getDeltaDistances(playerId,opponentId);
  return Math.abs(distances.x) + Math.abs(distances.y);
}
Program: 40514
Project: 40514
Buggy source:
/** 
 * Attacks location x and y away from players current location
 * @param playerId Player
 * @param x        Units away from players current location
 * @param y        Units away from players current location
 * @return If player was able to attack
 */
private boolean attackLocation(int playerId,int x,int y){
  EntityTile playerTile=this._entityMap.getPlayers().get(playerId);
  Point location=playerTile.getLocation();
  if (!_entityMap.isInsideMap(new Point(location.x + x,location.y + y))) {
    return false;
  }
  Entity entity=getEntityAtLocation(new Point(location.x + x,location.y + y));
  Player player=(Player)playerTile.getEntity();
  player.setShielding(false);
  if (entity.getEntityType() == Entity.EntityType.EMPTY) {
    return false;
  }
 else {
    Player playerToAttack=(Player)entity;
    int damageToBeDone=player.getDamage();
    if (playerToAttack.isShielding()) {
      damageToBeDone=player.getDamage() - playerToAttack.getShieldStrength();
    }
    playerToAttack.setHealth(playerToAttack.getHealth() - damageToBeDone);
    if (playerToAttack.getHealth() <= HEALTH_DEAD) {
      playerToAttack.setHealth(0);
      this._isGameOver=true;
    }
    return true;
  }
}

Fixed version (ground truth):
/** 
 * Attacks location x and y away from players current location
 * @param playerId Player
 * @param x        Units away from players current location
 * @param y        Units away from players current location
 * @return If player was able to attack
 */
private boolean attackLocation(int playerId,int x,int y){
  EntityTile playerTile=this._entityMap.getPlayers().get(playerId);
  Point location=playerTile.getLocation();
  stopDefending(playerId);
  if (!_entityMap.isInsideMap(new Point(location.x + x,location.y + y))) {
    return false;
  }
  Entity entity=getEntityAtLocation(new Point(location.x + x,location.y + y));
  Player player=(Player)playerTile.getEntity();
  if (entity.getEntityType() == Entity.EntityType.EMPTY) {
    return false;
  }
 else {
    Player playerToAttack=(Player)entity;
    int damageToBeDone=player.getDamage();
    if (playerToAttack.isShielding()) {
      damageToBeDone=player.getDamage() - playerToAttack.getShieldStrength();
    }
    playerToAttack.setHealth(playerToAttack.getHealth() - damageToBeDone);
    if (playerToAttack.getHealth() <= HEALTH_DEAD) {
      playerToAttack.setHealth(0);
      this._isGameOver=true;
    }
    return true;
  }
}
Program: 40515
Project: 40515
Buggy source:
/** 
 * Checks to see whether or not the current player has been in their location for NUMBER_OF_TURNS_TO_STALEMATE
 * @param playerId
 * @return If the users has not moved in NUMBER_OF_TURNS_TO_STALEMATE
 */
private boolean isStalemateTurnForPlayer(int playerId){
  if (_previousLocations.get(playerId).x == getPlayer(playerId).getLocation().x && _previousLocations.get(playerId).y == getPlayer(playerId).getLocation().y) {
    _numberOfTimesAtCurrentLocation.set(playerId,_numberOfTimesAtCurrentLocation.get(playerId) + 1);
    if (_numberOfTimesAtCurrentLocation.get(playerId) > NUMBER_OF_TURNS_TO_STALEMATE) {
      return true;
    }
 else {
      _previousLocations.set(playerId,new Point(getPlayer(playerId).getLocation()));
    }
  }
 else {
    _previousLocations.set(playerId,new Point(getPlayer(playerId).getLocation()));
    _numberOfTimesAtCurrentLocation.set(playerId,1);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Checks to see whether or not the current player has been in their location and not taken damage for NUMBER_OF_TURNS_TO_STALEMATE
 * @param playerId
 * @return If the users has not moved in NUMBER_OF_TURNS_TO_STALEMATE
 */
private boolean isStalemateTurnForPlayer(int playerId){
  if (_previousLocations.get(playerId).x == getPlayer(playerId).getLocation().x && _previousLocations.get(playerId).y == getPlayer(playerId).getLocation().y && _previousHealth.get(playerId) == getPlayer(playerId).getHealth()) {
    _numberOfStalemateTurns.set(playerId,_numberOfStalemateTurns.get(playerId) + 1);
    if (_numberOfStalemateTurns.get(playerId) > NUMBER_OF_TURNS_TO_STALEMATE) {
      return true;
    }
 else {
      _previousLocations.set(playerId,new Point(getPlayer(playerId).getLocation()));
      _previousHealth.set(playerId,getPlayer(playerId).getHealth());
    }
  }
 else {
    _previousLocations.set(playerId,new Point(getPlayer(playerId).getLocation()));
    _previousHealth.set(playerId,getPlayer(playerId).getHealth());
    _numberOfStalemateTurns.set(playerId,1);
  }
  return false;
}
Program: 40516
Project: 40516
Buggy source:
/** 
 * @param entityMap
 */
public Game(EntityMap entityMap){
  this._entityMap=entityMap;
  _previousLocations.add(getPlayer(PLAYER_ID).getLocation());
  _previousLocations.add(getPlayer(OPPONENT_ID).getLocation());
  _numberOfTimesAtCurrentLocation.add(1);
  _numberOfTimesAtCurrentLocation.add(1);
}

Fixed version (ground truth):
/** 
 * @param entityMap
 */
public Game(EntityMap entityMap){
  this._entityMap=entityMap;
  _previousLocations.add(getPlayer(PLAYER_ID).getLocation());
  _previousLocations.add(getPlayer(OPPONENT_ID).getLocation());
  _numberOfStalemateTurns.add(1);
  _numberOfStalemateTurns.add(1);
  _previousHealth.add(getPlayer(PLAYER_ID).getHealth());
  _previousHealth.add(getPlayer(OPPONENT_ID).getHealth());
}
Program: 40517
Project: 40517
Buggy source:
/** 
 * Returns updated entityMap.
 * @return Updated EntityMap
 */
public Map nextTurn(){
  if (!isGameOver()) {
    boolean isStalemateForPlayer=isStalemateTurnForPlayer(PLAYER_ID);
    boolean isStalemateForOpponent=isStalemateTurnForPlayer(OPPONENT_ID);
    if (isStalemateForPlayer && isStalemateForOpponent) {
      _isStalemate=true;
      this._isGameOver=true;
    }
 else     if (this._numberOfTurnsCompleted > MAX_TURN_LIMIT) {
      _isStalemate=true;
      this._isGameOver=true;
    }
    this._numberOfTurnsCompleted++;
  }
  return this._entityMap.getMap();
}

Fixed version (ground truth):
/** 
 * Returns updated entityMap.
 * @return Updated EntityMap
 */
public Map nextTurn(){
  if (!isGameOver()) {
    boolean isStalemateForPlayer=isStalemateTurnForPlayer(PLAYER_ID);
    boolean isStalemateForOpponent=isStalemateTurnForPlayer(OPPONENT_ID);
    if (isStalemateForPlayer || isStalemateForOpponent) {
      _isStalemate=true;
      this._isGameOver=true;
    }
 else     if (this._numberOfTurnsCompleted > MAX_TURN_LIMIT) {
      _isStalemate=true;
      this._isGameOver=true;
    }
    this._numberOfTurnsCompleted++;
  }
  return this._entityMap.getMap();
}
Program: 40518
Project: 40518
Buggy source:
/** 
 * Based on the current game state data, returns if condition is true.
 * @param data takes in the data to be returned
 * @param game is the pointer to the game model
 * @return the integer value of the game data that has been looked up
 */
private int getData(String data,Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (data.equals(Data.USER_HEALTH.text())) {
    return game.getPlayer(id).getHealth();
  }
 else   if (data.equals(Data.OPPONENT_HEALTH.text())) {
    return game.getPlayer(otherId).getHealth();
  }
 else   if (data.equals(Data.DISTANCE_FROM_OPPONENT.text())) {
    return (int)Math.round(game.distanceToOpponent(id,otherId));
  }
 else {
    try {
      return Integer.parseInt(data);
    }
 catch (    Exception ex) {
      System.out.println("String_Node_Str" + data + "String_Node_Str");
      return -1;
    }
  }
}

Fixed version (ground truth):
/** 
 * Based on the current game state data, returns if condition is true.
 * @param data takes in the data to be returned
 * @param game is the pointer to the game model
 * @return the integer value of the game data that has been looked up
 */
private int getData(String data,Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (data.equals(Data.USER_HEALTH.text())) {
    return game.getPlayer(id).getHealth();
  }
 else   if (data.equals(Data.OPPONENT_HEALTH.text())) {
    return game.getPlayer(otherId).getHealth();
  }
 else   if (data.equals(Data.DISTANCE_FROM_OPPONENT.text())) {
    return game.pathDistanceToPlayer(id,otherId);
  }
 else {
    try {
      return Integer.parseInt(data);
    }
 catch (    Exception ex) {
      System.out.println("String_Node_Str" + data + "String_Node_Str");
      return -1;
    }
  }
}
Program: 40519
Project: 40519
Buggy source:
/** 
 * Called by doCommand to actually modify the game data with built-in functions
 * @param game the instance of the game class passed in
 * @param id the id of the player executing this script
 */
private void executeFunction(Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (id == 1) {
    System.out.println("String_Node_Str" + id + "String_Node_Str"+ this.command);
  }
switch (this.command) {
case APPROACH:
    game.approach(id,otherId);
  break;
case ATTACK:
game.attack(id);
break;
case HEAL:
game.heal(id,20);
break;
case EVADE:
game.evade(id,otherId);
case DO_NOTHING:
game.doNothing(id);
break;
case DEFEND:
game.defend(id);
break;
default :
game.doNothing(id);
break;
}
}

Fixed version (ground truth):
/** 
 * Called by doCommand to actually modify the game data with built-in functions
 * @param game the instance of the game class passed in
 * @param id the id of the player executing this script
 */
private void executeFunction(Game game,int id){
  int otherId;
  if (id == 0) {
    otherId=1;
  }
 else {
    otherId=0;
  }
  if (id == 1) {
    System.out.println("String_Node_Str" + id + "String_Node_Str"+ this.command);
  }
switch (this.command) {
case APPROACH:
    game.approach(id,otherId);
  break;
case ATTACK:
game.attack(id);
break;
case HEAL:
game.heal(id,9);
break;
case EVADE:
game.evade(id,otherId);
case DO_NOTHING:
game.doNothing(id);
break;
case DEFEND:
game.defend(id);
break;
default :
game.doNothing(id);
break;
}
}
Program: 40520
Project: 40520
Buggy source:
public double distance(Point location1,Point location2){
  return Math.hypot(location1.x - location2.x,location1.y - location2.y);
}

Fixed version (ground truth):
/** 
 * Returns a double of the distance between two points on graph.  This includes diagonal distance
 * @param location1
 * @param location2
 * @return
 */
public double distance(Point location1,Point location2){
  return Math.hypot(location1.x - location2.x,location1.y - location2.y);
}
Program: 40521
Project: 40521
Buggy source:
/** 
 * Evades from opposing player.  Will move in direction that is one space away from player.  Will only evade 50% of time
 * @param playerId
 * @param opponentId
 * @return
 */
public boolean evade(int playerId,int opponentId){
  stopDefending(playerId);
  if (getRandomBoolean()) {
    return false;
  }
  Player player=getPlayer(playerId);
  Player opponent=getPlayer(opponentId);
  int currentDistance=pathDistanceToLocation(player.getLocation(),opponent.getLocation());
  ArrayList<Point> potentialMoveLocations=getAllPossibleMoves(getPlayer(playerId).getLocation());
  Point playerCurrentLocation=getPlayer(playerId).getLocation();
  double longestDistance=-1;
  int longestMoveIndex=-1;
  for (int i=0; i < potentialMoveLocations.size(); i++) {
    Point moveLocation=getNewLocation(playerCurrentLocation,potentialMoveLocations.get(i));
    int distanceCandidate=pathDistanceToLocation(moveLocation,opponent.getLocation());
    if (distanceCandidate > longestDistance) {
      longestDistance=distanceCandidate;
      longestMoveIndex=i;
    }
  }
  if (longestDistance > currentDistance) {
    return move(playerId,potentialMoveLocations.get(longestMoveIndex).x,potentialMoveLocations.get(longestMoveIndex).y);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Evades from opposing player.  Will move in direction that is one space away from player.  Will only evade 87.5% of time
 * @param playerId
 * @param opponentId
 * @return
 */
public boolean evade(int playerId,int opponentId){
  stopDefending(playerId);
  if (getRandomBoolean()) {
    if (getRandomBoolean()) {
      if (getRandomBoolean()) {
        return false;
      }
    }
  }
  Player player=getPlayer(playerId);
  Player opponent=getPlayer(opponentId);
  int currentDistance=pathDistanceToLocation(player.getLocation(),opponent.getLocation());
  ArrayList<Point> potentialMoveLocations=getAllPossibleMoves(getPlayer(playerId).getLocation());
  Point playerCurrentLocation=getPlayer(playerId).getLocation();
  double longestDistance=-1;
  int longestMoveIndex=-1;
  for (int i=0; i < potentialMoveLocations.size(); i++) {
    Point moveLocation=getNewLocation(playerCurrentLocation,potentialMoveLocations.get(i));
    int distanceCandidate=pathDistanceToLocation(moveLocation,opponent.getLocation());
    if (distanceCandidate > longestDistance) {
      longestDistance=distanceCandidate;
      longestMoveIndex=i;
    }
    if (distanceCandidate == longestDistance) {
      if (getRandomBoolean()) {
        longestDistance=distanceCandidate;
        longestMoveIndex=i;
      }
    }
  }
  if (longestDistance > currentDistance) {
    return move(playerId,potentialMoveLocations.get(longestMoveIndex).x,potentialMoveLocations.get(longestMoveIndex).y);
  }
  return false;
}