Spread algorithmic Christmas cheer with our snowflake generator

Snowflakes are perfect examples of how complex and beautiful designs can emerge spontaneously from a few simple rules and a bit of randomness.

As data scientists, we usually spend our time trying uncover hidden rules and patterns that shape the seemingly random world. It was a refreshing new challenge for us to try to create these patterns ourselves. This holiday season, we set out to create a snowflake generator that would create unique and beautiful digital Christmas cards for our friends. But how?

We first took our inspiration from the Game of Life, which was invented in 1970 by the British mathematician John Horton Conway. In this "game," there is a matrix composed of cells that can either "live" or "die" based on the state of their neighboring cells and a few simple rules. After being seeded with a few live cells, complex patterns can emerge.


Some of the rules in the "Game of Life" are 1) any live cell with fewer than two live neighbours dies, 2) any live cell with two or three live neighbours lives on to the next generation, 3) any live cell with more than three live neighbours dies and 4) any dead cell with exactly three live neighbours is born

This model is called "cellular automata" and has been widely studied by physicists, mathematicians, and computer scientists. Scientists experiment with tweaking the rules or seeding the board in different ways to produce patterns with surprisingly complex properties. We wondered: Could we use this model to produce digital snowflakes too?

The first thing we needed to do was to use a set of hexagonal tiles, since snowflakes have six sides:

Fun fact: Snowflakes are made of tiny hexagon-shaped crystals that are formed when water molecules lock together.


To turn this canvas into a snowflake, we needed to "freeze" or fill in some cells to create a unique visual pattern. We first tried taking a slice of a hexagon, randomly freezing some of its cells, and generating mirror images of the result:


While beautiful, these patterns didn't look as snowflake-like as we'd hoped. We realized that we needed to take inspiration from how real snowflakes are formed.

In reality, snowflakes don't just form randomly or all at once. Each snowflake begins with a tiny speck of dust, around which water molecules freeze to form tiny hexagonal flakes called “diamond dust.” As more water molecules attach themselves to the corners of that first initial speck, complex patterns gradually emerge.


With a bit of research, we found an algorithm that could more closely mimic this process. Instead of producing a whole snowflake in one go, we now do it gradually over the course of 48 cycles. Now, each snowflake starts with a single frozen cell. Whether any particular cell "freezes" is influenced by the number of its frozen neighbors. By making cells with fewer neighbors freeze more readily than those whose surroundings are already fully frozen, we found that we can produce patterns that look much more like the snowflakes we know and love.


When a cell freezes, it steals away some of the moisture in the air, leaving its surroundings less humid. Its adjacent cells will then be less likely to freeze themselves.

But is each snowflake really unique? Almost! By seeding each pattern with a unique number derived from the characters in a person’s name, we can produce as many snowflake designs as there are words in the world.

Left: Snowflake produced by randomly “freezing” cells. Right: snowflake produced using a series of probabilities.


And voila! A bit of digital artwork worthy of the nerdiest of Christmas cards.

What pattern can you create with our snowflake generator?

Subscribe to Our Newsletter