AVR Mines is a Minesweeper implementation for AVR. Minesweeper
Minesweeper is a game in which the player is given a board with a certain number of spaces that contain hidden mines. To win, the player must select all empty spaces, avoiding the mines.
The board is a 5 x 14 matrix which starts with all spaces hidden, as seen in Figure 1. Once a space is selected, it and its neighbors are revealed. A space can be empty or contain a mine. Empty spaces display the total value of adjacent mines, or nothing if they have no neighbouring mines.
Figure 1. Board with all spaces hidden
A space reveals no neighbours if it has any adjacent mines. There are 14 mines on the board, and if any one of them are selected, the game is lost. The player can mark houses where they believe there are mines with flags to make the game easier, as seen in Figure 2. When all empty houses are selected, the player wins the game. Then, the player can restart the game with a new, randomly generated board.
Every space is revealed and the appropriate message is shown, as seen in Figures 2 and 3. The player then may press the FLAG button to restart the game.
To implement this game, the AVR atmega328 processor and the pcd544 display were used. The project was simulated with simulIDE 0.4.15_SR9-1. Six buttons were used, four for movement and two others. Of the latter, the CHECK button is responsible for starting the game and for selecting a field, while FLAG is used for restarting the game and marking a square on the board with a flag.
The game may be built and ran by executing $ make
in the project's root directory and then loading the generated .hex file within simulIDE after using it to open simulide/mines.simu (right click the CPU and select "Load firmware").