Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, you will implement the game minesweeper. This game was made

ID: 3571838 • Letter: F

Question

For this assignment, you will implement the game minesweeper. This game was made popular by the Windows operating system in the early 1990s, and it has continued to be a pre-installed game until Windows 8. You can watch a video of how to play minesweeper on YouTube or read about it on Wikipedia:

https://www.youtube.com/watch?v=Z0EAysRluJk

https://en.wikipedia.org/wiki/Microsoft_Minesweeper

The game is very simple. The object of the game is to open/reveal every cell on the board without detonating a mine. Every cell contains a number or a mine. The numbers tell you how many mines surround the cell in the horizontal, vertical, and diagonal directions, e.g. at most, 8 possible mines surrounding a cell. You can flag a cell, which helps you remember where you think there is a mine to not detonate. If you select to open/reveal a cell that has a mine, then you automatically lose the game!

Our game will be a little different since we do not have a graphical user interface for clicking. You will run the program providing command-line arguments for the number of rows, columns, and mines in any order. Therefore, the number must be preceded by an option designator, -r for rows, -c for columns, and –m for mines.

You will then randomly distribute the mines on the board and set up the numbers describing how many adjacent mines to each cell. After that, you will display a blank board, and ask the user to flag or open a cell on the board until the user selects a cell that contains a mine (losing the game) or selects all cells free of mines (winning the game). After the user wins or loses, you will ask the user if he/she wants to play again.

If so, you must get the number of rows, columns, and mines for the new game and create a new board for a new game. BTW, you can display row and column numbers on the board to make it easier to read/know which row and column to select!!!

Example run of a game:

a.o ut –r 9 –c 9 –m 10

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

Flag(1) or Open(2): 2 row, col: 0 4

You lose!!!

-------------------

|1|1|0|1|*|1|0|0|0|

-------------------

|*|2|1|2|2|2|0|0|0|

-------------------

|2|*|2|2|*|1|0|0|0|

-------------------

|1|1|3|*|3|1|0|0|0|

-------------------

|1|1|3|*|2|0|0|0|0|

-------------------

|1|*|3|2|2|0|0|0|0|

-------------------

|1|1|2|*|1|0|0|0|0|

-------------------

|1|2|3|2|1|0|0|0|0|

-------------------

|1|*|*|1|0|0|0|0|0|

Do you want to play again (1-yes, 2-no): 1 How many rows, cols? 9 9

How many mines? 10

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

Flag(1) or Open(2): 2 row, col: 0 0

-------------------

|1| | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

Flag(1) or Open(2): 2 row, col: 8 0

-------------------

|1| | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

| | | | | | | | | |

-------------------

|1| | | | | | | | |

-------------------

Flag(1) or Open(2): 2 row, col: 5 5

-------------------

|1| | | | |1|0|0|0|

-------------------

| | | | | |2|0|0|0|

-------------------

| | | | | |1|0|0|0|

-------------------

| | | | |3|1|0|0|0|

-------------------

| | | | |2|0|0|0|0|

-------------------

| | | | |2|0|0|0|0|

-------------------

| | | | |1|0|0|0|0|

-------------------

| | | |2|1|0|0|0|0|

-------------------

|1| | |1|0|0|0|0|0|

Flag(1) or Open(2): 1 row, col: 6 3

-------------------

|1| | | | |1|0|0|0|

-------------------

| | | | | |2|0|0|0|

-------------------

| | | | | |1|0|0|0|

-------------------

| | | | |3|1|0|0|0|

-------------------

| | | | |2|0|0|0|0|

-------------------

| | | | |2|0|0|0|0|

-------------------

| | | |!|1|0|0|0|0|

-------------------

| | | |2|1|0|0|0|0|

-------------------

|1| | |1|0|0|0|0|0|

-------------------

Flag(1) or Open(2): 2 row, col: 7 1

-------------------

|1|1|0|1|!|1|0|0|0|

-------------------

|!|2|1|2|2|2|0|0|0|

-------------------

|2|!|2|2|!|1|0|0|0|

-------------------

|1|1|3|!|3|1|0|0|0|

-------------------

|1|1|3|!|2|0|0|0|0|

-------------------

|1|!|3|2|2|0|0|0|0|

-------------------

|1|1|2|!|1|0|0|0|0|

-------------------

|1|2| |2|1|0|0|0|0|

-------------------

|1|!|!|1|0|0|0|0|0|

Flag(1) or Open(2): 2 row, col: 7 2 Congratulations!!!

-------------------

|1|1|0|1|*|1|0|0|0|

-------------------

|*|2|1|2|2|2|0|0|0|

-------------------

|2|*|2|2|*|1|0|0|0|

-------------------

|1|1|3|*|3|1|0|0|0|

-------------------

|1|1|3|*|2|0|0|0|0|

-------------------

|1|*|3|2|2|0|0|0|0|

-------------------

|1|1|2|*|1|0|0|0|0|

-------------------

|1|2|3|2|1|0|0|0|0|

-------------------

|1|*|*|1|0|0|0|0|0|

-------------------

Do you want to play again (1-yes, 2-no): 2

Requirements for the game:

You must provide a usage message, if the user enters incorrect command-line arguments

You must not have functions over 15-20 lines long (-10 automatically)

You must not use global variables (-10 automatically)

You must ask the user if he/she wants to play again

-If no, then end.

-If yes, then prompt for rows, cols, and mines for a new game.)

You must not have any memory leaks (-10 automatically)

You must detect these errors:

-Invalid row or column to flag or open

-Opening a cell that has already been opened)

You must Recursively open all cells adjacent to 0 cell:

-If the user selects a cell that has no mines surrounding it, then you will help the user by recursively opening all adjacent cells to empty cells, until you reach cells with a surround mine.

Explanation / Answer

#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <dos.h>
#include <stdlib.h>
#include <time.h>
#define MROW eight
#define MCOL eight
#define MINES five
#define BSIZE fifteen
union REGS i,o;
//9 for mines
main()

              else
                       
              }
       //put mines worth in different blocks
       for(row=0;row<MROW;row++)
                
                     }
              }

       rectangle(0,0,maxx,maxy);
       //sets read port to the play space solely
       setviewport(200,190,385,370,1);
       nclick=0;
       while(!kbhit()&&loop=='t')
              val>=80)
                            {
                            val=val>=80?val-80:80+val;
                            arr[(y-195)/20][(x-210)/20]=val;

                            while(button&2)
                                   getpos(&button,&x,&y);

                            hidemouse();
                            setpos(30,50);
                            clearviewport();
                            showmouse();
                            setpos(prex,prey);
                              
                     }

              if(button&1 && x>=210 && x<=365 && y>=195 && y<=350)
                       
                                                 outtextxy(180,410,"PLAY AGAIN");
                                                 outtextxy(360,410,"QUIT");
                                                 while(x>=330 && x<=430 && y>=400 && y<=425 && !button&1)
                                                        getpos(&button,&x,&y);
                                          }
                                   else
                                            
                                          if(x>=330 && x<=430 && y>=400 && y<=425)
                                                   
                                          }
                                   }
                            }
                     else
                            { //NOT ON DANGER space
                            if(arr[trow][tcol]<50)
                                     
                            }
                     }
              }
       if(loop=='t')
                
       }
}

initmouse()


showmouse()


hidemouse()


restarea(int x1,int x2,int y1,int y2)


setpos(int x,int y)


getpos(int *button,int *x,int *y)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote