Script for generating a map?

As the title says, I wanted to know if there is a way to ‘generate a map’, for example like Diablo II… everytime you join/create a new game the map is always different… or MineCraft, when you start a new game it generates a map for you… please let me know and thanks in advance for the help!

Diablo2 and Minecraft are 2 totally different map generators.
Diablo 2 uses pre-made sections of maps (as I understand it) the game doesn’t modify them, just connects them.

Minecraft uses something called Perlin Noise (simplex? General concept is same) which generates a pseudo random image.
Procedural terrain generating is something that really interests me, so playing Minecraft makes me think a lot about how they did it.

If it were me, I’d make 1 image for top-layer terrain, than generated several other images for tunnels.
Each tunnel would have 2 images - the first image will only use 0.5 - 0.52 colors. Anything on range this is a cave. The second image is the bottom height of the tunnel. Random value is used for ceiling.

Of course.

var mapParts : GameObject[];
var partSize : float;
var mapSizeX : int;
var mapSizeY : int;
function RandomizeMap() {
 for ( var x : int = 0; x < mapSizeX; x++ ) {
  for ( var y : int = 0; y < mapSizeY; y++ ) {
   var part : GameObject = Instantiate( mapParts[ Random.value * (mapParts.length-1) ] );
   part.transform.position.x = x * partSize;
   part.transform.position.y = y * partSize;
  }
 }
}

Edit : ninja’d.

The point is, every game has different needs as far as random maps, but you need to have parts that snap together in some way and use Random.value.

Hmm - how would I go about doing that? If they are two completely different terms my goal is to have something similiar to Minecraft