Random map with fixed sections.

Started by
11 comments, last by menyo 12 years, 2 months ago
Hi, after having made several random alghorithms i decided to scrap the idea of total randomization of each tile since it just won't work for what i am planning. Or at least i don't have the skill to get the maps the way i want with just alghorithms. Hence i decided i need a bunch of fixed tilesets to create my map. Think of it as a bunch of 32*32 maps that get loaded in the main map. I am having trouble to decide what method to go for.

First of all, i don't like the idea of having each of these fixed tilesets have the exit/entrance at the same location. I Also might need several sets for each side and corner but i might settle with just a impassable 32*32 set all around (except for the spot where it will connect to the next map).

I love the idea of being able to draw those 32*32 sections in a painting program like PS, it will be easy to see and allign the pieces. But is there a way i could add in aditional information like where this piece should connect with another one? I mean if a particular section has 5 tiles open on the right side from Y6 to Y10 i need to store this so the next section should fit this. I could color these tiles differently so they will also be put in some aray. But eventually i also need to add in level information since not every level uses the same tiles. So what are my options here?

Another method would be regular text files, i can easily add extra lines in it to store additional data and save that. But to make that much maps in a text file and allign it all properly is very time consuming and it's less clear what the end result will be. Thats why i'm really opting for the image approach.

Programming whise i want to create a class for these sections and load every map into it on runtime. Then another class will work these tiles into a complete map. In the end i might serialize all those sections i have into XML but the first priority is creating a map from a bunch of sections and get some gameplay going.

It's very hard to find info online about this. I know Diablo 2 uses this technique very succesfully and i believe diablo 3 is using a simular approach with painted tileset sections corresponding to 3D assets. I appreciate ANY ideas or info on how to pull off something like this.

Thnx,
Advertisement
There are 2 options.
#1, use a pre-built Tile editor. the two I hear about most often are Tiled and Mappy, with Tiled being the one I hear about most. You can use these editors to lay out your maps using your pre-created tiles, and I'm sure you can add extra information about each tiles (including possible entrances/exits). You'd then use the code from Tiled to read and process your map in your game.

#2, create your own editor. Basically, you would use the same engine you use to display your map in the game in your editor, except, where you'd typically have the player's stats, etc., you'd have all your tiles displayed, and you can select which tile you want to go where. And, you'd have to add in the ability to edit the properties of the file in your map. You can save it off in whatever format you want. So, when you laod the map in the editor or the game, you use the same loading code.

Both have their pluses and minus, but you have to decide which one you feel more comfortable with. personally, I've one both, and I prefer the pre-made editors, but that's just me.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

In addition to what BeerNutts suggested, here are a few thoughts:

You can still use a bitmap to create the maps, and use a seperate text/XML/JSON/whatever file for map/tile information. Storing map information seperate from the section maps may be beneficial later anyway. I've done something similar to this before, the caveat being that once you get to a certain number of different tiles, it becomes difficult keeping track of which color corresponds to which tile. Also, after a point, you run out of visually distinct colors.

It sounds to me from what you are describing that you could analyze the borders of each section programatically to determine connection points fairly easy.

Building your own editor would be time consuming (although, a great learning experience if that is what you are after). The only time I consider rolling my own is if my vision includes allowing the end-user to edit maps.

Both Tiled and Mappy are decent programs, I've used them both before, and they include map loading/display libraries for many frameworks. They both allow adding "metadata" to the map and individual map elements. Tiled also supports shapes (such as defining regions) and other niceties that may come in handy.

The real trick with all of this, of course, is making sure that each section can be used with a large selection of other sections, so that a large number of appearent random and seamless-looking maps can be created. This is where the art of level design will come into play.
Hmmm it's really weird i usually just can't get clear on what i want the first post.

I just want the layout of the map, almost no objects or textures are fixed. If i want somekind of quest zone that needt to be fixed i could inc my .png purple and add an interactable object, boss, dungeon, etc in that place. So mappy or tiled only add time to my project since i can just ink in 32*32 tilesets next to eachother in photoshop. I already made blue tiles where entrances are, purple for exits and thinking about adding yellow for "fixed" lighting to make some maps more interesting. I probably also add somekind of color where no objects can be spawned on so there is always a way from point A to B.

I got this far already: showing 3 of the 4 sections i made, they all get more love later on biggrin.png.
semirandom.jpg

1. So what i did, paint 4 PNG's.
2. Make a class to hold the sections color data.
3. In the class that builds the map lookup all the files in a folder and create a list of these sections.
4. Spam them on a 512*512 grid like a cheap jigzaw puzzle.

ToDo:
1. Make some alghorithm that plops one exit and entrance on the map at least a couple of tiles away.
2. Fill that up with a nice rout that connects without dead ends. //This still riddles me a bit but i got some concepts on paper.
3. Make it so it can plop a quest tile in there.
4. Make a whole bunch of these tiles.
5. Some alghorithm that textures the environment nicely.
6. Add mobs that chase the player.

It already has fairly good working smooth realtime pathfinding. But most probably it will lag when 20+ mobs chase the player but thats for later worries. Anyway, i'm still looking for sugestions for systems like these.

PS.
Those 2 smilies are characters, can you find them? :D
I don't really have any specific suggestions, and you may have already seen these, but there are multiple articles on random map generation over here that might give you some ideas:

http://roguebasin.roguelikedevelopment.org/index.php/Articles#Map
Yeah i have seen it, it's for total random maps, but may come in handy when i want to improve other things then the map like mob AI.

I basicaly need ways to connect these maps pieces into a full map, the full map dos not have to be filled completely. I also like the idea of rotating these pieces so i don't need 4 different corners for example and i can just focus on making "visual" different corners that get rotated in place. Same goes for 3 Ways and 4 ways. When i know more about this i want to add sections that don't nececarely have passage to the next on the middle.

Yeah i have seen it, it's for total random maps, but may come in handy when i want to improve other things then the map like mob AI.

I basicaly need ways to connect these maps pieces into a full map, the full map dos not have to be filled completely. I also like the idea of rotating these pieces so i don't need 4 different corners for example and i can just focus on making "visual" different corners that get rotated in place. Same goes for 3 Ways and 4 ways. When i know more about this i want to add sections that don't nececarely have passage to the next on the middle.


Basically, treat the map like a tileset, except you're constructing rooms out of pre-built pieces/chunks. Have each room know whether it has N/S/E/W entrances/exits. Then assemble them as large tiles. The key here is that each room must have corresponding entrances and exits at pre specified locations along the edges to connect to another room tile adjacent to it (assuming it has the appropriate N/S/E/W info). From there its just a matter of tiling the room randomly, kinda like wang-tiles. http://en.wikipedia.org/wiki/Wang_tile
There is more to it then that.

Let's say, whenever i add a 3 way tile i must add another 3 way tile somewhere to connect that extra "path". I also have to make sure it can connect to somewhere without overwriting/crossing nececary sections like a quest poin, entrance or exit.

I obviously also want interesting maps so i simple straight path is not going to cut it for me.

As of now i connect all the sections in the middle of the edge, this would probably work for rooms with corridoors but i'm not sure about natural caverns. Preferably i create the alghorithm so it handles multiple, if not all map types so i just need to create the sections.
In my game I use a combination of a template based approach and randomly generated maps. The basic idea is, to place templates randomly on the map first, then connect them by tunnels , then modify the tunnels to meet some criterias (i.e. no dead-ends etc.).

In more detail:
First off, map your grid to a graph, each node represents a tile, each edge represents a connection between two tiles. Then you can utilise some graph algorithm like kruskal (minimal spanning tree). That is, fill your graph with all possible edges (every tile is connected to its neighbors), then place special locations (templates), by removing and marking edges. After that use the kruskal algorithm to create a maze-like tunnels between your templates (don't remove template based edges!). And finally modify the "kruskal tunnels" (i.e. remove dead-end edges) to meet a more non-maze look.
I prefer a top-to-bottom approach, where you first divide the whole map into sections, with specific requirements for how the sections should connect to each other and roughly what they should contain. Then you tackle the problem of designing each of the sections, following the requirements that were established in the previous step, which in turn might decompose the problem into designing little subsections. You can do this type of progressive refinement until you get to having to design a specific tile with certain properties, which you can then pick from a database of predefined tiles.


Reducing the problem of designing something complex to subproblems of how to design a few simpler things is very powerful and I believe it can be used to design basically anything, from music to airports.

This topic is closed to new replies.

Advertisement