static List<Quadrant> SpacialPartition(int mapSize, double splitChance, double roomChance, PseudoRandom rnd) { Quadrant first = new Quadrant(0,0, mapSize, mapSize, 0, 0); List<Quadrant> next = first.QuarterQuadrant(rnd, roomChance); List<Quadrant> final = new List<Quadrant>(); while(next.Count != 0) { int index = 0; double split = Math.Round(rnd.Next(), 2); if(split < splitChance) { List<Quadrant> subs = next[index].QuarterQuadrant(rnd, roomChance); if(subs.Count == 0) { final.Add(next[index]); } else { next.AddRange(subs); } } else { final.Add(next[index]); } next.RemoveAt(index); } return final; }