MCPcopy Index your code
hub / github.com/SuveenE/codenames-ai

github.com/SuveenE/codenames-ai @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
60 symbols 145 edges 24 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GitHub stars License Twitter Follow

Codenames AI

I got OpenAI o1 to play Codenames and it's super good.

You can get AI to play your own games at codenames.suveenellawela.com

Here's a short blog post I published with my findings (7000+ views). And the blog post got featured on Hacker News ranking #7 at its peak. There were a lot of interesting comments, have a look here.

New to Codenames? Here's a 3-minute video explaining how it works.

Screenshot 2025-01-01 at 20 40 27

Features

  • See AI play a game with random words
  • See AI play a game with a custom set of words and a custom board (If you just finished playing a game, see how AI would have played it)
  • Replay previous games ( Currently this is suppored only for a test game )
  • Add your own API key to use OpenAI models

Custom Game input: Screenshot 2025-01-01 at 20 40 27

The story behind

During our lunch breaks, my colleagues and I have been enjoying games of Codenames. In one round, the clue giver faced the challenge of connecting "carrot" and "ray." At the end of the game, I asked ChatGPT for a suggestion, and it came up with "Orange", a pretty clever clue! My own idea was "Laser."

That got me thinking: how good could AI be at playing Codenames? So, I built this.

Getting Started

First, run the development server:

npm install
npm run dev

Open http://localhost:3000 with your browser to see the result.

Links

Extension points exported contracts — how you extend this code

Card (Interface)
(no doc)
types/game.ts
ApiKeyDialogProps (Interface)
(no doc)
components/ApiKeyDialog.tsx
GameHistoryProps (Interface)
(no doc)
components/GameHistory.tsx
CustomGameDialogProps (Interface)
(no doc)
components/CustomGameDialog.tsx
SpymasterViewProps (Interface)
(no doc)
components/SpymasterView.tsx
GameBoardProps (Interface)
(no doc)
components/GameBoard.tsx
ButtonProps (Interface)
(no doc)
components/ui/button.tsx
GameTurn (Interface)
(no doc)
types/game.ts

Core symbols most depended-on inside this repo

cn
called by 13
lib/utils.ts
delay
called by 10
utils/gameUtils.ts
getStoredApiKey
called by 4
utils/encryption.ts
generateInitialGameState
called by 4
utils/gameUtils.ts
generateCardTypes
called by 3
utils/gameUtils.ts
moveToNextWord
called by 2
components/CustomGameDialog.tsx
generatePrompt
called by 2
utils/prompts.ts
shuffleArray
called by 2
utils/gameUtils.ts

Shape

Function 50
Interface 10

Languages

TypeScript100%

Modules by API surface

app/page.tsx10 symbols
components/CustomGameDialog.tsx9 symbols
utils/gameUtils.ts6 symbols
utils/encryption.ts5 symbols
types/game.ts4 symbols
components/GameBoard.tsx4 symbols
components/ApiKeyDialog.tsx4 symbols
utils/prompts.ts3 symbols
components/SpymasterView.tsx3 symbols
components/ui/dialog.tsx2 symbols
components/GameHistory.tsx2 symbols
app/api/o1/route.ts2 symbols

For agents

$ claude mcp add codenames-ai \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact