UNIVERSITY OF WEST ATTICA
SCHOOL OF ENGINEERING
DEPARTMENT OF COMPUTER ENGINEERING AND INFORMATICS
University of West Attica · Department of Computer Engineering and Informatics
Computer Programming
Vasileios Evangelos Athanasiou
Student ID: 19390005
Supervision
Supervisor: Nikolaos Vassilas, Professor
Co-supervisor: Georgios Meletiou, Laboratory Teaching Staff
Athens, January 2022
A C-based utility that generates a Minesweeper board based on user-defined dimensions and bomb counts. The program calculates the proximity numbers for each cell and outputs the resulting board to both the console and a formatted text file.
| Section | Folder/File | Description |
|---|---|---|
| 1 | INSTALL.md |
Installation and setup instructions |
| 2 | README.md |
Project overview and usage information |
| 3 | assign/ |
Assignment description and reference images |
| 3.1 | assign/Minesweeper.png |
Minesweeper assignment image (English) |
| 3.2 | assign/Ναρκαλιευτής.png |
Minesweeper assignment image (Greek) |
| 4 | src/ |
Source code and resources for the project |
| 4.1 | src/boards/ |
Predefined game boards for testing |
| 4.1.1 | src/boards/board10x20x20.txt |
Board configuration (10x20 grid with 20 mines) |
| 4.1.2 | src/boards/board5x4x6.txt |
Board configuration (5x4 grid with 6 mines) |
| 4.2 | src/minesweeper.c |
Main C source code implementing the Minesweeper game |
- Dynamic Board Generation: Allows custom rows (M), columns (N), and bomb count (K).
- Proximity Logic: Automatically calculates the number of adjacent bombs for every empty cell (8-neighbor adjacency).
- Memory Management: Uses dynamic heap allocation (
calloc) with error handling and proper memory cleanup to prevent leaks. - Dual Output:
- Prints a formatted grid to stdout
- Saves the board to a
.txtfile inside aboards/directory using a descriptive filename (e.g.,board10x10x15.txt).
The board is created as a 2D pointer array (int**) using dynamic memory allocation.
Bombs are randomly distributed across the grid using:
rand()srand(time(NULL))
Bombs are represented internally with the value:
-1For each bomb placed, the program scans its 3×3 neighborhood and increments the values of surrounding non-bomb cells.
All dynamically allocated memory is released before program termination:
- Each allocated row is freed
- The main pointer array is freed

