CSCI 689 Computer Assignment 5

$30.00

Download Details:

  • Name: Assignment-5-vrg9i1.zip
  • Type: zip
  • Size: 134.88 KB

Category:

Description

Rate this product

In the game of Minesweeper, a player searches for hidden mines on a rectangular table
that might—for a very small board—look like this:
X X
X
X X X X
X
X
One way to represent that table in C++ is to use a table of Boolean values marking the
mine locations, where indicates the location of a mine. Given such a table of mine
locations: write a C++ program that (1) creates a mine field for a given size; (2) prints out
the mine field; (3) creates a table for the mine counts, in which each element indicates
the number of mines in the corresponding neighborhood locations that includes the
location itself any of the eight adjacent locations that are inside the boundaries of the
table; and (4) prints out the table with number of mines corresponding to each location.
For the above example, the count table might look like this:
1 1 0 0 2 2
3 3 2 1 4 3
3 3 2 1 3 2
3 4 3 2 2 1
1 2 1 1 0 0
0 1 1 1 0 0
The Game of Minesweeper
2
Use two-dimensional vector containers for both the table of a mine field and the table of
the mine counts, and in addition to the routine, implement the following
routines in your program.
 This
routine determines if a location in the vector of has a mine. If that’s the
case, then sets the value for that location; otherwise, it sets the value
The value for each location is randomly chosen with the input argument
where a random number is generated by the equation:
and if then it assigns to that
location; otherwise, it assigns The random-number generator (RNG) can be
initialized by calling the function with the value
before generating any random numbers by the RNG.

This routine checks the Boolean value for each location and the
values of its eight neighborhood locations in the vector and sets the total
count value for that location, which is between and in the vector
 This routine
displays the table for the mine field on by printing out the character for
each mine location in the vector
 This routine
displays the table for the mine counts on for each mine location in the
vector
The routine gets a pair of numbers from (the size of the mine field and the
probability of mine in a location), creates the two-dimensional vectors and
for the size of the mine field, and calls the above routines for each individual
task. The process continues until no more input pairs are supplied from the
If you name your source file as and its header file as then to compile and
link your program with the system library routines, first make a link to in
directory: and then execute: To test your program,
execute: This command executes your program with the
input file and displays the output on and also writes in the output file
You can find the input and output files of this program in the same directory
with the You need to know that if you name your source and header files
different than the suggested names, then the command won’t work.
When your program is ready, mail its source and header files to your TA by executing the
following command: