Tutorial: Map Generator - Randomness: Difference between revisions

Maikel (talk | contribs)
No edit summary
Maikel (talk | contribs)
No edit summary
Line 3: Line 3:
==Turbulent Lines==
==Turbulent Lines==


[[File:MapGenerator_ExampleTurbulentLines.png|200px|thumb|right|Straight lines deformed randomly!]]
So let's start with introducing turbulence. For this purpose a new algorithm is introduced, the lines algorithm. It draws vertical lines where the parameter <code>a</code> determines the line width and <code>b</code> the distance between the lines. Therefore <code>b</code> must always be chosen larger than <code>a</code>, otherwise the whole overlay will be filled completely. Furthermore we will introduce two new attributes which together specify the turbulence transformation. First there is the <code>turbulence</code> attribute - which takes the values 10, 100, 1000 and 10000 - specifying the amount of deformation of the layer. Second the <code>lambda</code> attribute can be used to repeat the deformation process up to 20 times. So now let's take a look at this piece of map generator code and the result.
So let's start with introducing turbulence. For this purpose a new algorithm is introduced, the lines algorithm. It draws vertical lines where the parameter <code>a</code> determines the line width and <code>b</code> the distance between the lines. Therefore <code>b</code> must always be chosen larger than <code>a</code>, otherwise the whole overlay will be filled completely. Furthermore we will introduce two new attributes which together specify the turbulence transformation. First there is the <code>turbulence</code> attribute - which takes the values 10, 100, 1000 and 10000 - specifying the amount of deformation of the layer. Second the <code>lambda</code> attribute can be used to repeat the deformation process up to 20 times. So now let's take a look at this piece of map generator code and the result.
  // Straight lines made interesting.
  // Straight lines made interesting.
Line 13: Line 14:
  };
  };
  };
  };
blaBLA
You will have noticed that the straight golden lines of the algorithm are deformed quite smoothly by the applied turbulence. Turbulence uses a sine function to shift randomly shift the points of a layer, which transforms regular shapes into disordered and curved ones. Now try larger values for the <code>turbulence</code> and <code>lambda</code> attributes and observe there effects. Turbulence is a crucial attribute and you will need it in almost any dynamic map you design.
[TODO: Explain algo lines and turbulence]


==Example 2==
==Example 2==

Revision as of 20:48, 21 January 2011

This is the third part of the map generator tutorial. The previous part can be found here, and should be completed before trying this part of the tutorial. In the two previous parts you learned how to create overlays and combined them with logical operators, use algorithms and how to transform them. These ingredients do allow you to build some basic maps already, as seen in the previous exercise, but we need one more aspect of the map generator to make landscapes really interesting. That aspect is randomness and is treated in this part of the tutorial. There are two ways randomness is introduced into maps, these are through algorithms that behave randomly and through a single transformation called turbulence.

Turbulent Lines

Straight lines deformed randomly!

So let's start with introducing turbulence. For this purpose a new algorithm is introduced, the lines algorithm. It draws vertical lines where the parameter a determines the line width and b the distance between the lines. Therefore b must always be chosen larger than a, otherwise the whole overlay will be filled completely. Furthermore we will introduce two new attributes which together specify the turbulence transformation. First there is the turbulence attribute - which takes the values 10, 100, 1000 and 10000 - specifying the amount of deformation of the layer. Second the lambda attribute can be used to repeat the deformation process up to 20 times. So now let's take a look at this piece of map generator code and the result.

// Straight lines made interesting.
map ExampleTurbulentLines {
	mat=Water; tex=water;
	overlay {
		algo=lines; a=10; b=20;
		mat=Gold; tex=gold;
		turbulence=10; lambda=0;
	};
};

You will have noticed that the straight golden lines of the algorithm are deformed quite smoothly by the applied turbulence. Turbulence uses a sine function to shift randomly shift the points of a layer, which transforms regular shapes into disordered and curved ones. Now try larger values for the turbulence and lambda attributes and observe there effects. Turbulence is a crucial attribute and you will need it in almost any dynamic map you design.

Example 2

Example 3

Exercise

Summary

[TODO: Summarize]

The next part of this tutorial about some special features is here.