An implementation of the AI that plays the Minesweeper game.
On each AI move we need to deduce a new sentence based on premises (sentences) from knowledge base of the AI.
Each sentence in the knowledge base is represented by a set of cells and a number of mines among these cells.
{A, B, C, D, E} = 3
So here we have 5 cells that we don't know anything about just yet (of course, each cell is stored as a pair of x, y coordinates) but we know that there are 3 mines among them.
There are 3 possible situations from which we can infer new sentences.
If we have a sentence where a number of cells is equal to a number of mines among these cells then we can infer that all cells are known to be mines. Example: {A, B, C} = 3.
However if we have a sentence where a number of mines is 0 then we can infer that all cells are not mines. Example: {A, B, C, D} = 0.
Consider the following example:
+---+
|111|
|BCD|
|A2E|
+---+
Here we know that {A, B, C, D, E} = 2,
on the other side we know that {B, C, D} = 1. Now we can deduce a new sentence by removing all common cells from the first set and also let's subtract numbers of mines so we get {A, E} = 1 and that's indeed right!
So the algorithm is the following:
- Check if the second set is a subset of the first set,
- Perform a subtraction on both sets and mines counters.
- Install premake5 or use one from
Vendor/Bin/Premake5, - Run
./Vendor/Bin/Premake5 --helpand choose one of the supported platforms to generate a build configuration.
- Install Emscripten,
- You can use
embuild.pyto build the game andemrun.pyto run a server. Located atBuild/Scripts.
If the application runs but the screen is black then check a path to the Assets folder.