# Selecting easily distinguishable colors

I am writing a game and I need a choose a color for each player. The colors need to be easily distinguishable so that a human can identify the player by the color relatively easily. I need about 20 colors (the more, the better).

How do I approach this problem? Are there some rules that I can apply in order to make my choice of colors?

• It's generally accepted that color shouldn't be the only distinguishing factor. (Because people see colors differently, including those with color blindness.) So no matter what palette you choose, add something else: labels, shapes, something. – Ken Mohnkern Sep 14 '16 at 14:36
• @KenMohnkern I plan on adding flags (including player color and white/black pattern) and player names. – martinkunev Sep 14 '16 at 16:24
• There are great answers to the same question here: graphicdesign.stackexchange.com/questions/3682/… – Paul S Sep 15 '16 at 9:40

Agreed that you don't want to just use color to distinguish; this leaves your colorblind users open to problems. You need to consider luminance and contrast values between your colors, and more importantly include SHAPE as a distinguishing characteristic.

As for just considering colors to use, however, you might explore some of the many color palette generator tools out there to come up with a number of distinguishable but compatible colors:

https://coolors.co/

Depending of what language you use, if you can use HSL colors (Hue,Saturation,Lightness) then you could just distribute the colors around the color wheel for the number of players you have.

For example, for two players, you should have hsl(0, 100%, 50%) for the first player and hsl(180, 100%, 50%, 1) for the second player, for more players, just distribute the numbers evenly around the circle.

• I forgot to mention that I'll need about 20 colors. My first thought was doing it like that, but for that many colors I'm afraid they'll look too similar. – martinkunev Sep 14 '16 at 16:29
• @martinkunev Why would you need 20 colors? How many players would you have? Because I suppose you only need colors for the players,neutrals or npc groups. Resources, buildings or other places of importance should be defined by shape and have the color of their faction. – xpy Sep 15 '16 at 8:03
• I can have up to 16 players. – martinkunev Sep 15 '16 at 8:05
• And are there stable teams or you can form and destroy alliances during the game? – xpy Sep 15 '16 at 8:09
• Alliances can change during the course of the game. That's why I'll have a view mode that shows allies with one color and enemies with another. – martinkunev Sep 15 '16 at 9:00

Straight to the point - rainbow colours. Don't know if you ever played any NES games where players were red and blue and green, and yellow etc etc. Unless you will have more than 7 players.

I can't tell you more as I don't know how exactly are you going to apply the colour coding system. Will players' clothe be different? Will they have coloured squares floating over their heads? Is is 2d or 3D?

• I will probably have 16 colors and I'll need several more (a common ally color, a common enemy color, etc.). Units and buildings will carry a flag. – martinkunev Sep 14 '16 at 16:27