Program: 40137
Project: 40137
Buggy source:
public void GreedySearch(ArrayList<GreedyCoordinate> coords) throws Exception {
  ArrayList<GreedyCoordinate> fullcoords=new ArrayList<GreedyCoordinate>();
  fullcoords.add(new GreedyCoordinate(rover.getXPosition(),rover.getYPosition()));
  ArrayList<GreedyCoordinate> preferences=new ArrayList<GreedyCoordinate>();
  boolean working=true;
  boolean stepped;
  GreedyCoordinate currentNode=new GreedyCoordinate(coords.get(0));
  GreedyCoordinate checkNode;
  double goalDirection;
  while (working) {
    currentNode.setVisited(true);
    ArrayList<GreedyCoordinate> neighbors=currentNode.getNeighbors();
    goalDirection=getAngleToGoal(currentNode,rover.getEndPosition());
    ArrayList<GreedyCoordinateWrapper> directionList=new ArrayList<GreedyCoordinateWrapper>();
    for (    GreedyCoordinate item : neighbors) {
      if (checkArray(item,fullcoords) > -1) {
        item.setVisited(true);
      }
      if (item.getDirection() == 0 && goalDirection > 180) {
        directionList.add(new GreedyCoordinateWrapper(item,getAngleDiff((int)goalDirection,360)));
      }
 else {
        directionList.add(new GreedyCoordinateWrapper(item,getAngleDiff((int)goalDirection,item.getDirection())));
      }
    }
    Collections.sort(directionList,new Comparator<GreedyCoordinateWrapper>(){
      public int compare(      GreedyCoordinateWrapper l,      GreedyCoordinateWrapper r){
        return l.getDiff() > r.getDiff() ? 1 : (l.getDiff() < r.getDiff()) ? -1 : 0;
      }
    }
);
    for (    GreedyCoordinateWrapper item : directionList) {
      preferences.add(item.getCoordinate());
    }
    directionList.clear();
    stepped=true;
    while (stepped) {
      if (preferences.size() > 0) {
        checkNode=preferences.get(0);
        if (checkNode != null && processSlope(currentNode,checkNode,getAngleToGoal(currentNode,checkNode)) && !checkNode.isVisited()) {
          currentNode=checkNode;
          coords.add(currentNode);
          fullcoords.add(currentNode);
          stepped=false;
        }
 else {
          preferences.remove(0);
        }
      }
 else {
        if (coords.size() > 1) {
          coords.remove(checkArray(currentNode,coords));
          currentNode=coords.get(coords.size() - 1);
          currentNode.setVisited(true);
          if (mode.equals("String_Node_Str"))           fullcoords.add(currentNode);
          stepped=false;
        }
 else {
          throw new Exception("String_Node_Str");
        }
      }
    }
    preferences.clear();
    if (currentNode.equals(goal)) {
      if (mode.equals("String_Node_Str")) {
        output=new TerminalOutput(fullcoords);
        coords=fullcoords;
      }
 else {
        output=new TerminalOutput(coords);
      }
      working=false;
    }
  }
}

Fixed version (ground truth):
public void GreedySearch(ArrayList<GreedyCoordinate> coords) throws Exception {
  ArrayList<GreedyCoordinate> fullcoords=new ArrayList<GreedyCoordinate>();
  fullcoords.add(new GreedyCoordinate(rover.getXPosition(),rover.getYPosition()));
  ArrayList<GreedyCoordinate> preferences=new ArrayList<GreedyCoordinate>();
  boolean working=true;
  boolean stepped;
  GreedyCoordinate currentNode=new GreedyCoordinate(coords.get(0));
  GreedyCoordinate checkNode;
  double goalDirection;
  while (working) {
    currentNode.setVisited(true);
    ArrayList<GreedyCoordinate> neighbors=currentNode.getNeighbors();
    goalDirection=getAngleToGoal(currentNode,rover.getEndPosition());
    ArrayList<GreedyCoordinateWrapper> directionList=new ArrayList<GreedyCoordinateWrapper>();
    for (    GreedyCoordinate item : neighbors) {
      if (checkArray(item,fullcoords) > -1) {
        item.setVisited(true);
      }
      if (item.getDirection() == 0 && goalDirection > 180) {
        directionList.add(new GreedyCoordinateWrapper(item,getAngleDiff((int)goalDirection,360)));
      }
 else {
        directionList.add(new GreedyCoordinateWrapper(item,getAngleDiff((int)goalDirection,item.getDirection())));
      }
    }
    Collections.sort(directionList,new Comparator<GreedyCoordinateWrapper>(){
      public int compare(      GreedyCoordinateWrapper l,      GreedyCoordinateWrapper r){
        return l.getDiff() > r.getDiff() ? 1 : (l.getDiff() < r.getDiff()) ? -1 : 0;
      }
    }
);
    for (    GreedyCoordinateWrapper item : directionList) {
      preferences.add(item.getCoordinate());
    }
    directionList.clear();
    stepped=true;
    while (stepped) {
      if (preferences.size() > 0) {
        checkNode=preferences.get(0);
        if (checkNode != null && rover.canTraverse(currentNode,checkNode) && !checkNode.isVisited()) {
          currentNode=checkNode;
          coords.add(currentNode);
          fullcoords.add(currentNode);
          stepped=false;
        }
 else {
          preferences.remove(0);
        }
      }
 else {
        if (coords.size() > 1) {
          coords.remove(checkArray(currentNode,coords));
          currentNode=coords.get(coords.size() - 1);
          currentNode.setVisited(true);
          if (mode.equals("String_Node_Str"))           fullcoords.add(currentNode);
          stepped=false;
        }
 else {
          throw new Exception("String_Node_Str");
        }
      }
    }
    preferences.clear();
    if (currentNode.equals(goal)) {
      if (mode.equals("String_Node_Str")) {
        output=new TerminalOutput(fullcoords);
        output=new MapImageOutput(fullcoords,map.getMapPath());
        coords=fullcoords;
      }
 else {
        output=new TerminalOutput(coords);
        output=new MapImageOutput(coords,map.getMapPath());
      }
      working=false;
    }
  }
}