Image recognition is a task that is difficult for computers to perform independently. Humans are perfectly capable of it, but are not necessarily willing to do this for large collections of images. By making the recognition task a "game", people are more likely to participate. This is where the ESP game1 comes in as a human-based computation game developed to address the problem of creating difficult metadata.

The idea behind the game is to use the computational power of humans to perform a task that computers cannot (originally, image recognition) by packaging the task as a game. It was originally conceived by Luis von Ahn of Carnegie Mellon University. Google bought a license to create its own version of the game (Google Image Labeler2) in 2006 in order to return better search results for its online images. Don't try to look for it anymore: Google's version was shut down on September 16, 2011 as part of the Google Labs closure in September 2011.

ESP game
The ESP game is a human-based computation game developed to address the problem of creating difficult metadata. The idea behind the game is to use the computational power of humans to perform a task that computers cannot (originally, image recognition) by packaging the task as a game.

Once logged in to the ESP game, a user is automatically matched with a random partner. The partners do not know each other's identity and they cannot communicate. Once matched, they will both be shown the same image. Their task is to agree on a word that would be an appropriate label for the image. They both enter possible words, and once a word is entered by both partners (not necessarily at the same time), that word is agreed upon, and that word becomes a label for the image. Once they agree on a word, they are shown another image. As such, they have two and a half minutes to label 15 images.

Both partners have the option to pass. That is, give up on an image. Once one partner passes, the other partner is shown a message that their partner wishes to pass. Both partners must pass for a new image to be shown.

Some images have taboo words. That is, words that cannot be entered as possible labels. These words are usually related to the image and make the game harder as they prevent common words to be used to label the image. Taboo words are obtained from the game itself. The first time an image is used in the game, it will have no taboo words. If the image is ever used again, it will have one taboo word: the word that resulted from the previous agreement. The next time the image is used, it will have two taboo words, and so on. Taboo words is done automatically by the system: once an image has been labeled enough times with the same word, that word becomes taboo so that the image will get a variety of different words as labels.

Occasionally, the game will be played solo, without a human partner, with the ESP game itself acting as the opponent and delivering a series of predetermined labels to the single human player (which have been harvested from labels given to the image during the course of earlier games played by real humans). This is necessary if there are an odd number of people playing the game.

In late 2008, the game was re-branded as GWAP (game with a purpose), with a new user interface. Some other games that were also created by Luis von Ahn, such as Peekaboom3 and Phetch4, were discontinued at that point.

Assignment

Based on previous game play, the ESP game has already collected some taboo words that can be associated with a particular image. Your task is to make a random selection of these words that will be shown to a new pair of players. This is done in the following way:

Tip

Try to make use of the functions in the random5 module when implementing the above functions. As such, you don't have to reinvent the wheel.

Example

>>> words = ['forest', 'meadow', 'scenery', 'hills']
>>> taboo_length(words)
3
>>> taboo_length(words, minimum=2)
4
>>> taboo_length(words, maximum=3)
1
>>> taboo_length(words, minimum=2, maximum=3)
3
>>> taboo_length(words, minimum=-2, maximum=6)
1

>>> taboo_words(words)
['forest', 'hills', 'meadow', 'scenery']
>>> taboo_words(words, minimum=2)
['forest', 'meadow', 'scenery']
>>> taboo_words(words, maximum=3)
['forest', 'hills', 'meadow']
>>> taboo_words(words, minimum=2, maximum=3)
['hills', 'meadow', 'scenery']
>>> taboo_words(words, minimum=-2, maximum=6)
['forest', 'hills', 'meadow', 'scenery']