You are on page 1of 16

MEDDLING

WITH BRAINS
(MINESWEEPER
)

DESCRIPTION
Minesweeperis
asingle player video
game. The object of
the game is to clear
an
abstractminefieldwit
hout detonating a
mine. The game has
been written for
manysystem
platformin use today.

How to play Minesweeper


Click any square.
Most Minesweeper
players click random
squares until a group of
squares "opens" up. If
4 or 5 squares opened
after your click, it's
time to evaluate the
numbers. If only one
square opens after
your click, find another
random square.

How to play
Minesweeper(continued)
Understand
what the
numbers mean.
If you see a 1 on
the board, it
means that
square is touching
exactly 1 mine.

How to play
Minesweeper(continued)
Eliminate squares that
can't possibly contain
mines by clicking. Say
you found a 1, and you're
pretty sure where the
mine for that 1 is. You
can click all the other
squares around that 1 to
open them, because the
1 can only be in contact
with a single mine.

How to play
Minesweeper(continued)
Right-click to
identify mines.
When you're
reasonably certain
you've found a mine,
identify it by rightclicking on the
square. This will put
a flag on the mine,
and prevent you

How to play
Minesweeper(continued)
Keep moving
through a process
of elimination. As
you go around the
board, flag potential
mines. If you find that
you've flagged more
mines than the game
allows, go back and reevaluate them.

OUR SOLUTION
The functions for the game board
were originally written in C++
The GUI was originally written in
C#
After trying to link the two
different languages, we opted to
covert our C++ code into C# and
have all of the code be in one file

More on the Solution

Our solution consist of -:


We have created the start button to start the
game.
Next we created a how to play button which gives
instruction for playing the game.
A hint and tips button to give hint and tips for
playing better game.
We have created beginner mode of minesweeper
with 9 9 board.
We have numbered buttons1 ,2,3 and 4, we
also have buttons with empty spaces and buttons
with bomb.
Button with a no. 1 on it shows that there is one
bomb near that button, button with no. 2 on it
shows that there are 2 bombs near that button and

More on the Solution


We have first set the value of-:
Count=2 for indicating empty spaces.
Count=1 for indicating number of bombs in
adjacent buttons.
Count=0 for indicating that a bomb has been
encountered.
So that on click of a button
If bomb is encountered Game Over.
If cell that has 1 or more bombs on border
then reveal the number of bombs that border cell.
If a cell that has 0 bombs on border
then reveal that cell as a blank and click on the 8
surrounding cells.

More on the Solution

When user clicks the button with empty space then it will
open all the near buttons that the button is connected with,
which either has an empty space or a no. on the button.
When user clicks the button which is a bomb then it will
display a message that you lost the game and will also show
the time at which you lost the game and navigate to another
page which has 3 options for exit, restart and another level.
User wins the game when all the buttons has been opened
except the buttons with a bomb.
If user does not know which button contains the bomb and
does not want to lose the game then he can opt for flag
button which is a guess button. First he will click on the flag
button then on the button which he wants to guess, it will
show a flag image and decrement the value of k from 10 to 9
which will show in another button. If user wants to open the
guessed button now or later then first he will click the flag
button which will increment k from 9 to 10 again and then will
click on a button with a flag image, it will show the question
mark image showing user has open the guessed button and

More on the Solution


We have also used the variable flag to set the winning
condition and the variable count to set the losing condition
for the game. Each button has a flag variable associated
with it. When flag for each button has value 1 we win the
game else lost.
We have used 81 l variables which is to check if there is
already a flag in a button then it should not open the button
until we click the another flag.
81 d variables which is to check if button is already open
then it should not return to flag.
81 click buttons to check if there is already a flag in a
button then it will show the question mark image on a button ,
increment k telling the user that now the button can be
opened.

More on the Solution


We have also added -:
A timer to keep in account the time taken by the user to
complete the game. For the timer we have added the
dispatcher class and the System.Windows.Media.Imaging
namespace which is part of PresentationCore.dll. The
variable i which is incremented to give the value of time in
seconds.
When user clicks any button with no bombs then timer will
start.
Timer will stop only when user encountered a bomb or has
won the game.
An appearance button to change the colour of the board. With
the help of this button we can change the board colour from
purple to red.For this purpose we have used col variable.
Initially col is 0, when user clicks the appearance button it will
change the purple appearance to red and set col to 1,when
user clicks the appearance button again then it will again
change the appearance from red to purple and set col=0 and

More on the Solution


Also we have added-:
A button to keep into account the guess made by
the user. The variable k is initialized to 10 and
decremented each time user makes a guess and
incremented when guess is unlocked.
A quit button to quit the game. User can quit the
game at any time he wants by clicking the Q
button-it will also show the time user is quitting the
game.
An exit button to leave the game.
A play again button to play another level.
A restart button to restart the game.

Results
In the end, we
have created a
very functional
Minesweeper
game that very
closely resembles
the original
Windows version.

Thank you !

You might also like