So I'm making a game using love2d where the player will find himself in an zombie infested city but I don't want the city/map to be just the same all the time, so I want to create a random map/city generator, but I don't know where to start, I maybe can make my own but the result would probably be not what I wanted, as I don't want tiles getting placed all over the place messily(it won't look like a city then), I want random set of tiles getting placed in the world/map like buildings get placed randomly throughout the world/map, I hope someone can help me with this as this is really hard for me...

closed as too broad by Anko, Josh Aug 31 '15 at 15:25

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Random map generation is a broad topic. I think you might want to narrow down the scope of this question, because it doesn't seem to be answerable. – dimitris93 Aug 19 '15 at 9:50

Like stated by Shiro in a comment , it's difficult to give a precise answer. I can suggest a possible starting point.

Use random voronoi generation where , given a set of random points P , each point in space is weighted relative to the distance from the nearest p in P.

enter image description here

Now , instead of considering euclidean distance use Manhattan distance and you get something like this :

enter image description here

then adjoust the gradient to obtain this

enter image description here

You should do some research about l-systems, they allow you to specify some basic rules and then procedurally generate the map.

You could for example specify that every building must be surrounded by roads, and every road must continue in a straight line or eventually end, and every road is surrounded by buildings or empty space. Then, the algorithm will start "substituting" a building with a building surrounded by roads, a road piece with a full road... until you have a complete city.

Read the answer to this question for a more detailed explanation: Using L-Systems to procedurally generate cities

  • "You could for example specify that every building must be surrounded by roads, and every road must continue in a straight line or eventually end, and every road is surrounded by buildings or empty space. Then, the algorithm will start "substituting" a building with a building surrounded by roads, a road piece with a full road... until you have a complete city." I'll try and do that :D – Louie Aug 20 '15 at 3:57

There are simple ways to generate cities, depending on your needs.

Some time ago, I wanted to generate cities for a fantasy setting, so I started playing with a generator. Like I said in another SE post: "rough on the edges" is an understatement. But it suits my needs (it may meet your needs too).

This is what it looks like: Generated city

Some terms I use internally:

  • A tile is the smallest unit I handle; on the image one of the small houses fills almost a full tile.
  • A block is a group of NxM tiles.

And this is how I generate it:

First I generate a central feature, such as the block with the "fountain" (let's call this block a town square). I decide its width and height and place it near the center.

Then I try generating "blocks" for as long as I can:

  1. Generate a block size (somewhere between 2x2 and 5x5).
  2. Iterate through the image and decide where to place it. For this a weight is assigned depending on adjacency to other blocks (similar to what I explained on this post).
  3. Place the block if a suitable location is found. When no suitable location is found, go on to the next step.

Once all blocks have been placed, I can add houses and buildings for each block. I took care of leaving a gap between blocks and another between houses. Some buildings use four tiles (2x2).

Finally, I do the actual drawing in an image.

Not the answer you're looking for? Browse other questions tagged or ask your own question.