https://github.com/thomasahle/codenames
Codenames AI using Word Vectors
https://github.com/thomasahle/codenames
ai cli codenames game nlp word-embeddings word2vec
Last synced: 12 months ago
JSON representation
Codenames AI using Word Vectors
- Host: GitHub
- URL: https://github.com/thomasahle/codenames
- Owner: thomasahle
- License: gpl-3.0
- Created: 2018-02-28T14:39:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-12-07T07:59:49.000Z (over 2 years ago)
- Last Synced: 2025-03-20T01:06:27.489Z (12 months ago)
- Topics: ai, cli, codenames, game, nlp, word-embeddings, word2vec
- Language: JavaScript
- Homepage: https://codewords.app
- Size: 13.4 MB
- Stars: 48
- Watchers: 2
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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`.