Sign up to be kept up-to-date with news and offers, 100% spam free!!

Procedural World in Machiavillain

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

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




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 :

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:


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:


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


Now transform some of the trees into evil trees !


A little touch of long grass:


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


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)


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:


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):



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.


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!


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

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.