A simple Java-based implementation of the core Minesweeper game logic.
Focuses purely on the game engine, with no UI layer included.
Status: Completed — all main functions of the Minesweeper logic are implemented.
- Customizable board size and number of mines
- Automatic random mine placement
- Flood-fill logic for revealing connected empty cells
- Flagging system to mark suspected mines
- src/minesweeper/ — Core game logic (Board, Cell)
- test/minesweeper/ — Unit tests (JUnit 4)
- Clone the repository:
bash
git clone https://github.com/MrAlbertt/Minesweeper-core.git
- Open the project in NetBeans 8.2+.
- Build the project to ensure all dependencies (JUnit 4) are correctly loaded.
This project provides only the game engine, so you can integrate it into your own applications or use it via the included test suite.
import minesweeper.Board;
import minesweeper.Cell;
import java.util.List;
// Create a new board: 9x9 with 10 mines
Board board = new Board(9, 9, 10);
// Or use the empty constructor for a default 10x10 board with 15 mines
Board defaultBoard = new Board();
// Reveal a cell at row 3, column 4 (returns a list of updated cells)
List<Cell> updatedCells = board.floodReveal(3, 4);
// Flag a suspected mine at (5, 5)
board.setFlag(5, 5);
// Access a specific cell
Cell cell = board.getCell(3, 4);
To run the JUnit tests:
- Open the project in NetBeans.
- Right-click the test package and select Test.
- Java 8
- JUnit 4
- NetBeans 8.2
This project is licensed under the MIT License - see the LICENSE file for details