suppliesbas.blogg.se

Random map generator algorithm
Random map generator algorithm











random map generator algorithm

Let's introduce another algorithm, therefore consider the following piece of map generator code. Regular bozo algorithm compared to rotated one. Play around with the zoom factors a little so that you get an understanding of how they work. Here we have encountered a major advantage of algorithms, they reduce the amount of overlays needed drastically. All together results in the following code.Ĭonvince yourself that this produces the same landscape as in the exercise. All we need to know is that the value 50 results in zooming in by a factor of two. For the ones who want to know: the zoom factor is calculated as zoom factor = 100 / (100 - zoom value). The zoom attributes take integer values from -100 to +99, where negative values zoom out and positive values zoom in. For this purpose we can use the zoom transformation, with attributes zoomX and zoomY. So we want to reduce its size by a factor two.

random map generator algorithm

Thus we have a 10x10 checkers board, which is a problem since we want a 5x5 one. We need the checker algorithm, which creates an overlay consisting of alternating boxes of size ten in standard zoom. Such an alternative is to use an algorithm. The landscape shown in the figure had to be constructed, we will now see that there are alternative methods to construct such a landscape. We ended the previous part with an exercise about logical operators and set theory.

  • Rotation, specified by rotate, a positive value implies a counter clockwise rotation.Īll these transformation will be discussed in detail in the following examples.Įxercise: This landscape had to be constructed.
  • Translations, ox specifies the translation in the x-direction and oy in the y-direction.
  • Zooming, specified by zoomX and zoomY for the x- and y-directions respectively.
  • This somewhat more complicated transformation will be discussed later, in the part we restrict ourself to the three affine transformations available: There is the turbulence transformation, which shifts the points of a mask using a sine curve. Transformations are attributes of an overlay and affect the algorithm in that overlay. To adjust the fill pattern created by any of the algorithms to your specific needs, there are transformations.

    random map generator algorithm

    The next part of this tutorial however will explain random algorithms.

    random map generator algorithm

    In this part we will only consider non-random algorithms, so that the basics are not obfuscated. Some algorithm possess properties of randomness, others do not. These parameters are also attributes of the overlay, and are specified with the syntax: Some algorithms have - up to two - parameters, which define their behaviour. Stated more simply an algorithm cuts holes in the mask of its overlay, giving a certain fill pattern. An algorithm specifies which points of the overlay should be drawn, it provides a function which maps a point (x,y) to a boolean value. Both are attributes to the objects map and overlay, although using them in overlays makes more sense.Īlgorithms can be specified within an overlay with the following syntax:Īll algorithms available for the map generator can be found here in the documentation. Here two aspects of the map generator will be explained: algorithms and transformations. The first part can be found here, and should be completed before trying this part of the tutorial. This is the second part of the map generator tutorial.













    Random map generator algorithm