Allgemein

How good can you be at Codenames without knowing any words?

How good can you be at Codenames without knowing any words?

About eight years ago, I was playing a game of Codenames where the game state was such that our team would almost certainly lose if we didn’t correctly guess all of our remaining words on our turn. From the given clue, we were unable to do this. Although the game is meant to be a word guessing game based on word clues, a teammate suggested that, based on the physical layout of the words that had been selected, most of the possibilities we were considering would result in patterns that were “too weird” and that we should pick the final word based on the location. This worked and we won.

[Click to expand explanation of Codenames if you’re not familiar with the game]

Codenames is played in two teams. The game has a 5×5 grid of words, where each word is secretly owned by one of {blue team, red team, neutral, assassin}. Each team has a “spymaster” who knows the secret word <-> ownership mapping. The spymaster’s job is to give single-word clues that allow their teammates to guess which words belong to their team without accidentally guessing words of the opposing team or the assassin. On each turn, the spymaster gives a clue and their teammates guess which words are associated with the clue. The game continues until one team’s words have all been guessed or the assassin’s word is guessed (immediate loss). There are some details that are omitted here for simplicity, but for the purposes of this post, this explanation should be close enough. If you want more of an explanation, you can try this video, or the official rules

Ever since then, I’ve wondered how good someone would be if all they did was memorize all 40 setup cards that come with the game. To simulate this, we’ll build a bot that plays using only position information would be (you might also call this an AI, but since we’ll discuss using an LLM/AI to write this bot, we’ll use the term bot to refer to the automated codenames playing agent to make it easy to disambiguate).

At the time, after the winning guess, we looked through the configuration cards to see if our teammate’s idea of guessing based on shape was correct, and it was — they correctly determined the highest probability guess based on the possible physical configurations. Each card layout defines which words are your team’s and which words belong to the other team and, presumably to limit the cost, the game only comes with 40 cards (160 configurations under rotation). Our teammate hadn’t memorized the cards (which would’ve narrowed things down to only one possible configuration), but they’d played enough games to develop an intuition about what patterns/clusters might be common and uncommon, enabling them to come up with this side-channel attack against the game. For example, after playing enough games, you might realize that there’s no card where a team has 5 words in a row or column, or that only the start player color ever has 4 in a row, and if this happens on an edge and it’s blue, the 5th word must belong to the red team, or that there’s no configuration with six connected blue words (and there is one with red, one with 2 in a row centered next to 4 in a row). Even if you don’t consciously use this information, you’ll probably develop a subconscious aversion to certain patterns that feel “too weird”.

Coming back to the idea of building a bot that simulates someone who’s spent a few days memorizing the 40 cards, below, there’s a simple bot you can play against that simulates a team of such players. Normally, when playing, you’d provide clues and the team would guess words. But, in order to provide the largest possible advantage to you, the human, we’ll give you the unrealistically large advantage of assuming that you can, on demand, generate a clue that will get your team to select the exact squares that you’d like, which is simulated by letting you click on any tile that you’d like to have your team guess that tile.

By default, you also get three guesses a turn, which would put you well above 99%-ile among Codenames players I’ve seen. While good players can often get three or more correct moves a turn, averaging three correct moves and zero incorrect moves a turn would be unusually good in most groups. You can toggle the display of remaining matching boards on, but if you want to simulate what it’s like to be a human player who hasn’t memorized every board, you might want to try playing a few games with the display off.

If, at any point, you finish a turn and it’s the bot’s turn and there’s only one matching board possible, the bot correctly guesses every one of its words and wins. The bot would be much stronger if it ever guessed words before it can guess them all, either naively or to strategically reduce the search space, or if it even had a simple heuristic where it would randomly guess among the possible boards if it could deduce that you’d win on your next turn, but even when using the most naive “board memorization” bot possible has been able to beat every Codenames player who I handed this to in most games where they didn’t toggle the remaining matching boards on and use the same knowledge the bot has access to.

JS for the Codenames bot failed to load!