This project is a full-stack software system designed to algorithmically generate crossword puzzles and play them on a mobile device. It consists of a high-performance Python backend for generating grids and fitting words, and a native SwiftUI iOS frontend for rendering the puzzles into an interactive game.
The repository is divided into two distinct environments:
- Backend (Python): Handles all mathematical grid generation, template creation, and word-fitting logic. It utilizes Python's
ProcessPoolExecutorfor multi-core constraint backtracking, which is necessary to efficiently solve large 15x15 symmetrical grids. - Frontend (SwiftUI): A native iOS application that reads the compiled JSON puzzles generated by the backend and provides the user interface for gameplay.
The dictionary and clue database is built upon the albertxu/CrosswordQA dataset from Hugging Face, which contains over 6.7 million historical crossword clues and answers.
- The raw data is processed from
train.csv. - The cleaned and optimized data is stored locally in
words.db(SQLite) for rapid querying during the constraint satisfaction process.
- Python 3.8+
- SQLite3
- Navigate to the
Backenddirectory. - Generate Templates: Run the layout generators to create the initial empty grid structures. This outputs a
templates.jsonfile.python small_grid_generator.py # or for standard 15x15 grids python grid_generator.py - Build Database: If
words.dbis not present, compile it from the CSV source.python build_ru_db.py
- Generate Puzzles: Execute the main engine to fill the templates with words using the database.
The compiled, playable puzzles will be exported as individual
python generator.py
.jsonfiles to the output directory.
- macOS with Xcode 15+
- iOS 17.0+ Target
- Open
Frontend/Crossword.xcodeprojin Xcode. - Move the generated
.jsonpuzzle files from the Python backend into thegenerated_puzzlesfolder within the Xcode project structure. - Select an iOS Simulator or connected iOS device.
- Build and Run (
Cmd + R).
- Procedural Grid Generation: Supports asymmetrical small grids and standard 15x15 grids with rotational symmetry.
- Parallel Processing: The backend distributes the backtracking workload across CPU cores to reduce generation time.
- SwiftUI Integration: A modern, declarative UI parsing complex JSON game states into playable views.
- Filtering and Sorting: In-app capabilities to filter generated puzzles by size and symmetry type.