ai-nonogram-puzzle-solver
π§ AI-powered Nonogram Solver using Simulated Annealing π§© Solve logic grid puzzles intelligently with Python + Turtle π’β¨
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
βCITATION.cff file
Found CITATION.cff file -
βcodemeta.json file
Found codemeta.json file -
β.zenodo.json file
Found .zenodo.json file -
βDOI references
-
βAcademic publication links
-
βAcademic email domains
-
βInstitutional organization owner
-
βJOSS paper metadata
-
βScientific vocabulary similarity
Low similarity (14.8%) to scientific vocabulary
Repository
π§ AI-powered Nonogram Solver using Simulated Annealing π§© Solve logic grid puzzles intelligently with Python + Turtle π’β¨
Basic Info
- Host: GitHub
- Owner: akamohid
- License: mit
- Language: Python
- Default Branch: main
- Size: 9.77 MB
Statistics
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
π What Is a Nonogram?
A Nonogram (aka Picross or Paint-by-Numbers) is a logic-based puzzle where players fill or leave cells blank based on number clues for each row and column. A correct solution reveals a hidden image.
Each number represents a group of filled cells. For example, [2, 1] means "2 filled cells, then space(s), then 1 filled cell".
π₯ About This Project
This project uses the Simulated Annealing algorithm to solve Nonogram puzzles automatically:
- Start with a random filled grid.
- Evaluate how well it satisfies the puzzle constraints (fitness).
- Iteratively tweak the grid and improve it using simulated annealing's probabilistic approach.
- Continue until all row and column constraints are satisfied.
Includes: - π§ Constraint validation - π Random restarts to ensure convergence - πΌ Visualized output using Turtle graphics - π§ͺ Tests for fitness and logic
π₯ Key Features
- Custom Clues: Easily edit row/column constraints for any puzzle size.
- Random Restarts: Robustly solves even hard puzzles by trying again.
- Flexible Grid: Supports NΓM puzzles of arbitrary shape.
- Adjustable Cooling: Tweak starting temperature, cooling rate, and iterations.
- Unit Tested: Ensures core fitness and state-flip logic are correct.
- Documentation: Includes research paper, detailed report, and presentation slides.
π Repository Structure
AI-NONOGRAM-PUZZLE-SOLVER/
βββ assets/ β Project visual assets
β βββ outputs/ β Turtle output screenshots
β βββ Sample-output-1.png
β βββ Sample-output-2.png
β βββ Sample-output-3.png
β βββ Sample-output-4.png
β βββ Sample-output-5.png
β βββ Sample-output-6.png
βββ docs/ β Research paper (PDF)
β βββ research_paper.pdf
βββ presentation/ β Slides (PPTX)
β βββ slides.pptx
βββ reports/ β Written report (DOCX)
β βββ report.docx
βββ src/ β Solver source code
β βββ nonogram_solver.py
βββ tests/ β Unit tests
β βββ test_solver.py
βββ .gitignore β Files to ignore in Git
βββ LICENSE β MIT License text
βββ CITATION.cff β Citation metadata
βββ requirements.txt β Python dependencies (standard library only)
βββ README.md β This guide
π Installation & Setup
Clone the repository
bash git clone https://github.com/akamohid/AI-NONOGRAM-PUZZLE-SOLVER.git cd AI-NONOGRAM-PUZZLE-SOLVER(Optional) Create a virtual environment
bash python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # WindowsInstall (none!)
This project uses only the Python standard libraryβno external dependencies.
βΆοΈ Running the Solver
- Open
src/nonogram_solver.pyin your editor. - Locate the β### EDIT BELOW FOR CUSTOM PUZZLE ###β section:
python row_constraints = [ [3], [1,1], [2], β¦ # example ] col_constraints = [ [1], [4], [1,1], β¦ ] - Replace these lists with your own puzzleβs row and column clues.
- Run:
bash python src/nonogram_solver.py - Watch terminal logs for fitness progress, then see the final grid drawn in a Turtle window.
π§ͺ Testing
Validate core logic:
bash
pytest tests/test_solver.py
All tests should pass, confirming fitness scoring and flips work as expected.
π Puzzle Example Used (Default)
You can modify row_constraints and col_constraints in nonogram_solver.py. Example:
python
row_constraints = [[6], [2, 2], [2, 2], [2], [3], [4], [2], [], [2], [2]]
col_constraints = [[], [2], [3], [1], [1, 2, 2], [1, 2, 2], [1, 2], [6], [4], []]
πΌοΈ Sample Output Visualizations
Here are a few example solutions generated by our AI Nonogram Solver using Simulated Annealing:
πΎ Typical Git Workflow
bash
git init
git remote remove origin 2>$null
git remote add origin https://github.com/akamohid/AI-NONOGRAM-PUZZLE-SOLVER.git
git add .
git commit -m "Initial commit: nonogram solver via simulated annealing"
git branch -M main
git push -u origin main
β Requirements
Works with Python 3.7 or higher. No extra packages required.
Python >= 3.7
Standard Library only (turtle, math, random)
π₯ Team Members
π License
This project is released under the MIT License.
See LICENSE for full terms.
π Citation
bibtex
@misc{arshad2025nonogram,
author = {Arshad, Mohid and Umar, Mohammad and Hasnain, Mohammad},
title = {AI Nonogram Puzzle Solver via Simulated Annealing},
year = 2025,
howpublished = {GitHub},
url = {https://github.com/akamohid/AI-NONOGRAM-PUZZLE-SOLVER}
}
π¬ Contact & Feedback
Made with β€οΈ by Mohid Arshad.
βοΈ Email: akamohid@gmail.com
π LinkedIn
Feel free to open issues, propose enhancements, or leave a β!
Happy puzzling and learning! π’β¨
Owner
- Login: akamohid
- Kind: user
- Repositories: 1
- Profile: https://github.com/akamohid
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it."
title: "AI Nonogram Puzzle Solver via Simulated Annealing"
version: "1.0.0"
date-released: "2025-06-10"
authors:
- family-names: Arshad
given-names: Mohid
- family-names: Raza
given-names: Mohammad Umar
- family-names: Hasnain
given-names: Mohammad
repository-code: "https://github.com/akamohid/AI-NONOGRAM-PUZZLE-SOLVER"
GitHub Events
Total
- Watch event: 2
- Push event: 4
- Create event: 2
Last Year
- Watch event: 2
- Push event: 4
- Create event: 2
Dependencies
- PythonStandardLibraryonly *
- python >=3.7
- turtle ,math,random,etc.