A clean, fully client-side Wordle clone with a built-in information-theoretic AI assistant. No backend, no dependencies, just two files.
- Classic Wordle gameplay -- 6 attempts to guess a hidden 5-letter word
- AI Assistant -- powered by an information-theoretic solver that suggests the optimal next guess using candidate set partitioning
- Statistics panel -- tracks games played, win rate, streaks, best try, and guess distribution, persisted via
localStorage - Polished UI -- smooth flip/bounce/shake animations, colour-coded keyboard, toast notifications
- Invalid word handling -- unknown words are flagged and the row is flushed so you can retry without losing a turn
- Zero dependencies -- pure HTML, CSS, and vanilla JavaScript
- GitHub Pages ready -- deploy with one click, no build step required
├── index.html # The entire game (rename wordle.html to index.html for GitHub Pages)
└── words.txt # Word list, one 5-letter word per line
- Fork or clone this repository
- Rename
wordle.htmltoindex.html - Go to Settings > Pages, set source to
mainbranch, root folder - Your game will be live at
https://<username>.github.io/<repo-name>/
The game uses fetch() to load words.txt, so you need a local HTTP server. Opening the file directly via file:// will not work.
Python:
python -m http.server 8000
# Open http://localhost:8000/index.htmlNode.js:
npx serve .VS Code:
Install the Live Server extension, then right-click index.html and select Open with Live Server.
The AI button (top-right, blue) suggests the statistically optimal guess at any point in the game. The solver is a JavaScript port of ai_assistant.py.
Let
After submitting guess
For a given guess
where
Under a uniform prior over candidates, the probability of observing outcome
The expected size of the candidate set after one guess is:
Since
The solver selects the guess
The search is performed over the full vocabulary (not just remaining candidates), since a non-candidate word may partition the candidate set more efficiently.
To keep the UI responsive, the search runs in non-blocking 200-word chunks using setTimeout, approximating a Web Worker without requiring a separate thread.
| Action | Result |
|---|---|
| Click AI button | Computes and shows the optimal suggestion in a banner |
| Click Use it | Auto-types the suggested word into the current row |
| Click x | Dismisses the banner; next click recomputes for the new round |
| Submit a guess | Candidate set |
- Type a 5-letter word using your keyboard or the on-screen keys
- Press Enter to submit
- Tiles change colour to show how close your guess was:
| Colour | Meaning |
|---|---|
| 🟩 Green | Correct letter, correct position |
| 🟨 Yellow | Correct letter, wrong position |
| ⬜ Grey | Letter not in the word |
- Use the feedback to narrow down the answer within 6 tries
The stats panel (bar chart icon in the header) tracks:
- Games Played -- total games started
- Games Won -- total wins
- Win Rate -- percentage of games won
- Best Try -- fewest guesses used to win
- Current Streak -- consecutive wins
- Max Streak -- longest winning streak ever
- Guess Distribution -- bar chart of wins by guess number
Stats are saved in localStorage and persist across sessions. They are scoped to the origin, so GitHub Pages stats are independent of local server stats.
Replace words.txt with any plain text file containing one 5-letter word per line. Words with non-alphabetic characters or lengths other than 5 are filtered out automatically.
Update the filename constant at the top of the <script> block if needed:
const WORD_FILE = 'words.txt'; // change this to match your filenameconst MAX_GUESSES = 6; // number of allowed attempts
const WORD_LENGTH = 5; // letters per word
const FLIP_DELAY = 280; // ms between tile flip animationsWorks in all modern browsers (Chrome, Firefox, Safari, Edge). Requires JavaScript enabled. No installation, no accounts, no data sent anywhere.
MIT -- free to use, modify, and distribute.
