If you have spent any time doing missions in Elite Dangerous
you've probably met dozens or even hundreds of the game's many factions and it's hard to tell them apart.
It's nice how the contacts for these factions have human faces, but I wanted to go a step further. What if each faction had its own flag?
Inspired by the algorithms Elite uses to generate an almost infinite galaxy, I came up with a way to generate a unique flag from the name of a faction.
Each faction gets three colors derived directly from the name. To make it more informative, I added 11 design variations to indicate the government type
and a watermark to indicate the allegiance.
First, the name is sanitized and treated as a number in base 36 (10 numerals plus 26 letters).
Then this number is divided by the number of possible colors and the remainder is used to select Color #1.
The process is repeated with the result to get Color #2 and Color #3.
Here are some examples:
Here are all of the possible colors:
Try it out here, in real time! The flag will be generated as you type.
Some notes on randomness.
The colors may look totally random, but they actually repeat very quickly. Notice that "x" and "1py" have the same colors.
With 3 colors chosen from 13 possibilities there are only 13*13*13 = 2,197 total combinations.
The Elite Dangerous Wiki lists 39,074 minor factions At least, it did when I first wrote this. so each flag should be re-used at least 17 times on average.
In reality though, it's probably skewed far from this average. The faction names are not randomly distributed and most combinations don't occur.
For instance, there's no faction called "XXXXX". That said, I have yet to come across two factions with the same colors, let alone the same colors and the same government type and the same allegiance!
However, there is a way around this. Instead of turning the faction name into a hash, why not just use it to seed a random number generator?
JavaScript doesn't support seeded random number generation and the math was a bit over my head, so I found a third-party implementation.
The Pseudorandom Mode checkbox toggles it on and off.
You'll notice that the results are very different. Incrementing the name no longer ascends through the colors.
There is now no guarantee that sequential names yield different results.
We are relying on the large number of possibilities to avoid collisions.
But the results are still consistent within Pseudorandom Mode. The same name will always yield the same result.
This is how most procedural generation works in games like Elite.