ai-nonogram-puzzle-solver

🧠 AI-powered Nonogram Solver using Simulated Annealing 🧩 Solve logic grid puzzles intelligently with Python + Turtle 🐒✨

https://github.com/akamohid/ai-nonogram-puzzle-solver

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
Last synced: 6 months ago · JSON representation ·

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
Created 9 months ago · Last pushed 7 months ago
Metadata Files
Readme License Citation

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

  1. Clone the repository
    bash git clone https://github.com/akamohid/AI-NONOGRAM-PUZZLE-SOLVER.git cd AI-NONOGRAM-PUZZLE-SOLVER

  2. (Optional) Create a virtual environment
    bash python -m venv venv source venv/bin/activate # macOS/Linux venv\Scripts\activate # Windows

  3. Install (none!)
    This project uses only the Python standard libraryβ€”no external dependencies.


▢️ Running the Solver

  1. Open src/nonogram_solver.py in your editor.
  2. Locate the β€œ### EDIT BELOW FOR CUSTOM PUZZLE ###” section:
    python row_constraints = [ [3], [1,1], [2], … # example ] col_constraints = [ [1], [4], [1,1], … ]
  3. Replace these lists with your own puzzle’s row and column clues.
  4. Run: bash python src/nonogram_solver.py
  5. 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

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

requirements.txt pypi
  • PythonStandardLibraryonly *
  • python >=3.7
  • turtle ,math,random,etc.