I became curious about creating a suggestion engine while the playing the game Codenames (published by Czech Games). There are two main 'modes' in the game, and both proposed interesting problems to break down: the players, and the spymaster. The players get to see the 5x5 grid of agent codenames, while the two spymasters are the only people who see the grid showing which codenames correspond to red and blue agents, innocent bystanders, and the assassin.

When playing this game in person, I usually tailor my clues or guesses based on my knowledge of three main areas: associated words, news and world events, and personal experiences.  The easiest area to program for is associated words, as it relies mostly on definitions and thus does not change based on the people playing. 

                                    Agent Codenames

                                    Agent Codenames

                                  Agent Allegiances

                                  Agent Allegiances



The role of the spymaster is to come up with a single word clue for any number of their own team's agents. What interested me about this role is the process of finding relationships between words that are often random.


The basic approach I used to solve the problem of generating a single-word clue from a set of codenames was to use the Word Associations Network. This method finds common associations between each codename in the set, removes any words that were also on the game grid, and suggests the top remaining word as the clue. 



The role of the player is to use the given clue and number of agents to pick codenames from the grid. What interested me about this role was finding a way to model the relate-ability of words to a single clue. 


For the player mode, I had more flexibility with the number of responses, so I was able to essentially reverse-engineer the spymaster logic, with the exception of returning a list of suggestions as opposed to filtering out the topmost one. I used the Word Associations Network again, but this time just on the clue word, and returned any associations that appeared in the game matrix, limiting the list to the number of agents given by the spymaster. 



With the current implementation, there were some obvious shortcomings. The biggest issue was that I only used one query for finding word associations, when a better system would likely look at multiple iterations as the game often relies on using a less obvious meaning of a word. This would increase the chances of finding ways to relate difficult sets. Additionally, multi-word codenames (i.e. ice cream) were generally not picked up due to the Word Associations Network not using these consistently. 

There are two main areas I plan to improve on next. Firstly, I will be adding support for using news and world events to add to the generation of clues or codename guesses. And secondly, including a more automated system for tracking the game progress.