# Flag Design Algorithm

Learning how to program using Python opened up new methods of designing to me. I became interested in writing a process to design something, rather than just designing it, because of the possibilities this method offered.

To explore this idea in a simplistic form, I wrote a program that randomly generated a flag using Python and Matplotlib for the graphical output. It creates a 3×2 canvas of a random colour, then two lines with a random colour, thickness and direction are displayed on top of it.

The issue with that is, a lot of the time you then get plots that look like this, which obviously isn’t a great design. So a method was needed to filter out the bad flag designs. I needed to find a mathematical method of distinguishing them from each other.

Some of the best flag designs use the golden ratio spiral, so I thought it would make sense to make use of this also. So for each flag the program creates, the intersection of the lines into the coordinates of the golden ratio is outputted. So you can then pick out the better designs such as the ones below which have 8-9 intersections.

I tried to base this program around the 5 basic rules of flag design, these are:

1. Simplicity     –     The program only uses 3 features
2. Meaningful symbolism      –     The program only allows for symbolism retrospectively, it’s impossible to randomly generate symbolism
3. 2-3 colours     –     The program only allows for 3 colours to be used maximum
4. No lettering or seals     –     Nope
5. Distinctive     –     Definitely, as these designs are generated from a random process

My original idea was that once these flags were ordered in terms of their golden ratio intersections, they would mutate and be optimised leading to designs with more intersections using a survival of the fittest style evolutionary algorithm. But this did not totally make sense for this program as the solution is trivial (but I may try this with later projects).

The program also does not take into account the thickness and colour of lines in designs when they are assessed, and these are factors in what makes a good flag design. But defining these things could take away from this being a truly random process.

The highest number of intersections in a design that this program has outputted is 10, which is this design, which I think could pass for a genuine flag design.