[Programmation] A pseudofractal approach for a matrix generator.
Is far less scary than it sounds like, actually.
You know that phenomena seen in the nature? Fractals? Pretty much repetitive shapes that obey some chemistry and physics I'm not gonna board.
Well, they usually have a "core" from where they generate outwards. That's pretty much the idea. Making an algorithm that picks a point in a matrix and develops "outwards" from it.
Been working on it for 2 days now (not as much as I should, IMO, given I do so during the dead times at my job). So pretty much, the thing goes like this:
1.- Define an empty matrix of a known size
2.- Put a 1 in the very center of it
3.- Iterations and more iterations!
So pretty much, the interesting part starts at bullet 3. These iterations can be the "headache" since we are talking the matrix should be filled up in 4 different directions PER STEP, meaning bigger maps require more calculations and the algorithm should also identify parent "blocks".
To deal with this, I came up with 2 "steps" per iteration. First, the centered neighbor grows, then, it branches out from it and checks if the neighbors from the past iteration are 1s or if the direct parent is to do so.
Here goes a little screencap of the resulting matrix by drawing "big 8x8 pixels" through the engine I used to program this. As a little sidenote, I also added the possibility to adjust the size of the matrix and both the minimum and maximun amount of 1s desired for each run.
As for uses this may have? Well... I have a little something in mind, but it's gonna take me a while.
Anyway, any thoughts?
You need to be logged in to comment