Question: I need help with my minesweeper program.I want this in c thx . The outline of the minesweeper. structure: two 2 - dimensional array:minemap and

I need help with my minesweeper program.I want this in c thx.
The outline of the minesweeper.
structure:
two 2-dimensional array:minemap and cellstatus
minemap is store where the mines are the neighboring
mine counts
cellstatus store the status of each cell during gameplay which is untouched opened and flagged.It will be update during the process
-1 indicating it's a mine
0 indicating untouched
1 indicating opened
2 indicating flagged
the height and width of the game board is 5
# define H 5
# define W 5
# define MINE -1
# define UNTOUCHED 0
# define OPENED 1
# define FLAGGED 2
int mineMap [H][W];
int cellStatus [H][W];
int N;
No other global variable are allowed
#include
#include
only this two header file are allowed
1.Initializing Game Boards
The main() function calls the initGameBoard() function,place the mines in mineMap and set all the cells UNTOUCHED in cellStatus.
read the number of mines (N) and then the locations of the N mines one by one.
We use the MINE to mark these mine locations in the mineMap.
for Loop, read in N mine
// for each mine,read in column and row
scanf("%c %d",&c,&r);
getchar(); // get the pending new line
// place the MINE in the mineMap
2.complete the printMineMap() function to print the
mineMap .We use numbers 1,2,3,4, and 5 to represent
the five rows, and capital letters A, B, C, D, and E to represent the five columns
A cell will display a 0 to indicate there is no mine in it, or display a * to indicate
the presence of a mine in that cell.
3.Count the neighbouring mine
The main() function invokes the fillMineNeighborhood() function, which counts the number of nearby mines.For each empty (not mine containing) cell in mineM ap, fillMineNeighborhood() counts the total number of mines in the neighboring cells and stores the number in the mineMap array
4.Print gameboard
After each input,on the screen using the printGameBoard() function.use the numbers 1,2,3,4,5 to represent the five rows,
the letters A, B, C, D, E to represent the five columns.
there are three cell status, UNTOUCHED, OPENED, FLAGGED in cellStatus
For UNTOUCHED cells, display -
For FLAGGED cells, display &
For OPENED cells, display the value in mineMap
5.Choose cell by player
In each round of the game, the main() function displays the game board and prompts the player to enter the location of the selected cell.Initially, the game board is displayed with all cells UNTOUCHED, and the game waits for the user to select a cell.After the player inputs the location of a selected cell, we need to check the validation of the input.
If the cell is opened or flagged, we need to remind the
player and ask for the input again, until the input is appropriate.If the input location is invalid.we need to remind the player and ask for the input again, until the input is valid.
If the input is valid,let the player choose open the cell or flag the cell and update the cellStatus array accordingly.
If the player opened the cell and the cell is mine,the player loses the game The mineMap will be displayed to tell the player the correct result and a message to let the player know he lose.
If the opened cell is not a mine, consider the winning condition.If it is not fulfill the condition, update and next round.If the condition is fulfilled,print a message to player. The winning condition is to open all the non-mine cell
If the player choose to flag the cell,, the program will display the cell as flagged by the character "&", and then prompt for the next input.It is important to note that the flagged cell remains unopened; it is only marked as suspicious, but not opened yet.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!