Program: 37962
Project: 37962
Buggy source:
/** 
 * Splits the sublevel recursively until it builds rooms, then connects the rooms together In the end, curr is populated with the current hallways and rooms
 */
private void splitAndBuild(SubLevel curr){
  boolean makeRoom=false;
  int splitAttempts=0;
  if (curr.depth == depthMax) {
    makeRoom=true;
  }
  if (makeRoom) {
    makeRoom(curr);
  }
 else {
    Split s=(getRandom(2) == 0) ? Split.VER : Split.HOR;
    SubLevel s1, s2;
    if (s == Split.HOR) {
      float width=(curr.max.x - curr.min.x);
      if (width < 4 * minWallThickness + 2 * minRoomDim) {
        makeRoom(curr);
        return;
      }
      int maxVal=Math.round((width * (splitMax - splitMin)));
      int splitVal=Math.round(curr.min.x + width * splitMin + getRandom(maxVal));
      while (splitVal - curr.min.x < 2 * minWallThickness + minRoomDim || curr.max.x - splitVal - 1 < 2 * minWallThickness + minRoomDim) {
        if (splitAttempts >= splitTries) {
          makeRoom(curr);
          return;
        }
        splitAttempts++;
        maxVal=Math.round((width * (splitMax - splitMin)));
        splitVal=Math.round(curr.min.x + width * splitMin + getRandom(maxVal));
      }
      s1=new SubLevel(new Vec2i(curr.min.x,curr.min.y),new Vec2i(splitVal,curr.max.y),curr.depth + 1);
      s2=new SubLevel(new Vec2i(splitVal + 1,curr.min.y),new Vec2i(curr.max.x,curr.max.y),curr.depth + 1);
    }
 else {
      float height=(curr.max.y - curr.min.y);
      if (height < 4 * minWallThickness + 2 * minRoomDim) {
        makeRoom(curr);
        return;
      }
      int splitVal=Math.round(curr.min.y + height * splitMin + getRandom(Math.round((height * (splitMax - splitMin)))));
      while (splitVal - curr.min.y < 2 * minWallThickness + minRoomDim || curr.max.y - splitVal - 1 < 2 * minWallThickness + minRoomDim) {
        if (splitAttempts >= splitTries) {
          makeRoom(curr);
          return;
        }
        splitAttempts++;
        splitVal=Math.round(curr.min.y + height * splitMin + getRandom(Math.round((height * (splitMax - splitMin)))));
      }
      s1=new SubLevel(new Vec2i(curr.min.x,curr.min.y),new Vec2i(curr.max.x,splitVal),curr.depth + 1);
      s2=new SubLevel(new Vec2i(curr.min.x,splitVal + 1),new Vec2i(curr.max.x,curr.max.y),curr.depth + 1);
    }
    splitAndBuild(s1);
    splitAndBuild(s2);
    Range range=s1.overLap(s2,s);
    if (range != null) {
      int hpt;
      hpt=range.min + getRandom(range.max - range.min);
      HallwayPoint hp1=s1.getHallwayPoint(s,true,hpt);
      HallwayPoint hp2=s2.getHallwayPoint(s,false,hpt);
      Hallway new_hallway=new Hallway(hp1.point,hp2.point);
      paintHallway(hp1.point,hp2.point,true,TileType.FLOOR);
      hp1.space.connectToHallway(new_hallway);
      hp2.space.connectToHallway(new_hallway);
      curr.hallways.add(new_hallway);
    }
 else {
      if (s == Split.HOR) {
        int cy=s1.intersectMin.y + getRandom(s1.intersectMax.y - s1.intersectMin.y);
        int cx=s2.intersectMin.x + getRandom(s2.intersectMax.x - s2.intersectMin.x);
        Vec2i corner=new Vec2i(cx,cy);
        HallwayPoint hp1=s1.getHallwayPoint(Split.VER,true,cy);
        HallwayPoint hp2=s2.getHallwayPoint(Split.HOR,(s1.intersectMin.x > s2.intersectMax.x),cx);
        Hallway new_hallway1=new Hallway(hp1.point,corner);
        hp1.space.connectToHallway(new_hallway1);
        Hallway new_hallway2=new Hallway(hp2.point,corner);
        hp2.space.connectToHallway(new_hallway2);
        new_hallway1.connectToHallway(new_hallway2);
        paintHallway(hp1.point,corner,true,TileType.FLOOR);
        paintHallway(hp2.point,corner,true,TileType.FLOOR);
        curr.hallways.add(new_hallway1);
        curr.hallways.add(new_hallway2);
      }
 else {
        int cx=s1.intersectMin.x + getRandom(s1.intersectMax.x - s1.intersectMin.x);
        int cy=s2.intersectMin.y + getRandom(s2.intersectMax.y - s2.intersectMin.y);
        Vec2i corner=new Vec2i(cx,cy);
        HallwayPoint hp1=s1.getHallwayPoint(Split.HOR,true,cx);
        HallwayPoint hp2=s2.getHallwayPoint(Split.VER,(s1.intersectMin.y > s2.intersectMax.y),cy);
        Hallway new_hallway1=new Hallway(hp1.point,corner);
        hp1.space.connectToHallway(new_hallway1);
        Hallway new_hallway2=new Hallway(hp2.point,corner);
        hp2.space.connectToHallway(new_hallway2);
        new_hallway1.connectToHallway(new_hallway2);
        paintHallway(hp1.point,corner,true,TileType.FLOOR);
        paintHallway(hp2.point,corner,true,TileType.FLOOR);
        curr.hallways.add(new_hallway1);
        curr.hallways.add(new_hallway2);
      }
    }
    curr.rooms.addAll(s1.rooms);
    curr.rooms.addAll(s2.rooms);
    curr.hallways.addAll(s1.hallways);
    curr.hallways.addAll(s2.hallways);
    int maxIX=Math.max(s1.intersectMax.x,s2.intersectMax.x);
    int maxIY=Math.max(s1.intersectMax.y,s2.intersectMax.y);
    int minIX=Math.max(s1.intersectMin.x,s2.intersectMin.x);
    int minIY=Math.max(s1.intersectMax.y,s2.intersectMax.y);
    curr.intersectMax=new Vec2i(maxIX,maxIY);
    curr.intersectMin=new Vec2i(minIX,minIY);
  }
}

Fixed version (ground truth):
/** 
 * Splits the sublevel recursively until it builds rooms, then connects the rooms together In the end, curr is populated with the current hallways and rooms
 */
private void splitAndBuild(SubLevel curr){
  boolean makeRoom=false;
  int splitAttempts=0;
  if (curr.depth == depthMax) {
    makeRoom=true;
  }
  if (makeRoom) {
    makeRoom(curr);
  }
 else {
    Split s=(getRandom(2) == 0) ? Split.VER : Split.HOR;
    if (s == Split.HOR) {
      float height=(curr.max.y - curr.min.y);
      if (height < 4 * minWallThickness + 2 * minRoomDim) {
        s=Split.VER;
      }
    }
 else {
      float width=(curr.max.x - curr.min.x);
      if (width < 4 * minWallThickness + 2 * minRoomDim) {
        s=Split.HOR;
      }
    }
    SubLevel s1, s2;
    if (s == Split.HOR) {
      float height=(curr.max.y - curr.min.y);
      if (height < 4 * minWallThickness + 2 * minRoomDim) {
        makeRoom(curr);
        return;
      }
      int splitVal=Math.round(curr.min.y + height * splitMin + getRandom(Math.round((height * (splitMax - splitMin)))));
      while (splitVal - curr.min.y < 2 * minWallThickness + minRoomDim || curr.max.y - splitVal - 1 < 2 * minWallThickness + minRoomDim) {
        if (splitAttempts >= splitTries) {
          makeRoom(curr);
          return;
        }
        splitAttempts++;
        splitVal=Math.round(curr.min.y + height * splitMin + getRandom(Math.round((height * (splitMax - splitMin)))));
      }
      s1=new SubLevel(new Vec2i(curr.min.x,curr.min.y),new Vec2i(curr.max.x,splitVal),curr.depth + 1);
      s2=new SubLevel(new Vec2i(curr.min.x,splitVal + 1),new Vec2i(curr.max.x,curr.max.y),curr.depth + 1);
    }
 else {
      float width=(curr.max.x - curr.min.x);
      if (width < 4 * minWallThickness + 2 * minRoomDim) {
        makeRoom(curr);
        return;
      }
      int maxVal=Math.round((width * (splitMax - splitMin)));
      int splitVal=Math.round(curr.min.x + width * splitMin + getRandom(maxVal));
      while (splitVal - curr.min.x < 2 * minWallThickness + minRoomDim || curr.max.x - splitVal - 1 < 2 * minWallThickness + minRoomDim) {
        if (splitAttempts >= splitTries) {
          makeRoom(curr);
          return;
        }
        splitAttempts++;
        maxVal=Math.round((width * (splitMax - splitMin)));
        splitVal=Math.round(curr.min.x + width * splitMin + getRandom(maxVal));
      }
      s1=new SubLevel(new Vec2i(curr.min.x,curr.min.y),new Vec2i(splitVal,curr.max.y),curr.depth + 1);
      s2=new SubLevel(new Vec2i(splitVal + 1,curr.min.y),new Vec2i(curr.max.x,curr.max.y),curr.depth + 1);
    }
    splitAndBuild(s1);
    splitAndBuild(s2);
    Range range=s1.overLap(s2,s);
    if (range != null) {
      int hpt;
      hpt=getRandom(range.min,range.max);
      HallwayPoint hp1=s1.getHallwayPoint(s,true,hpt);
      HallwayPoint hp2=s2.getHallwayPoint(s,false,hpt);
      Hallway new_hallway=new Hallway(hp1.point,hp2.point);
      paintHallway(hp1.point,hp2.point,true,TileType.FLOOR);
      hp1.space.connectToHallway(new_hallway);
      hp2.space.connectToHallway(new_hallway);
      curr.hallways.add(new_hallway);
    }
 else {
      if (s == Split.HOR) {
        int cx=getRandom(s1.intersectMin.x,s1.intersectMax.x);
        int cy=getRandom(s2.intersectMin.y,s2.intersectMax.y);
        Vec2i corner=new Vec2i(cx,cy);
        HallwayPoint hp1=s1.getHallwayPoint(Split.HOR,true,cx);
        HallwayPoint hp2=s2.getHallwayPoint(Split.VER,(s2.intersectMin.x < s1.intersectMax.x),cy);
        Hallway new_hallway1=new Hallway(hp1.point,corner);
        hp1.space.connectToHallway(new_hallway1);
        Hallway new_hallway2;
        if (s2.intersectMin.x > s1.intersectMax.x)         new_hallway2=new Hallway(hp2.point,corner);
 else         new_hallway2=new Hallway(corner,hp2.point);
        hp2.space.connectToHallway(new_hallway2);
        new_hallway1.connectToHallway(new_hallway2);
        paintHallway(hp1.point,corner,true,TileType.FLOOR);
        paintHallway(hp2.point,corner,true,TileType.FLOOR);
        curr.hallways.add(new_hallway1);
        curr.hallways.add(new_hallway2);
      }
 else {
        int cx=s1.intersectMin.x + getRandom(s1.intersectMax.x - s1.intersectMin.x);
        int cy=s2.intersectMin.y + getRandom(s2.intersectMax.y - s2.intersectMin.y);
        Vec2i corner=new Vec2i(cx,cy);
        HallwayPoint hp1=s1.getHallwayPoint(Split.HOR,(s1.intersectMin.y < s2.intersectMax.y),cx);
        HallwayPoint hp2=s2.getHallwayPoint(Split.VER,false,cy);
        Hallway new_hallway1;
        if (s1.intersectMin.y < s2.intersectMax.y)         new_hallway1=new Hallway(hp1.point,corner);
 else         new_hallway1=new Hallway(corner,hp1.point);
        hp1.space.connectToHallway(new_hallway1);
        Hallway new_hallway2=new Hallway(corner,hp2.point);
        hp2.space.connectToHallway(new_hallway2);
        new_hallway1.connectToHallway(new_hallway2);
        paintHallway(hp1.point,corner,true,TileType.FLOOR);
        paintHallway(hp2.point,corner,true,TileType.FLOOR);
        curr.hallways.add(new_hallway1);
        curr.hallways.add(new_hallway2);
      }
    }
    curr.rooms.addAll(s1.rooms);
    curr.rooms.addAll(s2.rooms);
    curr.hallways.addAll(s1.hallways);
    curr.hallways.addAll(s2.hallways);
    int maxIX=Math.max(s1.intersectMax.x,s2.intersectMax.x);
    int maxIY=Math.max(s1.intersectMax.y,s2.intersectMax.y);
    int minIX=Math.min(s1.intersectMin.x,s2.intersectMin.x);
    int minIY=Math.min(s1.intersectMin.y,s2.intersectMin.y);
    curr.intersectMax=new Vec2i(maxIX,maxIY);
    curr.intersectMin=new Vec2i(minIX,minIY);
  }
}