Project
Knowledge-Based Minesweeper AI
A Python knowledge-based AI agent for Minesweeper, built through 16 tagged releases with an interface-independent design that powers a CLI, a static browser demo, and a Python-backed API client.
Overview
This project implements a knowledge-based AI agent for Minesweeper and develops it through an interface-independent architecture across 16 tagged releases. The AI engine, an interface-independent game session, a CLI, a static browser demo, and a Python-backed API client are built in separate layers so the reasoning logic can be tested and audited independently of any user interface.
The agent models game state as logical constraint sentences. After each revealed clue, it updates those sentences, infers which cells are safe or mined, and selects a known safe move when inference succeeds. When no safe conclusion can be drawn from the current constraints, it falls back to an unverified move. Structured reasoning trace events record the decision process at each step.
Problem
Minesweeper requires reasoning from partial information. Each revealed cell gives a count of nearby mines, and the agent must use that evidence to infer which neighboring cells are safe or dangerous.
Approach
The project is organized in layers. The AI engine handles constraint sentences, inference, and fallback selection. A GameSession layer wraps the engine and manages board state without any UI dependency, allowing the same logic to power CLI examples, the static browser demo, and the Python-backed API client without modification.
Each revealed clue becomes a logical sentence describing a set of neighboring cells and the number of mines among them. The agent updates those sentences as cells are marked safe or mined, then derives additional constraints from subset relationships. Structured reasoning trace events record each inference step.
Outcome
The project reached v1.4.2 through 16 tagged releases and 81 unit tests covering all core modules: sentences, board, agent, session, reasoning trace, and the web adapter.
Three runnable demo modes share the same engine: a CLI reasoning trace, a CLI board simulation, and two browser interfaces. Both browser modes support configurable difficulty from Beginner to Hard, Classic and Tactical reveal styles, and an optional Helper move control. The Python-backed API client syncs all settings through a local JSON API.
Tradeoffs
This project strengthened my understanding of representing uncertainty, maintaining a knowledge base, deriving new facts, and translating logical reasoning into clear Python code.
Professional profile
Continue from the evidence
See how this work fits into my broader computational science and software engineering background, or get in touch about relevant work.