Skip to main content

lettergame

Play a word-guessing game!

Rules

  • The computer chooses an N-letter word from a dictionary file.
    • The word has no repeated letters.
  • Each round, you guess a word following those same rules.
    • The computer tells you how many letters of your guess are also in the correct word.
    • It ignores the position of the letters, i.e. NOTES and STONE will have the same result.
  • When you guess the correct word, you win!
  • You should only be guessing real words, so it isn't too easy.

An example:

The computer secretly chooses the word 'EARTH'.
You guess 'GIRTH' -- 3 letters are correct (R, T, H).
You guess 'BIRTH' -- 3 letters are correct (R, T, H).
It is now probable that GI and BI are both incorrect (but not definite!).
To be sure, you guess 'BINGO' -- 0 letters are correct, so you know it must be R, T, and H.
You guess 'HEART' -- 5 letters are correct, but the order is not.
You guess 'EARTH' -- you win.

Installation

Using a virtual environment

# Create and activate virtual environment
python -m venv venv
source venv/bin/activate
# Install pip package
pip install lettergame

Note that the virtual environment must be active when using the command.

Using pipx

# Install pipx
pip install pipx
# Install pip package globally using pipx
pipx install lettergame

Using a manual link

# Clone this repository
git clone https://github.com/xorwow/lettergame
# Link to the game file from your BIN
ln -s lettergame/game.py ~/.local/bin/lettergame

Usage

First, install a dictionary file (see below). Then, start a game by running lettergame in your terminal (must have color support).

Dictionary file

To play the game, a dictionary file is required. It contains the words the computer can choose from. It is recommended to use non-plural nouns. You can find lists of common nouns online.

The game expects one word per line. The words can be any length. On start, the game loads all words that:

  • Don't have any repeating characters.
  • Fit the target word length.
  • Only contain A-Z/a-z.

By default, the game look for this file in ~/.config/lettergame/words.txt.

Options

The following flags are available:

  • --word-length|-n <number> specifies the target word size.
  • --dict-file|-f <path> specifies a custom path to the dictionary file.
  • --load-hash|-l <hash> forces the game to choose the target word of a previous game.
    • The shortened hash of the chosen word is shown at the beginning of the game.
    • This can be used to continue an interrupted game (although previous guesses are not loaded).
  • --difficult|-d disables automatic marking of letters based on obvious clues (see below).

Marking letters

The game shows you the alphabet and a list of previous guesses at the beginning of each round, with letters colored green, yellow, or red to keep track of which letters you have already ruled out or assume to be correct. Green means correct, red means incorrect, and yellow means unknown. This is meant as a memory aid, and will not influence the game's logic.

You can mark letters as correct/incorrect/unknown by entering +<letters>, -<letters>, or ~<letters> in the guess prompt. For example, enter +abc to mark a, b, and c as correct. They will be shown in green in the alphabet and the list of previous guesses.

If --difficult mode is not enabled, the game will also automatically mark letters in some obvious cases for convenience:

  • If a guess has no matches, all of its letters are marked as incorrect.
  • If the number of matches is equal to the amount of letters in the guess which aren't already marked as incorrect, all other letters are marked as correct (ex.: CASE matches 3 letters and C is marked as incorrect -> A, S, and E must be correct).
  • If the number of matches is equal to the amount of letters in the guess which are already marked as correct, all other letters are marked as incorrect.
  • If all correct letters have been guessed, all other letters are marked as incorrect.

Note that falsely marking a letter as (in)correct may create additional false marks based on that assumption.

Cheating

If you give up but still want to know the correct word, enter _reveal in the guess prompt.

Metadata

Release files for lettergame 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lettergame 1.0.0
File Size Uploaded
lettergame-1.0.0.tar.gz 6.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lettergame 1.0.0
File Interpreter ABI Platform
lettergame-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / lettergame-1.0.0.tar.gz

Download URL lettergame-1.0.0.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
03bec1eb2d4a90723d12ce4312e22ad0cbdcdf875ae4ac76ef245deb3e6b13b0
BLAKE2b-256 checksum
How to use checksums
f0d93fa13bceeefc9c5900e7e96d8896914bed26cd47ab695ba56a7e622681a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / lettergame-1.0.0-py3-none-any.whl

Download URL lettergame-1.0.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f2e76be2311113ee0c47b17cde184353d5a98e535ec0708459453dc25f84358
BLAKE2b-256 checksum
How to use checksums
57716780b917dcf7cb0afe912840d506636efef600f8a476eb3f05445d496acc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page