Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 AI Minesweeper Agent

An intelligent Minesweeper game built with Python and Pygame. The AI uses propositional logic and knowledge-based reasoning to infer safe moves, identify mines, and solve the board with minimal guessing.


✨ Features

  • Human vs AI gameplay
  • AI uses logical inference to determine safe moves
  • Automatically identifies mines when possible
  • Knowledge base updates after every move
  • Interactive Pygame interface
  • Reset game functionality
  • AI falls back to random moves only when necessary

🧠 AI Concepts Used

  • Knowledge-Based Agents
  • Propositional Logic
  • Logical Inference
  • Constraint Satisfaction
  • Safe Cell Detection
  • Mine Identification
  • Knowledge Base Updates

🛠 Technologies

  • Python
  • Pygame

📂 Project Structure

.
├── assets/
│   ├── fonts/
│   │   └── OpenSans-Regular.ttf
│   └── images/
│       ├── flag.png
│       └── mine.png
├── screenshots/
│   ├── home-screen.png
│   ├── gameplay.png
│   └── game-over.png
├── minesweeper.py
├── runner.py
├── requirements.txt
├── .gitignore
├── LICENSE
└── README.md

📸 Screenshots

Home Screen

Home Screen

Gameplay

Gameplay

Game Over

Game Over


🚀 Installation

Clone the repository:

git clone https://github.com/ambertiwary27/ai-minesweeper-agent.git

Move into the project folder:

cd ai-minesweeper-agent

Install dependencies:

pip install -r requirements.txt

▶️ Run the Project

python3 runner.py

🎯 How the AI Works

The AI maintains a knowledge base containing logical sentences about the game board. After every revealed cell, it updates its knowledge, infers new safe cells and mines, and continues making logical moves. When no logical move is available, it selects a random unexplored cell.


📚 Learning Outcomes

This project demonstrates:

  • Knowledge-Based Artificial Intelligence
  • Logical reasoning with propositional logic
  • AI decision making
  • Constraint solving
  • Python game development using Pygame

🙏 Acknowledgements

This project was developed as part of Harvard University's CS50's Introduction to Artificial Intelligence with Python.


👨‍💻 Author

Amber Kumar Tiwary

About

AI-powered Minesweeper game built with Python and Pygame using logical inference and knowledge-based reasoning.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages