Procedural Level Generation – Part 2
Today I will continue with the Procedural Generation of Levels, in this post I will write about the solution I took to make the levels look a little bit different of being only squares and rectangles. It can get bored if you only have these types of levels in your game.
The quickest way was to continue with the same level generation until now adding a limit of rooms and erasing the ones that left over.
Example without erasing rooms
Example erasing random rooms
Is really liked the effect of this solution because it was really simple to implement and it eliminated the problem with simple boring square houses.
The problem with erasing random rooms was that sometimes appeared levels that where not connected :
The solution to this problem was to check after each generation if the rooms where connected, at the beginning sound simple but lately appear more problems. The most urgent problem to solve was to be sure all the rooms where connected and was possible to walk through all of them, some times happened that rooms where connected to different halls and impossible to walk through the whole level.
Knowing which rooms are the neighbors of each room, we can navigate from the first room until the last room connected and compare the number if is equal to the amount of rooms that we have.
If the number is lower the level is generated again until we find a space partition fully connected.
In the next post I will discuss the last problem with this random erase of rooms and finally talk about the furniture placement.
Currently working on the next post 😀