~piotr-machura/sweep-ai

Minesweeper with AI-powered hints.

0897760 Create cache directory if it does not exist

4 months ago

a967cc1 Create cache directory if it does not exist

4 months ago

#Sweep AI

Sweep AI is a minesweeper clone enhanced with deep learning capabilities. While minesweeper may not exactly be NP-complete and multiple strategies that make the game easier exist, why not make the neural network solve the problem for us?

Warning: this doesn't work so well.

#Installation

The safest way to clone the repo and install the game within a virtual environment

# In the project's directory
python3 -m venv .venv
source .venv/bin/activate
pip install .
python3 -m sweep-ai # Play the game

For development, use poetry:

# In the project's directory
poetry install
poetry run pytest # Run unit tests
poetry run sweep-ai # Play the game

#Usage

The players' brains and training data are cached and looked for in the following order:

  1. $SWEEP_CACHE/sweep
  2. $XDG_CACHE_HOME/sweep
  3. $CWD/sweep

Run the game with --clean-cache flag to remove the cache directory. Use --no-cache if you don't want to use the cached models (cached training data is still used). To generate a plot of player's loss after training add the --plot flag.

The AI is built using keras. The interface uses pygame and pygame-menu.