Question: Assignment Your assignment will not involve any game playing but you will be required to generate the underlying grid for a game of minesweeper. Your

 Assignment Your assignment will not involve any game playing but youwill be required to generate the underlying grid for a game of

Assignment Your assignment will not involve any game playing but you will be required to generate the underlying grid for a game of minesweeper. Your program should read three input values. The first two, m and n represent the dimensions. The game will be played on an m by n board. The third input, p, is a double value between 0 and 1 which represents the probability that a cell contains a mine. (Make sure you validate this input value) Your program should first produce an m by n grid where 1 indicates the presence of a mine and 0 indicates a safe cell. For each cell, you should generate a random value between 0 and 1. If the value is less than p, you should place a mine in that cell. You should output this grid using an asterisk to indicate the presence of a bomb and a dot to indicate a safe cell. For example, if m=5, n=10 and p=0.3 the output could be as follows (it may differ depending on the random numbers generated): Assignment Your assignment will not involve any game playing but you will be required to generate the underlying grid for a game of minesweeper. Your program should read three input values. The first two, m and n represent the dimensions. The game will be played on an m by n board. The third input, p, is a double value between 0 and 1 which represents the probability that a cell contains a mine. (Make sure you validate this input value) Your program should first produce an m by n grid where 1 indicates the presence of a mine and 0 indicates a safe cell. For each cell, you should generate a random value between 0 and 1. If the value is less than p, you should place a mine in that cell. You should output this grid using an asterisk to indicate the presence of a bomb and a dot to indicate a safe cell. For example, if m=5, n=10 and p=0.3 the output could be as follows (it may differ depending on the random numbers generated)

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 Databases Questions!