• Register

You're the villain: it's up to you to build your own manor, raise your monsters and set up your traps to lure in and isolate your victims. But remember, a proper villain follows the Horror Movie Rules, so kill them when they're alone, keep the virgin for last, and do not hurt the dog !! Inspired by all the horror movie clichés, Machiavillain is a simulation/strategy game where you will get your fill of Dark comedy, silliness and chainsaws.

Post feature Report RSS Procedural World in Machiavillain

How we generate the procedural World in Machiavillain, to keep each play session new.

Posted by on

In MachiaVillain, we want every play to be different, a new experience. That's why the world is randomly generated.

Seed:
A world is generate from something coder name as: a seed. This seed is just a number, any number. From it a unique world can be generated.

Example with Seed = 30, 625 or 1

Seed30

seed625

seed1

We want to get a different seed number each time the player start a new map. But how do we ask the computer to get a random number ?
A computer can only calculate. It can't give you something random. So the solution is to get the random element from the Human !
The coder tricks to get a random number, is to record the time when the player start the game (or click on a button).
And from this recorded time value, he will took the number a human can't reproduce, even if he wants, which is he number of milliseconde of the time value when the player clicked.

For example the player, let's call him Joe. He clicks on the start button precisely at february 16th at 10:42 pm and 156 ms. We then take this 156 ms as the seed to make a random world. Seed = 156 ! If Joe starts a new map the day after, he will click on february 17th at 10:30 pm and 589 ms. We will use then 589 as the seed number and it will generate a completly different world. Even if Joe wanted it, he couldn't click again at exaclty X month X day X hour X min and 589 ms to get the same world.
Joe just gave a random number to his computer :)

So we have our random seed.

Perlin Noise
We will use this seed as an input for a function we call Perlin Noise. Perlin noise is function that can generate a texture. From a position X, Y, it gives you a value between 0.0 and 1.0.
If we consider a value of 1.0 to be white, and 0.0f to be black, you obtain this Texture:


It is usually use to give an organic look to random world. If we don't change any parameter of the perlin noise texture, we got a round, blob look texture.
But we can combine and modify this texture !

We can scale it:


And we can also combine several textures with different scale to get something new !

+ =

We now have something with a mountain kind of look. We have lost the round blob look.
So with this Perlin noise texture, we can get round/blod, and sharp mountain like texture.

Generating our world ground:

We start from a Perlin noise texture:


We decide that any value above 0.5 (grey to white), is grass. And value between below 0.5 (0.0 to 0.5, black to grey) is dirt.
This will transform our Perlin noise into this ground :

->Perlin-Threshold->

We have a ground !

Generating our world rocks:

For the rocks, we are using another technics, because it needs to be less spread out on the map. I call it the "splash technics".
We are just drawing random circle of hills of different size on the map.
The number of circle and their size are choosen arbitrarily to make things look good and fun to play :)

Example with 1 big circle of rocks:

Example of several circles of different size of rocks:

Hills

Generating our world vegetation:

Then let's add some Tree. We use the Perlin texture (the one with a mountain kind of look.) like we used previously, to add trees:

Tree3

But, they all look the same. Se we randomly change tree look as well as their growth stage:

Tree4

Now transform some of the trees into evil trees !

TreeEvil5

A little touch of long grass:

Grass6

At last, add 3 types of poisonous Mushrooms. Useful to make any kinds of potions :)

MushRoom6b

Generating our cimetary:

Our Cimetary will provide energy to players. We place it randomly on the map, but with the constraint of being accessible (not in the middle of a Rock):
(upper right of the picture)

Cimetary7Cimetary7

Adding the Road:

In the current version, we choose to add a road not too close to border,
and in straight horizontal line. Of course we need to remove close rocks and trees:


Raod8

Later in the game, you will be able to upgrade the road. We will talk about it in another article.

Adding minerals (gold and iron):


Mineral9

Adding Spiders:

At first we added a spider nest in a random free position. But we soon realized that sometine, when the spider nest is too close to the road, spiders were killing every victims passing by.. :)
So we added a constraint not to spawn spider nest too close to the Road.

Spider10

Of course, we will not stop there. We will add in the futur the swamp (non buildable but provider of new resources), wendigo, chupacabra (steal your food), tree monsters etc...

And now it's your turn!

Build your own mansion on this freshly made world. Raise your monster and be the ultimate evil lord!

Nv_style_01

You can take a look at our Kickstarter if you're interested.

Post comment Comments
SniperCharlie
SniperCharlie - - 321 comments

This game will soo fun to play.Can´t wait^^

Reply Good karma Bad karma+2 votes
WildFactor Author
WildFactor - - 6 comments

Thank you SniperCharlie ;)

Reply Good karma+1 vote
Guest
Guest - - 689,904 comments

Procedural generation is so satisfying once you get it working :), looks good.

Reply Good karma Bad karma+1 vote
WildFactor Author
WildFactor - - 6 comments

Yes it's better once it works :) Thank you

Reply Good karma+1 vote
InfiniteProductions
InfiniteProductions - - 10 comments

Thank you for sharing your dev experience, it is very interesting and may help others who wish to create similar game/world.

Your game looks good so far, wish you the best.

Reply Good karma Bad karma+2 votes
WildFactor Author
WildFactor - - 6 comments

Thank you InfiniteProductions. We will try to continu like that.

Reply Good karma+1 vote
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: