Fractals

Fractals in Game Design

"As a language, Mathematics may be used not only to inform but also to seduce."

n 1977 when famous mathematician Benoit Mandelbrot uttered the phrase, little did he know that his brainchild, fractal geometry, would become seductive to the point of being addictive.

Fractal for a layman is simply an object or quantity that displays self-similarity. But the real technicalities that lie beneath are more complex and intricate. As explained in technical terms, a fractal is a mathematical set that has a fractal dimension (a plot of the quantity on a log-log graph versus scale then gives a straight line, whose slope is said to be the fractal dimension) that usually exceeds its topological dimension and may fall between the integers. (Confusing, eh!). Human nature has been to take the easier path and hence we here instead of delving deep into the mathematical interpretation ,are going to illustrate to you , a practical and more interesting use of fractals .

Call of Duty, Doom, Age of Empires, World of Warcraft aren't new to anyone who is capable of spelling "video game" but what is not known is the role fractals play in the development of these video gamesWhen it comes to video games, there are two fundamental coding styles each with their pros and cons. The style that is most often used in video games is to hard code every element of a video game. This makes a very stable gaming environment that can be modified and perfected so that, come release time, the game has very detailed content that has been painstakingly created for the player by teams of the creators. This is a tried and true method of video game creation that gives the creators complete control over every aspect of the game. The only problem with this method is that it takes a great deal of man power to create every aspect of a video game by hand.Procedural generation, the other style of game creation, has the advantage of not needing such a large team of developers.

Procedural generation is a coding style that is the near opposite of hard coding; it uses a set of instructions to create an object. An example where this would be particularly useful in a video game is a forest: A modeler could go and make a variety of tree models and then have a level designer meticulously place these and eventually a forest would be created, on the other hand, the modeler could make a variety of tree branches and trunks then a programmer could go in and code roughly how these branches should be placed on a tree and roughly how far apart the trees should be and then when the program is run an infinitely large forest could be created. Obviously this is very advantageous as the content-to-effort ratio is much higher and therefore less time and effort is spent creating any of the in game content. Unfortunately some of the detail is lost, but overall this can be an extremely useful tool.Fractals have become inherent to the development of environment in a game and that is mainly due to fact that fractal-based terrain is simple to implement and scales well as fractals are self-similar. A self-similar design is one which, if you isolate and magnify a small part, it will look like the larger whole. For example, consider the midpoint displacement algorithm. Imagine a straight line.

Now, take the midpoint of that line and move it a random amount upward or downward. Repeat that process for the left and right halves of the line: find the midpoint and move it randomly up or down. Keep dividing the line segments in half and repeating this process, and eventually you get something that looks like the silhouette of a mountain range off in the distance. This basic principle can be extended to 3 dimensions to get a 3D landscape.

What basically leads to the use of fractals for designing landscapes is the fact that the details of the landscapes (mountain ranges, roads, skyline, coast ) isn't usually considered important and therefore these details can be computed on the fly, if they come in sight, and simply discarded, if they move behind the user or out of sight. In that way, the whole landscape is never represented at once, and the landscape's extent can be literally infinite.

The textures of natural objects, such as stones, and living things, such as animals and human faces, have fractal properties. Almost any item that does not have an absolutely smooth, glassy surface contains bumps, pits and grooves. The sizes of these features vary by fractal laws: many will be very small, some will be bigger and a handful is relatively large. Their distribution across an object's surface is not entirely random but has a fractal nature. A computer program, using numeric parameters to vary the appearance of fractal features, mathematically “paints” an area in an image to fill it with realistic-looking texture. Compare it to a designer working with an artist to animate scenes by creating thousands of computer generated still images which can take days or weeks of computer processing time and not to mention the sheer effort put in.

No doubt, Fractals have become an indispensable part of (video) game development but there are still areas where fractals can be put to use. As Benoit Mandelbrot puts it :

“Why geometry is often described as 'cold' and 'dry?' One reason lies in its inability to describe the shape of a cloud, a mountain, a coastline, or a tree. Clouds are not spheres, mountains are not cones, coastlines are not circles, and bark is not smooth, nor does lightning travel in a straight line. Nature exhibits not simply a higher degree but an altogether different level of complexity. "