Codenames: Pictures is a fun little board game where you are given the task of communicating which of the cards below are “yours”, where each turn you can say one word and one number.
The goal is to find a strategy that maximizes the information conveyed by the word and number, ideally leading to the correct cards being chosen with minimal ambiguity.
However, we also have to account for the fact that half of the cards belong to the opposing team, and we want to avoid them being chosen. This adds a layer of complexity to our strategy.
We cannot simply discard using features that are shared with the opposing team, as this would severely limit our options. Instead, we need to find a balance between maximizing the information conveyed about our own cards while minimizing the risk of the opposing team being able to make a correct guess.
Information Theory is well suited to analyze this problem. We can use concepts like entropy and mutual information to quantify the amount of information conveyed by a given clue.
Formal Definition
We will be assuming using some image classification model to extract features from the images to form a probability distribution over the images.
Why a probability distribution? Because we want to be able to quantify the uncertainty associated with each image, and a probability distribution allows us to do that.
Say we have a set of features containing descriptors:
this set of features can be generated by a pre-trained image classification model
For each one of the cards in the game , a machine learning model will then give us a probability distribution over the features:
We then define a description/clue that can be a mix/subset of the features in . We will formalize it as a binary or weighted mask over the features:
This gives us a mechanism to evaluate the effectiveness of a clue in terms of how well it matches the features of the cards.
The clue defines a posterior over which cards it might refer to. Using Bayes:
and defining as:
This defines a “fit” for a clue to a card . E.g. “how likely is it that card would be generated by that description”.
Bringing information theory in now, we will evaluate how much a given clue reduces the uncertainty between cards being a “target” and an “enemy” ( as we don’t want to reveal the opponents cards for them ).
We define:
- set of our target cards
- set of the enemies cards
- all candidate cards
we will be disregarding the blank card for this experiment, as if it isnt working against us and is not a member of the set of our cards, its effect is trivial
We are seeking to find a clue that maximizes mutual information between and “is it a member of “.
We can start by defining a new discrete random variable such that:
Thus, the information gained from the clue is defined as:
Where:
- the entropy of our target vs not-target, e.g. baseline uncertainty
- the expected entropy after hearing our clue ( how much left over uncertainty )
will be high if the clue makes the targets much more probable than enemies.
Our Scoring Function
We now need a scoring function to evaluate how good a clue is at both maximizing information about our targets while minimizing the risk of enemies being chosen.
Expanding out our definition:
Where:
- defines the likelihood of clue pointing to card
- is 1 if , otherwise it is 0
Another much simpler scoring function can be achieved using the log-likelihood ratio:
Where is defined as:
and as:
Essentially, we are balancing how much more the given clue matches with targets vs enemies.
If , then the clue carries a net positive in information for targets, and the magnitude defines the strength of the clue.
Now, the key challenge is to balance our coverage maximizing algorithm with target-enemy ratio.
This gives us two important properties:
We can use this to assemble a final scoring function:
Where Coverage is defined as:
ensuring all targets are hit
and log-ratio is defined as the information gain against enemies.