Why is this room always spawning on left side?

Hey. I’ve been coding this dungeon generator and the boss room (the very white room), is always spawning on the right. Here are screenshots of different instances. I mostly get between those two rooms even if i regenerate the dungeon 20 times.


using UnityEngine;
using System.Collections;

public class SpawnRooms : MonoBehaviour {

int spawnerID;

public int maxXDEFAULT;
public int maxYDEFAULT;
public int dungeonSizeXDEFAULT;
public int dungeonSiZeYDEFAULT;

public GameObject room1;
public GameObject room2;
public GameObject room3;

public int DungeonID;

 bool shouldSpawnBossRoom;

void Start () {
	shouldSpawnBossRoom = true;
	InstantiateRooms (maxXDEFAULT,maxYDEFAULT,dungeonSizeXDEFAULT,dungeonSiZeYDEFAULT);

void InstantiateRooms(int maxX, int maxY, int dungeonSizeX,int dungeonSizeY){
	for(int iX =0; iX<maxX; iX+= dungeonSizeX ){
		for(int iY = 0; iY< maxY; iY+= dungeonSizeY){



void CheckWhatToSpawn(int x, int y){
	if (shouldSpawnBossRoom == true) {
					DungeonID = Random.Range (1, 4);
			} else {
		DungeonID = Random.Range(2,4);	
	if (DungeonID == 1 && shouldSpawnBossRoom == true) {
					shouldSpawnBossRoom = false;
					GameObject instance1 = (GameObject)Instantiate (room1, new Vector3 (x, y, 0), Quaternion.identity);
					instance1.name = "Boss Room";
	if (DungeonID == 2) {
		GameObject instance2 = (GameObject)Instantiate (room2, new Vector3(x,y,0), Quaternion.identity);
		instance2.name = "Room2";
	if(DungeonID == 3 ){
		GameObject instance3 = (GameObject)Instantiate(room3,new Vector3(x,y,0),Quaternion.identity);
		instance3.name = "Room3";





You are generating rooms sequentially through y and then x coordinates (for x, for y …). So new rooms are created down first column, then down second, etc. Your boss room selection is the first time a random number is 1…4. After that you disable boss room spawning. So one would expect on average to see it about 70% (4/5 ^5) in the first column, which is what your observations seem to match.