You could generate equidistant hue values in the HSV space:
for (int i = 0; i < 10; i++) colors[i] = HSV(0.1 * i, 0.5, 1.0);
However, it’s possible that you will not always have 10 players. In that case, the palette would not be very efficient unless you re-generated a different palette for another number of players. Instead, some authors recommend generating a palette using the golden ratio, taking advantage of a property resulting from the equidistribution theorem:
for (int i = 0; i < 10; i++) colors[i] = HSV(fmod(i * 0.618033988749895, 1.0), 0.5, 1.0);
That way, even if you stop at 3 or 4 or 7 players, you get a very good hue spread.
Many irrational numbers will do, but the golden ratio will work best (it has been proven).
Finally, you can use two different generating sequences in order to tweak
V, too. For instance (edit: I added the
sqrt call for better equidistribution):
for (int i = 0; i < 10; i++) colors[i] = HSV(fmod(i * 0.618033988749895, 1.0), 0.5, sqrt(1.0 - fmod(i * 0.618033988749895, 0.5)));
Update: the above results can be improved by using a correction curve for
H (similar to the gamma curve for RGB components) that takes the human visual system into account. This is the hue correction curve that I computed using the CIEDE2000 metric:
The results for equidistant hue values are as follows:
And for the golden ratio generation sequences (with and without tweaks on
I will publish an approximation of the curve formula for use in programs as soon as I find a reasonably good one.
The 8 StarCraft colors are:
Red, Blue, Teal, Purple, Orange, Brown (green in desert maps), White (green on ice maps), Yellow
Obv. Blizzard are UI geniuses and have studied the problem.
They left Green out as a swap-in for Brown on desert maps, so technically there are 9 listed there.
The 12 Warcraft 3 colors are:
Red, Blue, Teal, Purple, Yellow, Orange, Green, Pink, Grey, Light Blue, Dark Green, Brown
Here’s how this looks:
As you can see, they are quite distinct and easily distinguishable. Dark green is actually easy to distinguish from teal, possibly because the human eye can most easily distinguish shades of green. If you’re sure your players will be female tetrachromats you probably could pick any colors though.
A few people here recommend dividing up HSV color space at 10 equidistant positions on hue. In my opinion, this is actually not a good solution. The human eye does not perceive differences in color equally across the HSV spectrum. For example, what we’d call orange occupies a tiny slice of the band, whereas a good 25% chunk might qualify as green. So it starts with a bad premise. Look at the first row of colors in this answer. The two greens are almost indistinguishable.
Remember your users will need to communicate about and refer to the colors. In light of this, the Starcraft/Warcraft theme is a great lead to follow. Choosing based on a list of plain English Crayola colors is not a bad idea at all, because you’ll end up with familiar named colors. Then just tweak those colors to be bold, muted, whatever matches your aesthetic, as long as they’re still recognizable as i.e. Red, Orange, Yellow, Green, Blue, Purple, Brown, Gray, White, Black.
Edit: the connection between language and color perception is so interesting, I just wanted to share this awesome link:
The crayola-fication of the world: How we gave colors names, and it messed with our brains on Empirical Zeal