Optimal strategy for Codenames
This post will assume you are familiar with the game Codenames.
What is the optimal strategy for Codenames? In a three minute search I cannot find anyone who has written on this topic with the rigor I am about to. I will begin with the most theoretically and optimized strategy, and narrow to the most practical.
SUPER GENIUS AI LEVEL STRATEGY
Let’s say you are the spymaster going first. Ideally, you will give a clue that tells your team exactly which 9 words to guess out of the 25 and you can win instantly. Is this possible in only one clue? It absolutely is. Number the cards 1-25. We are going to make a 25 digit number that encodes whether each card is your color or not. Each card is assigned a 1 if it is your color, and a 0 if it is not. Thus, a clue 1001100000010100101100001 would mean you should guess the card in the first position, the fourth position, the fifth position, etc.
Now, this clue violates two rules. First, the clue must be only one word, and long numbers are probably considered many words. Second, you are not allowed to clue based on the physical placement of cards.
A similar but much more practical strategy is to catalogue all the answer sheets (the mini map cards showing the answers) in the game and have an arbitrary clueword that corresponds to each. This is very doable, since there are only 40 answer sheets, but should run afoul of the rule against spatial clues.
Is it possible to do something similar within the rules? It is. Before the game, we can list every possible set of nine words and choose a one word clue that would correspond to that set. For example, we could say the unordered set [cold, death, diamond, dog, dress, France, fire, glove, gold] corresponds to the arbitrarily chosen clue word tree. If everyone has previously agreed on a mapping of every set of nine words to a unique clue word, all the spymaster needs to do is figure out which nine are their spies, find the corresponding clue word, and say it, and then the guessers can look up what nine words correspond to that clue word. Instant win.
However, this creates a lot of possibilities. There are 200 double faced cards. To simplify the math, let’s consider this as 399 distinct cards (since a card and its backside can’t both be present in the same grid). To encode all possible sets of nine, we need to do 399 choose 9. This is 6.45 x 10^17. That’s more than 600,000,000,000,000,000, or six hundred quadrillion.
The Collins Scrabble dictionary has just under 180,000 words. If we add in slang and proper nouns in English, we get up to around 2 million words, according to ChatGPT. If we add in all words in all languages, including slang and proper nouns, ChatGPT estimates there are up to around 100 million words. I’m not sure if you are allowed to use words in other languages in Code Names, but even if you are, we would still need at least a million times more words than exist throughout all of Earth in order to encode all possible sets of nine words. So this option is probably out. However, there are enough words in the world to allow for a similar strategy that only clues three cards at a time. This strategy would allow a team to win in three turns, since there are nine words per game.
But we want to get it in one turn. Is there a way to do it more efficiently than 399 choose 9? There certainly is, because we have many more bits of information at our disposal. We have the context of the board. Thus, we only need to map to every possible combination of 9 for the current board state. That’s 25 choose 9. It doesn’t matter if we reuse cluewords across multiple possible boards, since guessers will know to use the mappings for this exact board. 25 choose 9 is just over 2 million, certainly within the amount of possible words. You still need to do 399 choose 9 mappings, but we can reuse cluewords a lot, limiting the amount of words needed to easily within the amount in our lexicon.
Of course, there is another pesky rule that clues must relate to the meanings of words. Tenuously, you could get around these words by assigning the two million mappings per possible board in a way that preserves maximal semantic correlation. This is your best bet to guarantee a turn one win within the rules.
GENIUS LEVEL STRATEGY
Let’s say you are a smart human and you are spymaster. Your team has five words left to guess, and your opponent has three words. You have miraculously found a clue that will certainly allow your team to guess four of your words without errors. You have three options available to you:
Clue the four words now, and pick up the last word next turn
Clue the one word now, and pick up the four words next turn
Clue all five remaining words right now. (Say your word for the four, but say 5 as your number, and your team will – let’s presume – know to guess the four words and then guess randomly on the last one).
Which option should you choose? The answer is, it depends on whether your opponent is likely to win on their next turn. If your opponent is certain to win on their next turn, you should choose option 3, since it’s your only shot of winning. This is also going to be true if your opponent is 99% likely to win on their next turn. But if their probability of winning is low enough, option 3 becomes no longer optimal, because the last guess is much more likely to help your opponent than it is to help you. If there are two neutral cards remaining, that final guess has a 1/7 chance of winning for you, a 3/7 chance of getting an opponent’s card for them, a 1/7 chance of hitting the black card and losing immediately, and a 2/7 chance of getting a neutral card and helping your opponent by a small amount by eliminating it as a distraction. So you look at your opponent’s three remaining cards, and decide how likely the enemy team is to successfully clue all three, and only if that is very high do you go for the hail mary.
If you discard option 3, how are you to decide between options 1 and 2? Both options reliably win in two turns. In the vast majority of cases, option 2 is better. This is because it makes your opponent’s next turn more difficult. There will be more cards remaining on the board, making it harder for your opponents to clue and guess, since they have to avoid accidentally cluing your cards. Thus, you should clue a single word now, hope your opponent is unable to win on the still complex board next turn, and scoop up the final four cards for a dramatic finish.
This principle applies throughout the entire game, not just on the final turns. If you get all your easy sets of several tiles early in the game, you simplify the game for your opponents. Does this mean you should plan out all of your clues, and give clues for groups of one and two words early, working up to clues of larger groups at the end? Perhaps, but not necessarily. While this does make it harder for your opponents to clue, there are several factors weighing on the other side.
Practically, it’s hard to plan out so far, especially if you are playing with a timer
While leaving a more complex board does make things harder for your opponent, it also means that if they accidentally choose one of your words, it will not be as useful to you, since you would have swept up that word in a large clue anyway. This suggests it may be better to leave single word clues for the end, in the hopes that your opponent (or your team) accidentally chooses them.
When there are more words on the board, it also makes your team more likely to choose the wrong words. This should be fine, since those would still be your color, but it could cause your team to get confused about what clues pointed to which words, making your progress less efficient.
The game is pretty high variance, and so you want to give clues for large groups early, so that if your team misses some of the words, they can pick them up in future clues.
Sometimes, it is beneficial to clue large numbers early, with the idea that your team will be only confident enough to pick up some of those on the first round, but those clues can combine with other large clues to multi-clue certain words for later rounds.
Thus, you should probably clue larger sets of words early; however, if you have a large set that you feel very confident about, it makes sense to leave it for the end.
I’ve seen a lot of games where one team cleans up some words for their side, and that opens the way for the other team to give really good clues that were not previously possible. Ideally, you would anticipate what the board state would be after your potential clues, and see if it gives your opponents new options. You would do this recursively for every possible set of clues until you have all branches of the game tree mapped out. Practically speaking, of course, this is humanly impossible, and probably very hard to do even a little bit except at the end of the game. But the principle remains: if you don’t have to, don’t make things easier for your opponent.
ACTUALLY PRACTICAL STRATEGY
This principle manifests in an important and relatively easily implementable way. As a guesser, say your spymaster clued three words, and you are certain about two of them and have a decent guess but some uncertainty about the third. Should you guess the third, or should you hold off?
The right answer is usually to hold off. This is because you can always pick it up next round as your extra guess, and if you are wrong, it makes the board more complex for your opponents. There is a reasonable chance that your opponents wind up cluing or guessing that word.
Since there is so much variance – that is, people make mistakes cluing, and guessers aren’t always on the same page as spymasters even when clues make sense – it’s best to play somewhat conservatively. Don’t risk cluing the black card or cards that your opponents have. It’s okay to only clue two at a time if there aren’t any good clues for three.
There is one final strategy to discuss, and this is probably the most important to actually implement when playing: theory of mind within your team. For the spymaster, this is pretty straightforward: when you come up with a potential clue connecting your words, imagine you are a guesser receiving that clue. What words might you choose? Basically spymasters need to consider all the words, not just their own color. Most people do this.
For guessers, theory of mind is really important and often neglected. Before guessing any words, find your candidate words, and consider: if you were the spymaster, what word would you use to clue this group?
Let’s look at an example. Say your spymaster has clued horn 2 and there are the words [unicorn, dragon, band] that are in contention. You are very confident about unicorn, and you are unsure if dragons typically have horns, but seem to recall the spymaster reading a book with a horned dragon on the cover. Horns are also an instrument in some bands, but in a vacuum, you think it far more likely that your spymaster would associate horn with dragon than with band.
But you are not in a vacuum. Your initial theory is that the correct words are unicorn and dragon. Now you ask: if you were spymaster, how would you clue these words? And obviously, you would say creature or mythical or magical or something like that (assuming there’s not some other mythical creature, which you should check for). Not horn. So the correct answer cannot be unicorn and dragon. Thus, it must be unicorn and band.
Of course this sort of reasoning can also lead you astray. Sometimes spymasters clue things in weird ways, sometimes they fail to notice distractors, sometimes they just have different associations than you. But this kind of reasoning should be considered every single guess.
CONCLUSION
Most of this is for fun rather than practical, but fun is kinda the whole point of the game, so there.


Nice, I like the strategy! I wanted to chime in with a strategy that I tried in my family's correspondence codenames (played to give us time to think through all the alternate words the clue giver may have given).
The 0 clue.
Let's say you have two very powerful clues, which would clue 4 and 5 words each. But avast! There are some clues for the other color that they would also clue. Fortunately, you've looked at all the words that you would also clue, and you see a clue that would connect those words. You can now clue that word with a 0, and on further clues you can give your 4 and 5 words. This has the advantage of being more efficient, and also delaying giving information to the other team. They can't safely pick clues that relate to your 0 clue, because you may have excluded the death word.
Admittedly, this is tricky to coordinate and I lost the game I tried it in. Also, guessers still must guess at least one word, so they now have to blind fire the first guess.
This interaction is also useful in your given example, and is more likely to be practical there. Having clued horn, your team can hopefully determine that Dragon is not a viable word (otherwise you'd have given 3 as the number). As such, they can exclude it from further guesses, even if you give a clue that looks like it should include Dragon (wing perhaps). Of course, this is risky in that they might never guess a real clue now; but when it works it should be able to give you more options.
Love this codenames strategy analysis. I didn’t finish it yet (cuz bedtime) but I can see already a lot I hadn’t thought of before. Nice!