Minesweeper-TUI
Minesweeper-TUI is a command-line implementation of the Minesweeper game in C.

Instructions
Running
- Clone the repository
git clone https://github.com/bepposax/minesweeper-tui && cd minesweeper-tui
Or download the executable
- Run the executable
./minesweeper
Doesn't run?
The prebuilt executable may not work on all distros due to different or missing library versions:
$ ldd minesweeper
linux-vdso.so.1 (0x00007a6cbe1a1000)
libncursesw.so.6 => /lib/x86_64-linux-gnu/libncursesw.so.6 (0x00007a6cbe153000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007a6cbe11d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007a6cbdf29000)
/lib64/ld-linux-x86-64.so.2 (0x00007a6cbe1a3000)
If it doesn’t, recompile it with:
make clean && make
See Compiling ↴
Compiling
- Clone the repository
- Make sure you have the necessary requirements installed on your system:
- Automate the installation with
./install.sh
(works with apt / dnf / pacman / zypper / apk / xbps package managers)
- Usage (make commands):
make: Compiles the source code files and generates the executable file.
make run: Runs the program.
make clean: Deletes the executable file.
make test: Compiles and runs the program in testing mode.
Optional
- Save the alias
mines with./alias.sh
and run it as a command from any folder
Gameplay

- The board is a grid of cells, some containing mines.
- Numbers indicate how many mines are adjacent to that cell.
- Flag suspected mines to track them and avoid accidental clicks.
- Left-click on a numbered cell to quickly uncover surrounding cells if all adjacent mines are flagged.
- Uncover all empty cells to win. Hitting a mine ends the game.
Features
-
Full Mouse Control: left to play, right to flag, middle to mark
-
Four Difficulties: Beginner, Intermediate, Expert, Custom
A full screen Custom game [height: 100%, width: 100%, mines: 10%]
-
Safe First Click: the first move can never be a mine
-
Chording: left-click a number cell to clear around it
-
Move History: replay a finished game step by step with arrow keys
-
Adaptive UI: responsive to window resizes in real time
Controls
| 🖱️ Left |
uncover an undiscovered cell ( ■ ) |
| clear around a numbered cell ( 2 ) if all its adjacent mines are flagged |
| 🖱️ Right |
flag ( ⚑ ) an undiscovered cell as a mine spot |
| 🖱️ Middle |
mark ( ? ) an undiscovered cell as a possible mine spot |
| H |
look at the history of the last played game |
| R |
restart the current game |
| N |
start a new game |
| Q |
quit the game / exit the program |
Notes
- This program has been tested on Windows Subsystem for Linux (WSL) with GCC installed. Compatibility with other systems may vary.
- To ensure proper rendering of the game board, it’s recommended to use a monospace font that supports the Unicode symbols used by the game.
Feel free to modify the code and customize the game according to your preferences.

© 2023-2024 Ivano Izzo
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.
评论