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.
- 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
- Knowledge-Based Agents
- Propositional Logic
- Logical Inference
- Constraint Satisfaction
- Safe Cell Detection
- Mine Identification
- Knowledge Base Updates
- Python
- Pygame
.
├── 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
Clone the repository:
git clone https://github.com/ambertiwary27/ai-minesweeper-agent.gitMove into the project folder:
cd ai-minesweeper-agentInstall dependencies:
pip install -r requirements.txtpython3 runner.pyThe 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.
This project demonstrates:
- Knowledge-Based Artificial Intelligence
- Logical reasoning with propositional logic
- AI decision making
- Constraint solving
- Python game development using Pygame
This project was developed as part of Harvard University's CS50's Introduction to Artificial Intelligence with Python.
Amber Kumar Tiwary
- GitHub: https://github.com/ambertiwary27


