Thank you very much!
The random rooms are instances that get placed at a specific coordinate.
There are basically 2 nested for-loops where the outer one places rooms vertically and the inner one places them horizontaly.
Additionally for the inner loop you get a random number between 1 and 6 that decides where the exit is (and another for walls, traps, ...). So in the end it generates a matrix that looks something like this:
[0,0,0,0,1,0]
[0,1,0,0,2,0]
[1,0,0,2,0,0]
[0,2,0,0,1,0]
[0,0,0,0,3,0]
1 = exit, 2 = wall, 3 = treasure
Based on this you just need to calculate the coordinates where to spawn a room based on screen and room size.
Sorry for that long text, I wrote it mostly for myself