It's hard for anyone to wrap their minds around the idea in the first place, let alone capture the essence of it for a video game.
Due to the "Rogue-Like" genre of our game, it feels appropriate that one of the challenges faced by the player should be traversing terrain that always is semi-familiar yet never the same. This is usually done by what they call "procedurally generated level design". This is a fancy term to state each level is created by an algorithm, which pieces together prefabricated rooms in an order that appears to be random. For some unknown reason I have tasked myself with creating the level generation for our game. It is a daunting task, especially when one's experience with Unity3D's Engine is limited and time constraints have it due in a week's time (well, at least the basic level design anyway).
Searching online on this topic yields many different answers, and almost all of those lead to more questions. Depending on what one wants to do with the level generation, randomness always seems to be at play. Our group ended up deciding on making our levels tile-based. It is basically placing tiles (or in Unity3D, cube game objects) in a grid side by side to make a board the player moves on.
For example, a level grid could look like this, where x = tile:
x, x, x
x, x, x
x, x, x
I found a starting point for level generation on the Unity website, under the learning archives (for those interested, the link is here: http://unity3d.com/learn/tutorials/modules/intermedia/live-training-archive/2d-dungeon-generation). To summarize the video briefly, there are rooms and corridors, which start near the middle of a grid. An initial room is set, and a corridor is made off of it in a -- you guessed it -- random direction. At the end of the corridor another room is made, and the process continues until all rooms are made.
Sounds simple, right? But as with simplicity, the idea to make things more complex quickly takes over, and soon the simple becomes the complex and the complex becomes a headache.
My head still hurts trying to understand what I made "work".
From the tutorial, the basic level generation was done, and it made some interesting results. In addition to altering room and corridor sizes, I began modifying the code to make the tiles of each room random. It made quite a spotted mess of pixels in Unity3D's scene view. I needed a way to make things look neater. This is where tiles came into play once again.
I've been messing around with tiles ever since. Which tiles can be placed beside other tiles, 2x2 tiles and 4x4 tiles stuck together, tiles with properties that the player cannot step on, etc. I have made progress, but not as much as I should when other issues need attention and the deadline is around the corner.
Moral of the story?
Don't deal with randomness outright. It's too... random. In addition don't make things so complex when dealing with randomness. Not only is it difficult to implement well, it takes a lot of time to sit down and plan how it will work even remotely reasonably. That being said, I am time restricted and I tend to over-complicate things.
I'm sure, with time, my headaches on this topic will subside. I will probably attempt another go at the level generation somewhere down the line, but as of right now the time constraints on this project's completion keep me moving forward. This blog post is not to discourage people from trying to work with randomness. It hasn't beaten me yet either. I just need a break from it by working on something else.