RPG game map generator

Started by
4 comments, last by Spodi 15 years, 11 months ago
I am trying to make a random map generator for a RPG game. The idea is to do something similiar to Diablo or Nethack: The topology of the different maps is fixed (which maps are connected to each other) but the appearence of the maps themselves is random. I already searched this forum and the net and found really few articles about this problem (what is strange imo as lots of games have some map generators). What I want is: 1. maps fit the *environment* (caves should look different from wide plains) 2. good partition of space (much small rooms vs wide open areas) 3. possibility to insert some *patterns* (for example a special room that always looks the same) The main differences to generators for game like AoE (this is mentioned as example for a good map generator) are: My maps are not rectangular and naturally bounded by the sides of the rectangle (in fact rectangular maps are really ugly ). What i want is to have a fixed number of entrances which are located in a way that I can link the maps together properly. I dont need some balancing of ressources, the maps *only* need to look fine and be interesting to explore. The Question is: Do you know any resources about some basic ideas of random map generation ? My first approach something like that: I start with a blank map and get a queue with one starting tile. Then I perform the following: while (queue is not empty) { take first tile out of the queue mark the adjacent blank tiles with a certain probability as free and with a certain probability as blocked. add tiles marked as free to the queue } Some sort of flooding algorithm essentially. The problems with this are: - its bad for making big plains - its hard to control the size of the map (i do this via changing the prob of blocked/free based on the size of the map) - I cant include some patterns - It is often ugly ...
Advertisement
If you haven't already, check out Dungeondweller - it's a roguelike development site that has articles on their development. There are several algorithm articles as well as a community, perhaps you could find something useful for your generator.
Take a look at procedural textures and perlin noise.

You can use these methods with different sets of parameters to make different effects, from smooth rolling landscapes to caves and caverns. I'm sure, with a bit of ingenuity you can make something to fit your requirements.
You could use a "puzzle piece" approach, kinda' like the PS2 .hack games. Have a set of rooms that the computer can choose from, perhaps assign random sizes to each room (for instance, have an X by Y square room where X and Y have a defined range, Hallways of X length and Y Width, etc.) and that will get you started making the rooms. Each part of your map would need a coordinate. The program would start at 0,0 (top left corner of the map) and put in a room. Then you could define random objects that are in that room (there is a X/1000 that [this object] will appear in the room). The program then randomly places doors in the room and records the present X and Y coordinates of the room. Using a loop, the program can put a room next to the one you just made at each end and expand in a kind of triangular pattern:

1 2 4
2 3 5
4 5 6

etc., setting each room so that it touches the rooms it is adjacent to and has a door with at least one of them.

Example code:

//place treasure in the room with coordinates 60, 30 to 90, 80//minx and miny are the farthest left and north coordinates (60 and 30)//maxx and maxy are the farthest right and south coordinates (90 and 80)//put all the stuff you need to generate random numbers using the time heretreasurechance=random()*100;if treasurechance>95 PlaceTreasure(minx, miny, maxx, maxy);PlaceTreasure(minx, miny, maxx, maxy){   TreasureX=random()*(maxx-minx)+minx;   TreasureY=random()*(maxy-miny)+miny;   //stuff that puts down a treasure at TreasureX,TreasureY}


Generating rooms will be harder, because you'll have to decide each type of room that you want, set up functions that create each kind of room, etc.
Give the dungeon generator from here a shot. I've used it before and it works just wonderfully. [smile]
Quote:Original post by NowSayPillow
Give the dungeon generator from here a shot. I've used it before and it works just wonderfully. [smile]


I second this. I have checked out that project before and it always makes me want to make a rouge-like. :)

While it may be designed for dungeons, you could easily apply it to outside worlds where the halls are pathways and the rooms can be points of interest (camps, large rocks, water, hills, etc). You can then go through the map a second time after generating the landscape, placing vegetation randomly based on the location of the tile (wouldn't want trees on pathways... probably), surrounding area (smaller, greener vegetation could be near water while large tree clusters hang out farther away from everything), how thick you want the vegetation, etc. You probably won't need anything more advanced than that for the vegetation since, like with real life, it is quite random. Though if the details are really important, you could also implement "rules" for vegetation, such as flowers that need a lot of light will be removed if put under a large tree, then loop through the vegetation generation, placing randomly and removing appropriately to fit the rules, until desired density has been achieved.
NetGore - Open source multiplayer RPG engine

This topic is closed to new replies.

Advertisement