Jump to content
Banner by ~ Ice Princess Silky

Fractals. A few thoughts on how they can help you


Jesse Terrence

Recommended Posts

(edited)

I guess people could argue this thread would be better for a personal blog, but then again, if I was to put it on my blogs people would most likely never be able to find it, given I'm not one of those popular active users, and still, people can contribute even more if I make it a forum thread instead.

So let's get it on it.

If you don't know what fractals are, you might be wondering what are they. Well, to put it bluntly and without diving deep into it, fractals are geometric shapes that repeat themselves all over. A couple fractals I could think of could be snow flakes or even how a good amount of plants grow (though sometimes the enviroment can deform their fractal growth).

8jxPNQGLuK903v0tr2wUa1ZHNwiOj7EfkQOIOshe

Fractals are very mathematical, and thus, they can present numerical and geometrical patterns, and that comes really handy for programers. If you put attention on the above image, you might notice there's some sort of simetry on the snowflake, and you might also notice how the branching patterns tend to repeat themselves and how sometimes they don't do so.

Now, I mentioned it can be useful for programers. And I will give a good example (which was the main target of this little topic). If you've ever played a dungeon crawler or rogue like game such as Persona 3 and a whole lot of others, and even games such as Terraria and Minecraft, you might be wondering how can the dungeons be so different one from another. That's where fractals come into play.

Those worlds are randomized by the program and generated in those annoying load screens. But how does that work and why should we care?
Well, is an easy answer. They are generated through programs that emulate fractal branching. They have a core coordinate, and expand around from there. Sometimes, certain conditions must be met to generate a certain block or entity, but that there is where the whole randomizing and conditioning comes. Let's make an example labyrinth to understand it a bit better.

In our little labyrinth, we shall represent walls with █ and empty squares through ░. Also, my starting (core) square would be ╬ and my goal would be ╪. Let's suppose I would want my labyrinth to be of about 8 by 8.

If told my program to set my core coordinate to develop the labyrinth at, let's say, 3, 3, and the rest of the spaces be empty without a goal, it would look something like

░░░░░░░░
░░░░░░░░
░░╬░░░░░
░░░░░░░░
░░░░░░░░
░░░░░░░░
░░░░░░░░

But, then I can let my program know when I might want to randomize a coordinate for the goal. If I only let it decide it should be put anywhere, despite how far is it from my core, it could literally put it just next from my core. That would make a really boring labyrinth.

░░░░░░░░
░░░░░░░░
░░╬╪░░░░
░░░░░░░░
░░░░░░░░
░░░░░░░░
░░░░░░░░

Also, up to this point, my labyrinth has no walls!

So let's suppose I just tell it to put walls at whatever point as long they aren't the core nor the goal.

██░░█░╪░
░░░█░██░
░░╬█░░░█
░░░░█░░░
░██░░░█░
░░████░░
░░███░░░

Is randomized, yes, and there are walls, but if you pay close attention, you'll notice my labyrinth might not have an actual solution, or sometimes walls aglomer and that sucks.

That's when applying the idea of fractals works. With some programming tweeks, we could let our program know that each empty space must have at least one empty space next to it, as long as that empty space is not the space from which it branched. We can also order it to have at least one empty space next to the core, if not more.

██░░█░╪░
░░░█░░█░
░░╬█░░░█
░░░░█░░░
░██░░░█░
░░████░░
░░███░░░

That could solve the no solution topic.

We can also give it some more order and so.

I'll keep updating later on.

Edited by Jesse Terrence
  • Brohoof 3
Link to comment
Share on other sites

When I think of fractals I think of coastlines and how because of the shiftyness of sand and the coming and going of tides that's essentially what they are, which makes it impossible to accurately measure them.

Link to comment
Share on other sites

Fractals has never helped me. I cannot think of a place where it would be applicable, unless it is a very fast calculation that can give some good prediction to something, like creating AI, or doing some tedious task.

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Join the herd!

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...