Skip to content
Play Codenames with Word Vectors
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
codenames.py
convert.py
get_glove.sh
wordlist
wordlist2

README.md

Play Codenames with Glove

This repository implements a simple single-player version of the codenames game by Vlaada Chvátil. You can play as the agent or the spymaster, and the Glove word vectors will take the role of your partner, as you try to find the 8 marked words in as few rounds as possible.

$ git clone git@github.com:thomasahle/codenames.git
...

$ sh get_glove.sh
...

$ python3 codenames.py
...Loading vectors
...Loading words
...Making word to index dict
...Loading codenames
Ready!

Will you be agent or spymaster?: agent

     buck       bat   pumpkin    charge      iron
     well      boot     chick superhero     glove
   stream   germany      sock    dragon scientist
     duck     bugle    school       ham   mammoth
   bridge      fair  triangle   capital      horn

Thinking....................

Clue: "golden 6" (certainty 7.78, remaining words 8)

Your guess: bridge
Correct!

How it works

The bot decides what words go well together, by comparing their vectors in the GloVe trained on Wikipedia text. This means that words that often occour in the same articles and sentences are judged to be similar. In the example about, golden is of course similar to bridge by association with the Golden Gate Bridge. Other words that were found to be similar were 'dragon', 'triangle', 'duck', 'iron' and 'horn'.

However, in Codenames the task is not merely to find words that describe other words well. You also need to make sure that 'bad words' are as different as possible from your clue. To achieve this, the bot tries to find a word that maximizes the similarity gap between the marked words and the bad words.

If you want the bot to be more aggressive in its clues (choosing larger groups), try changing the agg = .5 value near the top of codenames.py to a larger value, such as .8 or 1.5.

You can’t perform that action at this time.