CS120
Programming Assignment #8

Due Sunday. April 1st.

For this assignment you will be writting a gopher hunt game. In gopher hunt the player has to pick cells on a two dimensional grid - avoiding the locations of the gophers. Each time a cell is selected the number of gophers in the neighboring spaces is revealed in that cell (neighbors includes diagonals so each cell has eight neighbors). The player loses if they pick a cell containing a gopher. (Yes, this game is very similar to minesweeper.)

On each turn the entire map should be printed, showing which cells have been explored, which cells haven't been explored, and for the explored cells how many neighboring cells containg gophers. It should look something like:
|+++10|
|+++20|
|++++1|
|+++++|
(but bigger), where a + is an unexplored cell and the numbers are explored cells showing the number of neighboring gophers.

After the map is displayed the player picks a cell by entering the cell's x,y coordinates. The program should make sure that these values are in bounds and print an error message and request new coordinates if the cell is out of bounds.

If there is a gopher in the selected cell the player should lose. Otherwise the number of gophers in neighboring cells should be added to the map and the process repeats. The player wins if every cell without a gopher in it has been revealed.

For this game you will probably want two 2-dimensional arrays. One array keeps track of where the gophers are and the number of neighboring gophers for each square. The other array keeps track of which cells the player has already guessed.

You may change the theme of the game. If you want the player to be avoiding the sleeping vampires, that's fine.

Extra Credit: If a player uncovers a cell with zero neighboring gophers then it is clearly safe to uncover all of the neighboring cells. Add to the code so that it automatically uncovers all of the neighboring cells if the player chooses a cell with a zero. If any of the automatically uncovered cells contains a zero the neighbors of those cells should also be uncovered - and so forth.

Turn in: A copy of the program and sample, annotated output showing the program runs. You do not need to print an entire game, but you should show (and label) the important cases, which include the player winning, the player losing, the player entering an illegal move, and how the map changes when the player enters a legal move.