The Binding of Isaac has procedural generation in quite a few layers of the game. From the very structure of a floor with its many levels to the props and enemies. With the current integration I try to recreate the structure of the game's rooms. I am yet to define the type of algorithm (Randomized Prim's algorithm perhaps?), but it works in a couple of very simple steps.
The entire integration is built in Unity, making use of C# and Unity libraries. The algorithm executes every frame, but with a single concern- it can never be fully random just because of how System.Random operates and the number of operations that have to be executed.
-
The algorithm takes in a 2D array and fills it up with "0".
-
Then it estimates the center of the mesh(array) by deviding both of its axes.
-
After the center of the mesh(array) is found, a "1" is written there to indicate the position of the starting room.
-
The algorithm then generates a random x and y values, checks if the room coresponding to these values has any neighbors and if it does, the algorithm writes a "2" in its spot, indicating the existance of a room there.
You can influence the structure of the level by dictating a limit of how many neighbors a room should have.
There is a maxRooms value setting the maximum amount of rooms to be created.
I have also given the ability to set the mesh size.
Example levels generated by the algorithm using maxRooms=10 and x=5,y=5, checking for 1 neighbor only