The Hacker Noon editor now supports embedding Github gists.
- Pick some ‘anchor’ points (like the vertices of a regular polygon)
- Pick one of these vertices and another random point anywhere else.
- Draw the midpoint
Eventually you will see some interesting fractal sort of patterns emerge, which is pretty darn surprising if this isn’t something you have heard of before. Picking the vertices of an equilateral triangle and drawing the midpoint gets you a famous pattern, the Sierpinski triangle:
How do you create something so beautiful and structured from seemingly random points?
Nothing in Nature is random… A thing appears random only through the incompleteness of our knowledge.
The gist of it, is that even though the points are random and the first dot you draw may not be part of the emergent pattern, after the first point, you really cannot escape the domain of this sort of fractal pattern. It really is deterministic and the reason is a bit over my head to be honest, as I only have a curiosity in mathematics, but my education is a bit rusty. Instead, I prefer to play around and experiment.
Below is a CodePen I encourage you to visit and fork and edit to fiddle with the parameters n and r and see what comes of it. You can also click ‘Rerun’ in the bottom right corner of it to see it start from the beginning, using n = 5 and r = 2. Watching these things appear before your eyes is a pretty amazing experience, in my opinion.
It’s worth noting that not all parameters will lead to a fractal pattern. Some will lead to noise without structure.
I first found out about the chaos game via Numberphile on YouTube:
So to conclude, I hope you had fun and I look forward to seeing your code in lovely GitHub gists, showcasing your experiments and new-found knowledge.