Program: 164391
Project: 164391
Buggy source:
@Override protected boolean build(){
  initRooms();
  int distance;
  int retry=0;
  do {
    if (retry++ > 20) {
      return false;
    }
    roomEntrance=Random.element(rooms);
  }
 while (roomEntrance.width() < 4 || roomEntrance.height() < 4 || roomEntrance.top == 0 || roomEntrance.top >= 12);
  roomEntrance.type=Type.ENTRANCE;
  roomExit=roomEntrance;
  Room curRoom=null;
  Room lastRoom=roomEntrance;
  for (int i=0; i <= 4; i++) {
    retry=0;
    if (i < 4) {
      do {
        if (retry++ > 20) {
          return false;
        }
        curRoom=Random.element(rooms);
        Graph.buildDistanceMap(rooms,curRoom);
        distance=lastRoom.distance();
      }
 while (curRoom.type != Type.NULL || distance != 2);
      curRoom.type=Type.STANDARD;
    }
 else {
      curRoom=roomEntrance;
    }
    Graph.buildDistanceMap(rooms,curRoom);
    List<Room> path=Graph.buildPath(rooms,lastRoom,curRoom);
    Graph.setPrice(path,lastRoom.distance);
    path=Graph.buildPath(rooms,lastRoom,curRoom);
    Room room=lastRoom;
    for (    Room next : path) {
      room.connect(next);
      room=next;
    }
    if (i == 4) {
      ArrayList<Room> candidates=new ArrayList<Room>();
      for (      Room r : lastRoom.neigbours) {
        if (r.type == Type.NULL && r.connected.size() == 0 && !r.neigbours.contains(roomEntrance)) {
          candidates.add(r);
        }
      }
      if (candidates.size() > 0) {
        Room kingsRoom=Random.element(candidates);
        kingsRoom.connect(lastRoom);
        kingsRoom.type=Room.Type.RAT_KING;
      }
 else {
        return false;
      }
    }
    lastRoom=curRoom;
  }
  for (  Room r : rooms) {
    if (r.type == Type.NULL && r.connected.size() > 0) {
      r.type=Type.TUNNEL;
    }
  }
  for (  Room r : roomEntrance.neigbours) {
    if (r.bottom == roomEntrance.top && r.type != Type.NULL)     return false;
  }
  paint();
  exit=roomEntrance.top * Level.WIDTH + (roomEntrance.left + roomEntrance.right) / 2;
  map[exit]=Terrain.LOCKED_EXIT;
  paintWater();
  paintGrass();
  return true;
}

Fixed version (ground truth):
@Override protected boolean build(){
  initRooms();
  int distance;
  int retry=0;
  do {
    if (retry++ > 20) {
      return false;
    }
    roomEntrance=Random.element(rooms);
  }
 while (roomEntrance.width() < 4 || roomEntrance.height() < 4 || roomEntrance.top == 0 || roomEntrance.top >= 12);
  roomEntrance.type=Type.ENTRANCE;
  roomExit=roomEntrance;
  Room curRoom=null;
  Room lastRoom=roomEntrance;
  for (int i=0; i <= 4; i++) {
    retry=0;
    if (i < 4) {
      do {
        if (retry++ > 20) {
          return false;
        }
        curRoom=Random.element(rooms);
        Graph.buildDistanceMap(rooms,curRoom);
        distance=lastRoom.distance();
      }
 while (curRoom.type != Type.NULL || distance != 2 || curRoom.neigbours.contains(roomEntrance));
      curRoom.type=Type.STANDARD;
    }
 else {
      curRoom=roomEntrance;
    }
    Graph.buildDistanceMap(rooms,curRoom);
    List<Room> path=Graph.buildPath(rooms,lastRoom,curRoom);
    Graph.setPrice(path,lastRoom.distance);
    path=Graph.buildPath(rooms,lastRoom,curRoom);
    Room room=lastRoom;
    for (    Room next : path) {
      room.connect(next);
      room=next;
    }
    if (i == 4) {
      ArrayList<Room> candidates=new ArrayList<Room>();
      for (      Room r : lastRoom.neigbours) {
        if (r.type == Type.NULL && r.connected.size() == 0 && !r.neigbours.contains(roomEntrance)) {
          candidates.add(r);
        }
      }
      if (candidates.size() > 0) {
        Room kingsRoom=Random.element(candidates);
        kingsRoom.connect(lastRoom);
        kingsRoom.type=Room.Type.RAT_KING;
      }
 else {
        return false;
      }
    }
    lastRoom=curRoom;
  }
  for (  Room r : rooms) {
    if (r.type == Type.NULL && r.connected.size() > 0) {
      r.type=Type.TUNNEL;
    }
  }
  for (  Room r : roomEntrance.neigbours) {
    if (r.bottom == roomEntrance.top && r.type != Type.NULL)     return false;
  }
  paint();
  exit=roomEntrance.top * Level.WIDTH + (roomEntrance.left + roomEntrance.right) / 2;
  map[exit]=Terrain.LOCKED_EXIT;
  paintWater();
  paintGrass();
  return true;
}