Advertisement

Automatic Level Design

Started by August 28, 2002 02:36 AM
17 comments, last by Leonid Shevtsov 22 years, 4 months ago
Some cool games like Diablo generate level maps ''on the fly'' while creating a new character. The question is, *how* do they do that?
I can think of 2 ways.

One would be a randomized generator of different map pieces using good ol != and == == meaning that the basic rules say they can connect.

The other is making about 100 or so maps that it randomises for each type of map. The problem with this si I dont know how they get level 2 butcher and stuff like that in em with this method.
Advertisement
places like the butcher´s are simply items which are only inserted in specific levels, the rest of the level is more or less built around it randomly.
I once wrote a roguelike game that generated dungeon maps like this:

1) begin with an empty level (solid rock in this case)

2) attempt to add a room of a random size and type in a random location; if it overlaps an existing room, cancel the new one.

3) repeat stage 2 until there are the number of rooms you want (being careful that we don''t get stuck!)

4) pick a random point in a room, and try to add a passage N/S/E/W until it hits another room; if it doesn''t, or it scrapes against another passage in an undesired way, cancel it.

5) repeat stage 4 until there are the required number of passages.

The method will be different for different types of map (city, dungeon, forest, death star, whatever) and indeed in my roguelike game there were several variations for different levels. I hope this helps.
If you can get your hands on a AD&D first edition Dungeon Master''s Guide (not sure if later versions have it), you''ll find a section detailing how to construct a random dungeon on the fly. It may not translate directly to your game, but I''m sure you could get some inspiration from it.
Yes, g''s method is pretty good. My generator (which I wrote using the great ADOM as an inspiration) could combine random rooms with predefined rooms. It just made sure that the exits from the predefined room connected with the rest of the level.

The same principle of being able to balance between how much random you want and how much control you want can be applied to monster generation and item generation.

What I did was that, beside the usual attributes (value, damage, material etc.), each item could have some descriptive qualities that didn''t affect gameplay (classes preferring the object, magical object, ancient item, etc.) . So when defining a room, I could make an request for a random item as general as "costs less than 10 gold coins" or as specific as "golden ancient artifact, being a weapon or a defensive equipment preffered by knights with a value of more than 500 gold coins". Then the game would randomly generate objects until one of them fit the description.

Advertisement
To look real, you need to have recognizable architecture. In Diablo and various roguelikes, the scheme is pretty simple. Rooms are recognizable. They have four walls, and door that connect to passages. Often, rooms are designated storage, in which case they are small and saturated with barrels. Or rooms just have items randomly strewn throughout. Humans tend to stockpile things to make organization and transportation easier, so just make sure that everything in the room is contiguous. Lights tend to be distributed evenly along walls for aesthetic reasons. If a room is large, lights tend to be present in the center, which is usually either a transport to the edges, or, if very large, the center of attention(as a dance floor or sports field). Either way, lights there are necessary. Entrances to large rooms tend to be large(factory pickup) or numerous(stadium) themselves to facilitate whatever activity for which the room is intended to be used.(numerous considered in Diablo, probably by accident, but not large)

Think about how humans would use it, then just link (an arbitrary) cause(room is big) and effect(so it must have large or numerous entrances). Developing a decent algorithm once you have that is pretty easy.

It would take some careful consideration to think of a logical reason to have 15+ basement levels to any facility, but that''s beside the point.
g, how did you make it so only one doorway would lead to 1 room? Didn''t you ever experience like 6 doors on 1 wall to the next room?
quote: Original post by Anonymous Poster
g, how did you make it so only one doorway would lead to 1 room? Didn''t you ever experience like 6 doors on 1 wall to the next room?


I didn''t, no. This might have been something to do with the (large) size of my levels, or other complexities (my tunnels would join and bend and so forth).

If you want to prevent that, give each room a unique ID as you generate it; then store a table of which rooms are connected (bearing in mind that a tunnel from A to B connects B to A also). For a small level, the table shouldn''t be unmanagable, and of course you don''t need it once the level is finished (though it might help quite a lot for the AI).

The only danger here is that your passage adding routine could jam if it runs out of rooms to connect when the number of passages still hasn''t reached the quota. Rather like that guy in ''Wargames'', your computer needs to know when to give up.
I see... interesting.

This topic is closed to new replies.

Advertisement