Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use PYTHON this program recreates the game minesweeper if the function. ask for one argument please put only one argument initMines() - This function takes

Use PYTHON

this program recreates the game minesweeper if the function. ask for one argument please put only one argument

initMines() - This function takes zero arguments and returns a grid (i.e. a 2D list) with randomly placed mines. The size of the grid should be a global constant called GRIDSIZE (where both the number of rows and columns equal GRIDSIZE). The grid will be filled with either empty strings ("") or mines ("x"). For each cell in the grid there should be a 1 in 10 chance of placing a mine. (If you would like, this too can be a global constant making it a 1 in MINECHANCE chance of placing a mine. For submission, please set this constant to 10). This function initMines() has already been done

initBoard() - This function takes zero arguments and returns a grid (ie. a 2D list) representing the player's game board. Initially all cells in the game board should be unrevealed ("#"). The size of the game board should be the same as the size of the grid of mines. This function initBoard() has already been done

displayBoard() - This function takes a 2D grid representing the player's game board as argument and prints it to the screen. The printout of the board should include row and column labels (see examples below). You may assume that GRIDSIZE will always be a number in the range [2-10].

countHiddenCells() - This function takes a 2D grid representing the player's game board as argument and returns the number of cells in the board that are unrevealed ("#"). Initially this will be all of them, but as the game progresses this value should get smaller and smaller with each turn.

countMines() - This function takes a 2D grid representing the minefield as argument and returns the number of cells in the grid that contain mines. This value should not change once the minefield is initialized.

isMineAt() - This function takes as arguments, a 2D grid representing the minefield and two integers representing a row and column respectively, and returns True if the cell indicated by the row and column contains a mine in the grid, and False otherwise. This function should validate the inputted row and column values to ensure that they are on the gameboard, and return False if they are not.

countMinesAround() - This function takes as arguments, a 2D grid representing the minefield and two integers representing a row and column respectively, and returns the number of mines in adjacent cells. Adjacent cells are the 8 cells surrounding the provided cell, including diagonals, as illustrated in the figure to the rig

I need help with the last 5 :displayBoard(), countHiddenCells() , countMines(), isMineAt(), countMinesAround()

Example of Final game:

Game won with GRIDSIZE: 5

 > python minesweeper.py |01234 ------- 0|##### 1|##### 2|##### 3|##### 4|##### Select a cell (row,col) > 1,1 |01234 ------- 0|##### 1|#2### 2|##### 3|##### 4|##### Select a cell (row,col) > 3,3 |01234 ------- 0|##### 1|#2### 2|##### 3|###1# 4|##### Select a cell (row,col) > 0,4 |01234 ------- 0|####1 1|#2### 2|##### 3|###1# 4|##### Select a cell (row,col) > 4,0 |01234 ------- 0|####1 1|#2111 2|11 3| 11 4| 1# Select a cell (row,col) > 0,2 |01234 ------- 0|##1#1 1|#2111 2|11 3| 11 4| 1# Select a cell (row,col) > 0,1 |01234 ------- 0|#21#1 1|#2111 2|11 3| 11 4| 1# YOU WIN!!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

What are Decision Trees?

Answered: 1 week ago

Question

What is meant by the Term Glass Ceiling?

Answered: 1 week ago