Limited Reasoner Demo: Minesweeper

Quick start: hit the "Click to play Minesweeper!" button and see the agent play under "Game Output".

For further demos and details on the reasoner, click here.

Game Configuration

Standard configurations: small, medium, large, huge

Field width:
Field height:
Number of mines:
Scale field to window:
Max. number of case splits:
Mine placement seed:
(modify for different mine placement)

Game Output

Ready to play!
To flip through the agent's moves, use the arrow keys . To play another round, you could change the seed or the field size to get a new mine placement.

Quick explanation: The agent aims to explore the field without hitting a mine. When it explores a cell with a mine, the game is lost. When it opens a mine-free cell, it learns how many adjacent cells contain a mine. This number is displayed in every cell. From this information, the agent tries to infer which adjacent cells are safe or contain a mine. Known mines are flagged dangerous with a red flag symbol.

See previous / next turn (or use arrow keys ).

About Minesweeper

Among the width × height cells on the field, n_mines cells contain a mine. The goal of the agent is to identify these mines.

The goal state is to explore all cells that contain no mine, and to flag all cells contain a mine.

On every turn, the player selects a cell and either explores it or flags it as mine. When a cell that contains a mine is explored, the game is lost. When the cell contains no mine, the agent learns how many adjacent cells (0 ≤ N ≤ 8) contain mines. (When N = 0, the adjacent cells are explored immediately.) When a cell is known to contain a mine, it can be flagged as such, as a mental note not to consider it for future exploration. Explored cells are visualized as their number N, or a mine symbol when they contain a mine (in which case the game is lost), and flagged cells are marked by a red flag.

The game is won when all non-mine cells are explored and all mine cells are flagged. The game is lost when the agent explores a mine cell.

About the Agent

The agent is a simple C++ program that loops over all cells and uses the reasoner to find out which cells are known to contain a/no mine.

For every cell (x,y), we use a proposition IsMine(x,y). When a cell is explored, the agent receives the information how many adjacent cells contain a mine. To reflect this new information, the agent adds clauses of IsMine(x,y). For instance, when the agent learns that one of the eight adjacent cell contains a mine, it adds IsMine(x-1,y) ∨ IsMine(x-1,y+1) ∨ IsMine(x,y+1) ∨ IsMine(x+1,y+1) ∨ IsMine(x+1,y) ∨ IsMine(x+1,y-1) ∨ IsMine(x,y-1) ∨ IsMine(x-1,y-1) to say that at least one of the neighbours contains a mine, and a few similar clauses to say that at least seven adjacent cells contain no mine.

On every turn, the agent checks for every cell whether it is known to contain a mine or known to contain no mine. (As a simple heuristic, the agent starts with cells in the neighbourhood of the cell selected in the last move.) This process is repeated for increasing split level, until a cell which is known to be a mine or known to be safe is found: first for split level 0, then for 1, ..., until the maximum specified split level. If no cell is found, the agent guesses one randomly, with preference to non-frontier node.

The IsMine(x,y) propositions mentioned above are actually represented as literals of the form IsMine(x,y) = T, as the reasoner does not support boolean propsitions; they must be simulated with functions and using a dummy standard name T. To represent that the no mine is present at (x,y), the reasoner could use IsMine(x,y)≠T. Alternatively, a second name F can be introduced and IsMine(x,y) = F can be used together with a clause IsMine(x,y) = T &lor; IsMine(x,y) = F. It turns out that due to some optimisations, the latter method is actually slightly faster (about 5%): queries can be of the form IsMine(x,y) = b for a variable b, instead of of two queries, IsMine(x,y) = T and IsMine(x,y) ≠ T.

Note the agent's actions are not represented in the knowledge base—it's just hard-coded in C++. Extending the knowledge base to a basic action theory that also represents the agent's actions would be the next step.

The runtime reported by the game refers to the time the agent actually spend playing. The actual time that passes between starting and finishing the game may be longer because the graphical display procedures take some time.