// Now it's time to find the position of the stairs
Randomr=newRandom();
booleanbb=true;
intidRoom=0;
intposY=0;
intposX=0;
while(bb){// I choose a random spot for the stairs
idRoom=r.nextInt(rooms.length);
posX=rooms[idRoom].getSurface().i1;
posY=rooms[idRoom].getSurface().j1;
if(3*distanceToStart[posY][posX]>2*max_dist){
rooms[idRoom].setType(RoomType.END);
bb=false;// If the distance from the start position to the stairs position is large enough I choose it (compared to the farest point the player can reach)