Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anagrams Bot

A Python bot that screenshots a 6-letter word game, OCRs the tiles, finds every valid word using the system dictionary, then auto-clicks through all of them as fast as possible within 60 seconds.

Demo


Requirements

  • macOS
  • Python 3.10+
  • Tesseract OCR

Install Tesseract:

brew install tesseract

Install Python dependencies:

python3 -m pip install pyautogui pillow pytesseract --break-system-packages

Usage

python3 anagrams.py

After running, you have 3 seconds to switch to the game window. The bot will take a screenshot, read the tiles, solve all possible words, and begin clicking. It stops automatically after 60 seconds.

To stop early, move your mouse to the top-left corner of the screen.


How It Works

  1. Display scaling - Detects Retina display scale factor by comparing PyAutoGUI's logical screen size to the physical screenshot size. All crop coordinates are adjusted accordingly.

  2. OCR - Takes a single screenshot at startup and crops each of the 6 tile regions. Each crop is upscaled 8x, converted to grayscale, contrast-enhanced, sharpened, and binarized to pure black and white before being passed to Tesseract. OCR runs once and is not repeated.

  3. Solver - Generates every permutation of every subset (3 to 6 letters) of the detected letters and checks each against the macOS system dictionary at /usr/share/dict/words. Results are sorted longest-first to maximize score.

  4. Clicker - Uses PyAutoGUI to click each letter tile in order, then clicks the on-screen Enter button. Hardcoded coordinates match the tile positions on the mirrored iPhone display.

  5. Timer - The entire play session is capped at 60 seconds. The bot checks the time before each word and stops cleanly when the limit is reached.


Debug Output

If OCR fails on any tile, the bot saves two images to the project folder and opens them automatically:

  • debug_screen_<timestamp>.png - Full annotated screenshot with each crop box drawn. Red boxes indicate failed tiles, green indicates success.
  • debug_tiles_<timestamp>.png - Contact sheet showing the raw crop and preprocessed version of each tile side by side, with the detected letter labeled below.

Configuration

The following constants at the top of anagrams.py can be adjusted:

Constant Default Description
LETTER_COORDS see script Logical (x, y) click coordinates for each tile
ENTER_COORD see script Logical (x, y) coordinate for the Enter button
LETTER_DELAY 0.01s Delay between each letter click
ENTER_DELAY 0.01s Delay before clicking Enter
WORD_DELAY 0.10s Delay between words
TILE_RADIUS 24px Half-width of each tile crop box in logical pixels
RUN_DURATION 60s How long the bot plays before shutting down

About

A Python bot that screenshots Anagrams, OCRs the tiles, finds every valid word using the system dictionary, then auto-clicks through all of them as fast as possible within 60 seconds.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages