Minesweeper is a small grid-based game where a player has to identify hidden mines and open all the safe tiles. Players who are bored of staring at the same monitor and willing to play in a different monitor, can try this project game. The game was created by Robert Donner whilst working for Microsoft. The objective of the project is to create a tutoring system that will help the player how to play this game. While playing this game, strategies will be explored and the strategies will help a player to understand the game in an efficient and effective way.

The computer game Minesweeper is a game that was made popular by the windows OS. The computer game minesweeper starts the game by showing you blank grid of squares. Some squares conceal mines, the rest are safe. Your task is to work out where the mines are without detonating any of them.

History of Minesweeper
Minesweeper is a single player puzzle game. The origin of the minesweeper game is the earliest mainframe game of the 60’ and 70’ decades. The earliest ancestor of Minesweeper was Jermiac Ratliff’s Cube. This game became more popular amongst puzzle games during 1980’s with the title of ‘Mined-out’ ,’Yomp’ and ‘Cube’.The game of minesweeper that we play now-a-days created for windows.
Robert Donner and Curtis Johnson, who worked for Microsoft, wrote and developed the game for release with the Microsoft Entertainment Pack for Windows 3.1 in 1990. It was then upgraded in 1992 to feature in the in-game pack, replacing Reversi in the process. Versions of Minesweeper are frequently bundled with operating systems and GUIs, including Minesweeper for OS/2, Minesweeper in Windows, KMines in KDE (Unix-like OSes), Gnomine in GNOME and MineHunt in Palm OS.

Game rules
At the beginning of the game, a 2D grid of identically looking tiles (or squares) is presented to the player. The player has to find all the mines and it determines the difficulty of the game. The goal of the game is to set up flags on the tiles that are containing mine. If the player reveals a tile containing a mine, the game will over. To prevent the mine from being exploded player has to set up the flags on all the mines that are possible according to the game rules. At first, the player has to reveal a tile which will show some numbers and that is the clue to find the mines. The number on a particular tile indicates number of possible mines around its adjacent eight tiles.

Code explanation
This game is a C based Minesweeper. To implement this code we used four header files: graphics.h, conio.h, stdio.h, time.h. Including these libraries we got some advantages. By using time.h library we can use srand(time(NULL)) function which helps us to generate random number in every execution. Using graphics.h libarary we get a graphical user interface. From this library we used different types of functions like
• initwindow(): This function initializes the graphics system by opening a graphics window of the specified size. The first two parameters (width and height) are required but all other parameters have default values.
• bar(): This function is used to draw a two dimensional rectangular filled bar which takes four parameters as the co-ordinates of the bar. First two arguments are the starting point and last two arguments are the ending point.
• line(): This function is used to draw a line which takes four parameters as the co-ordinates of the line. First two arguments are the starting point and last two arguments are the ending point.
• setcolor(): This function is used to set the current drawing color to the new color.
• outtextxy(): This function takes three parameters. First two are the co-ordinates and the third parameter is the string or the text we want to display.
• settextstyle(): This function is used to change the way in which text appears. It takes three parameters. First one is font style, second one is direction and third one is text size.
• cleardevice(): This function clears the graphics window.
• setfillstyle(): It sets the current fill pattern and color to new fill pattern and color.
• closegraph(): It closes the graphics mode.

How to play this game
When we run the code a window and console will pop up like shown below:

After pressing “enter” we will see two options: Play and game rules as in the picture:

If we press “space” we will see the game rules.

Press “ESC” to return to main menu.
If we press left key we will see a 6X6 grid which is the main board of the game and on the console we will have to enter a starting point to open a tile.

After entering row and column number, we will see this:

If we want to flag a tile, we will have to select the f mode and after giving the point we will see this output:

If we want to open a tile, we will have to select the o mode and input a point and the output will be like this:

If we want to remove a flag, we will have to select the r mode and input the point where we want to remove the flag.
If we successfully flag all the mines, we will win and we will see this output:
And if we open a tile which contains a mine we will lose and see this

To play this game, download the source code from here

Written By:
Ayasha Hossain Jui (180201)
Maliha Bintay Zaman (180210)
Samia Sharnami (180233)
Umma Habiba Akhey(180237)

Thank you