Project 4: MineSweeper

Due by 11:59 pm Tuesday April 25th, 2006

 

Introduction

 

The game of minesweeper is a game of logic reasoning. A 10 by 10 grid is created and 10 mines are placed at random in the grid. The player then clicks a button in the grid which either reveals a mine (you lose) or it reveals how many mines there are in the neighboring squares (1 away in each of the directions). Your goal is to find the location of all 10 mines without accidentally exploding one.

 

What I’ve provided

 

To get you started, I’ve produced a skeleton project. This project contains the code that creates the grid of 100 buttons. It also has a method that informs you when and which button the user has placed. Your job is to modify the code in the Form1_Load subroutine and the GridClick subroutine.

 

Do NOT modify any of the code I’ve provided except for the example code in GridClick.

 

What you need to do

 

You need to create a 2 dimensional array that represents the playing board, and in each appropriate array element, you will either indicate it is a mine, or you will place the number of mines in the surrounding squares.

 

In the Form1_Load subroutine, you will do the following:

  1. Place 10 mines at unique, random coordinates
  2. Fill in the array with the neighbor counts, according to the following examples:

 

General Case:

For all of the rows from 2 to 9 and columns from 2 to 9, each square has eight neighbors. If the square you are examining (marked with the “?” below) does not contain a mine, count how many mines are in the surrounding 8 squares.

 

 

 

 

 

?

 

 

 

 


First/Last Rows/Columns:

In the first row, last row, first column, and last column there are only 5 neighbors.

 

 

 

?

 

 

 

 

Corners

In the top right, top left, bottom right, and bottom left corners, there are only 3 neighbors

?

 

 

 

 

 

Note: Loops will greatly help you in most of these cases; however there still is a lot of nearly identical code that will seem tedious. It’s copy, paste, and modify for the most part.

 

 

Tips and Suggestions

 

Submission

 

Submission is done through the usual website. http://www.cs.pitt.edu/~jmisurda/submit/

 

Username: cs0004

Password: vbrocks

 

Remember to name them with your last name. If there isn’t a last name on the file or in the comment, I will be unable to grade it since I will not see you again (submission is after the final)