This project implements an intelligent agent to solve the Minesweeper game using two independent AI approaches:
- Constraint Satisfaction Problem (CSP)
- Probabilistic reasoning (exact inference + Monte Carlo)
The goal is not only to solve the game, but to compare deterministic vs uncertainty-based decision making in AI systems.
- Knowledge-based reasoning
- Logical inference using constraints (sentences)
- Identifies safe cells and mines with certainty
✔ Strength:
- Guaranteed correctness when inference is possible
❌ Limitation:
- Fails when uncertainty appears (no safe moves)
-
Builds constraint models from the board
-
Uses:
- Exact inference (backtracking)
- Monte Carlo sampling (for large states)
-
Computes probability of each cell being a mine
✔ Strength:
- Can act under uncertainty
❌ Limitation:
- Slower and not always optimal
| Feature | CSP | Probabilistic |
|---|---|---|
| Deterministic | ✅ | ❌ |
| Handles uncertainty | ❌ | ✅ |
| Speed | Fast | Slower |
| Accuracy | High (when solvable) | Risk-based |
Game Engine (Minesweeper)
↓
AI Agent
├── CSP Reasoning
└── Probabilistic Inference
↓
Decision Making
- Playable Minesweeper (Pygame)
- AI autoplay mode
- Safe vs mine visualization
- Performance stats (win rate, speed)
- Two independent AI agents
pip install pygamepython game/runner_csp.pypython game/runner_probabilistic.py-
CSP:
- Plays perfectly when logic is sufficient
- Stops when no safe move is known
-
Probabilistic:
- Chooses lowest-risk move
- Continues even under uncertainty
- No learning (non-adaptive)
- Performance drops on large boards
- Probabilistic agent depends on sampling
- Hybrid AI (CSP + Probability)
- Reinforcement Learning agent
- Performance benchmarking system
- Visualization dashboard
- Difference between symbolic AI and probabilistic AI
- Trade-offs between certainty and risk
- Constraint modeling and inference techniques
Pham Tan Minh
This project is licensed under the MIT License.

