Posts Tagged ‘map generation’

Procedural Maps

Posted by (twitter: @Rubikow)
Saturday, July 18th, 2015 9:15 am

Hola!

While playing Invisible Inc. I suddenly wanted to build procedural maps like the game does. So I wrote a small procedural map generator capable of doing some pretty cool stuff. At the moment It produces maps like these:

vaults talecraft hexo bunker proc5 proc4 proc1 prmap proc10 rnd1 proc9 proc7

The algorithm producing all of these maps is the same. Hovewer I programmed different “map-renders” to get different visual designs. As you can see it is capable of building simple rogue-like maps as well as more complex maps (like the valuts-and-caverns map you see or the hex-field landscapes). The main feature is: (other than using random maps … ) There is always a way from point A to point B!

You can generate some levels here:

 

“What does this algorithm do?”

Basically you feed my algo with sets of “rooms”. A “room” in Javascript looks like this:

[

[new JTile(1),new JTile(1),new JTile(1)],
[new JTile(1),new JTile(1),new JTile(1)],
[new JTile(1),new JTile(1),new JTile(1)],

]

This room looks like this:

simple

As you can see its a simple 3×3 room. JTile(1) in the code above means “JoinTile” (or more simple: a Tile) of type “1”. As you can see in the image my map-viever interprets a “1” as a field of a vault-room. If I change the center tile to 4:

[

[new JTile(1),new JTile(1),new JTile(1)],
[new JTile(1),new JTile(4),new JTile(1)],
[new JTile(1),new JTile(1),new JTile(1)],

]

It looks like this:

simple

As you can see, my map-viewer interprets a 4 as a field of dirt.

Now, here comes the main feature!

JoinPoints!

Lets change our room to this:

[

[new JTile(1),new JTile(1),new JTile(1)],
[new JTile(1,(1)),new JTile(4),new JTile(1)],
[new JTile(1),new JTile(1),new JTile(1,(1))],

]

See? I added a “,(1)” to the fields in the west, and south-east. Now lets generate 3 rooms instead of one and let’s have a look:

simple2 simple3

These are two of many possible combinations the generator may produce now. (Some parts of the rooms are hidden behind walls due to my map-viewer).

What happened?

By adding the “,(1)” I told the tile, that it may join with another tile of type 1 in any direction. You can read:

    new JTile(1,(1))

as: “I am a Tile of type 1 and I will join with other tiles of type 1 in any direction!”.

Using only this, we already have a powerfull tool here. Add some more rooms of different types and shapes and give them different “join-partners” such as: “A toilet room always joins with a corridor” or “a vault entry always joins with a cavern” and you can build maps like this:

vaults

I’m working on a detailed tutorial at the moment, so if nothing of the above makes sense to you, just be patient 😉

 

“How can I use it for my games?!?”

If you want to, just go to my website and copy some of the current code under development. I wrote the generator in javascript for web browsers and in c# as a library for unity. Once I have the import/export part done I will publish it for everyone to use. Stay tuned!

 

Greetings:

Prowler!

 

 

[cache: storing page]