20
1 Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work with a partner, make sure you both turn in the lab, and make sure you include both names on the lab. Equally, note your partner’s name in canvas. Please be aware that if your partner flakes on you, you are still responsible for completing the lab and turning it in on time. To turn in: Screenshot of running code Code that compiles Your partner’s name (if you worked with a partner) Functions are scored as below, and then there are 24 points for getting everything working together as a game. Note that this lab took me about 3 hours to code. The rule of thumb is to double that time for students, but you’re probably more cognizant of your programming speed than I am, so plan accordingly. Contents Instructions: ...................................................................................................................................................................................... 1 Code: ................................................................................................................................................................................................. 2 Function Descriptions: .................................................................................................................................................................. 2 // getSize: (2 pts)....................................................................................................................................................................... 2 // makeBoard: ( 5 pts) ............................................................................................................................................................... 2 // printBoard: (5 pts)................................................................................................................................................................. 2 //placeBombs: (4 pts) ............................................................................................................................................................... 2 //placeCounts: (9 pts) ............................................................................................................................................................... 3 //makeVisibleBoard: (3 pts) ...................................................................................................................................................... 3 // printVisible: (3 pts) ................................................................................................................................................................ 3 //chooseSquare: (6 pts) ............................................................................................................................................................ 3 //addBomb: (5 pts) ................................................................................................................................................................... 4 //removeBomb: (4 pts) ............................................................................................................................................................. 4 //checkForWin: (7 pts) .............................................................................................................................................................. 4 //removeBoard: (5 pts) ............................................................................................................................................................. 4 //removeVisible: (3 pts) ............................................................................................................................................................ 4 /*Function Definitions: */ ............................................................................................................................................................. 6 /*Output */ ................................................................................................................................................................................... 6 Instructions: For this lab you’ll be creating the game, Minesweeper. Minesweeper is a game in which you’ve got a board with hidden bombs. As you choose squares, the number of bombs adjacent to the square is revealed. You can place bomb markers on the board where you think bombs are located. After you’ve placed a marker on the board where you think every bomb is, the game checks to see if you are correct. If you are, you

Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

1

Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work with a partner, make sure you both turn in

the lab, and make sure you include both names on the lab. Equally, note your partner’s name in canvas. Please be aware that

if your partner flakes on you, you are still responsible for completing the lab and turning it in on time.

To turn in: Screenshot of running code

Code that compiles

Your partner’s name (if you worked with a partner)

Functions are scored as below, and then there are 24 points for getting everything working together as a game.

Note that this lab took me about 3 hours to code. The rule of thumb is to double that time for students, but you’re probably

more cognizant of your programming speed than I am, so plan accordingly.

Contents Instructions: ...................................................................................................................................................................................... 1

Code: ................................................................................................................................................................................................. 2

Function Descriptions: .................................................................................................................................................................. 2

// getSize: (2 pts)....................................................................................................................................................................... 2

// makeBoard: ( 5 pts) ............................................................................................................................................................... 2

// printBoard: (5 pts) ................................................................................................................................................................. 2

//placeBombs: (4 pts) ............................................................................................................................................................... 2

//placeCounts: (9 pts) ............................................................................................................................................................... 3

//makeVisibleBoard: (3 pts) ...................................................................................................................................................... 3

// printVisible: (3 pts) ................................................................................................................................................................ 3

//chooseSquare: (6 pts) ............................................................................................................................................................ 3

//addBomb: (5 pts) ................................................................................................................................................................... 4

//removeBomb: (4 pts) ............................................................................................................................................................. 4

//checkForWin: (7 pts) .............................................................................................................................................................. 4

//removeBoard: (5 pts) ............................................................................................................................................................. 4

//removeVisible: (3 pts) ............................................................................................................................................................ 4

/*Function Definitions: */ ............................................................................................................................................................. 6

/*Output */ ................................................................................................................................................................................... 6

Instructions: For this lab you’ll be creating the game, Minesweeper.

Minesweeper is a game in which you’ve got a board with hidden bombs. As you choose squares, the number of bombs

adjacent to the square is revealed. You can place bomb markers on the board where you think bombs are located. After

you’ve placed a marker on the board where you think every bomb is, the game checks to see if you are correct. If you are, you

Page 2: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

2

win. If not, you lose. If, as you are playing, you accidentally choose to reveal a square where a bomb is located, you blow up

and lose. Note that you can also change your mind and remove a bomb marker from the board if you think you were wrong.

I have included a main function plus descriptions of the functions you are to write for this game. I’ve also included output from

my playing the game at the bottom of the lab.

You should place the function declarations above the main function, and the function definitions below the main function.

Note that I’ve also included some test code if you want to test your functions as you go.

Have fun!

Code:

Function Descriptions: * minesweeper.cpp * * Created on: Feb 20, 2020 * Author: Debra */ #include <iostream> #include <time.h> #include <stdlib.h> using namespace std; /*FUNCTION DECLARATIONS GO HERE!!!! */

// getSize: (2 pts)

// function getSize uses call by reference to modify the integer input parameter to a random

// number between 7 and 20 (not including 20). This will be the size of your board

// makeBoard: ( 5 pts)

// Function makeboard takes as input an integer: which is the length and width of the board

// (it's a square board). The function should create an integer matrix (a 2-d array) on the heap, fill

// matrix with 0s (that's the number, not the letter 'O') and return a pointer to the matrix

// printBoard: (5 pts)

// This method takes as input a pointer to a matrix (a 2-D function) of integers and an

// integer for the size (the length and the width - it's a square). It returns nothing.

// It should print out the matrix, only it should print a space instead of a 0 (in other words, I don't

// want to see a board of 0's - I'd rather just see blank spaces for the 0s).

// NOTE: to print out the board, I used tabs instead of endl's, e.g., cout << x << "\t";

// NOTE2: I also printed out the indices around the edges so the game would be

// easier to check when I was debugging, not to mention easier to play.

//placeBombs: (4 pts)

//This function takes as an input parameter a pointer to the 2-D matrix of integers (the board) and an

// integer (the size).

//It places size + 1 "bombs" randomly on the 2-D matrix. My bombs were the 9 value (because the board

// is a board of integers and that kind of looks like an upside down 'b'). It made sure that a bomb hadn't

// already been placed in the randomly selected place

Page 3: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

3

//on the board before placing it, and, if it had, it chose another spot to place the bomb

// NOTE: if you'd like to write a helper function for this, I'm okay with that.

//placeCounts: (9 pts)

//This function takes as input parameters a pointer to the 2-D integer matrix that is the board, an int

// representing the size of the board. It returns nothing.

//This function places the counts on the board - in minesweeper, when you select a square, that square

//becomes "visible" and should contain the numbe of "bombs" that are adjacent to that square. So, for

// instance, if the board was a 7 x 7 matrix with 8 bombs, it would look like this:

/*

* 0 1 2 3 4 5 6

0 9 9 1

1 2 2 1

2

3 1 1 1 1 1

4 1 9 2 2 3 9

5 2 3 9 2 9 9

6 1 9 2 2 2 2

*/

//This function calculates the number of adjacent bombs for each square on the matrix and places those

//counts on the matrix, making sure not to overwrite a bomb.

//Again, if you'd like to write a helper function for this one, feel free.

//makeVisibleBoard: (3 pts)

//This function takes as an input parameter the integer for the size of the 2-D matrix of characters that will

// be created in this function and returned from this function. The 2-D matrix will be initialized to all '-'

//This function is similar to the makeBoard function. It will be the board that is displayed to the user as

// the user plays the game (because you don't want the user to see all the bombs and counts)

// printVisible: (3 pts)

// Almost exactly like printMatrix (templates anyone??):

// This method takes as input a pointer to a matrix (a 2-D function) of Chars and an

// integer for the size (the length and the width - it's a square). It returns nothing.

// It should print out the matrix.

// NOTE: like with printMatrix, I printed out the indices around the edges so the game would be

// easier to check when I was debugging, not to mention easier to play.

//chooseSquare: (6 pts)

//This function takes as input parameters the pointer to the board matrix of ints, the pointer to the visible

// matrix of chars, and the size.

//It uses cout and cin to allow the user to choose a square (the x and the y position on the matrix

// respectively) and then sets the visible matrix at that square to be the value in the board matrix.

//This function returns a boolean - false if the square chosen was a bomb, and true otherwise.

//NOTE: the quick way to convert a single integer to a char is to do the following:

Page 4: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

4

//int x = 7;

//char c = '0' + x;

// now c holds '7' (not the int 7).

//addBomb: (5 pts)

//This function takes as input parameters the pointer to the visible matrix of chars, the size int, and a

pointer

// to the number of bombs found. It returns a boolean value (true if the number of bombs found is equal

// to size + 1, false otherwise.

//this function is allowing the user to choose a square where they think a bomb is and mark it as bomb in

// the visible matrix.

//It allows the user to choose a square, using cout and cin to get the x and y values, respectively, and then

//modifies that square in the visible matrix (I marked it with the '9' character, but you could make it be an

// X or anything you feel makes it obvious that you think there's abomb there. It then increases the third

// parameter by 1 (the pointer to the number of bombs found so far). It checks if the number of bombs

// found is equal to the total number of bombs and, if so, returns True. Otherwise it returns false

//removeBomb: (4 pts)

//This function takes as input parameters the pointer to the visible matrix of chars, the size int, and a

pointer

//to the number of bombs found. It returns nothing.

//this function is allowing the user to choose a square where they previously placed a bomb and unmark

the

//square.

//It allows the user to choose a square, using cout and cin to get the x and y values, respectively, and then

//modifies that square if it is a '9' (how I marked my bombs) to be a '-'. It also decreases the count of the

//number of bombs found.

//Note that it checks to make sure the user had previously marked that square as where they thought a

bomb

//was.

//checkForWin: (7 pts)

//this function takes as input the pointer to the board matrix of integers, the pointer to the visible matrix

//of characters, and the int size.

//It checks to make sure that each bomb in the board matrix has been marked as a bomb on the visible

//matrix. It returns a boolean value - true if all the bombs have been found, and false otherwise.

//removeBoard: (5 pts)

//This function takes as input parameters the pointer to the 2-D integer matrix that is the board, along

with the

// size integer, and removes the matrix from the heap. It returns nothing.

//removeVisible: (3 pts)

//This function takes as input parameters the pointer to the 2-D integer matrix that is the board, along

with the

Page 5: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

5

// size integer, and removes the matrix from the heap. It returns nothing.

/******************************END OF FUNCTION DECLARATIONS ******************************/ int main() { srand(time(NULL)); int size = 0; int bombsfound = 0; getSize(size); cout << "Size is " << size << endl; int **mat = makeBoard(size); //printBoard(mat, size); - for testing purposes placeBombs(mat,size); //printBoard(mat, size); - for testing purposes placeCounts(mat, size); //printBoard(mat, size); - for testing purposes char **visible = makeVisibleBoard(size); /* For testing purposes: */ printVisible(visible,size); chooseSquare(mat,visible,size); printVisible(visible,size); addBomb(visible, size, &bombsfound); printVisible(visible,size); removeBomb(visible, size, &bombsfound); printVisible(visible,size); checkForWin(mat, visible, size); /* End of testing */ char c; bool flag = true; char again = 'n'; while (flag) { printVisible(visible,size); cout << "Choose: A for choose square, B for add Bomb, C for remove bomb: " << endl; cin >> c; if (c == 'A' || c == 'a') { flag = chooseSquare(mat, visible, size); if (!flag) { cout << "YOU LOSE! YOU HIT A BOMB!!" << endl; printBoard(mat, size); cout << "\n\nDo you want to play again?" <<endl; cin >> again; } } if (c == 'B' || c == 'b') { if (addBomb(visible, size, &bombsfound)) { cout << "Bombs found: " << bombsfound << endl; cout << "You appear to think you've found all the bombs" << endl; cout << "Choose: D for check for Win, or C for remove bomb:" << endl;

Page 6: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

6

cin >> c; if (c == 'D' || c == 'd') { if (checkForWin(mat, visible, size)) { cout <<"YOU WON!!! WOO WOO!!!" << endl; printBoard(mat, size); } else { cout <<"Sorry, you were wrong. Boo hoo." << endl; printBoard(mat, size); } removeBoard(mat, size); removeVisible(visible, size); bombsfound = 0; flag = false; } cout << "\n\nDo you want to play again? (y or n)" <<endl; cin >> again; } } if (c == 'C' || c == 'c') { removeBomb(visible, size, &bombsfound); } if (!flag && (again == 'y' || again == 'Y')) { flag = true; bombsfound = 0; getSize(size); cout << "Size is " << size << endl; mat = makeBoard(size); //printBoard(mat, size); - for testing purposes placeBombs(mat,size); //printBoard(mat, size); - for testing purposes placeCounts(mat, size); //printBoard(mat, size); - for testing purposes visible = makeVisibleBoard(size); } } return 0; } /********************************FUNCTION DEFINITIONS GO HERE***************************************/

/*Function Definitions: */

/********************************OUTPUT OF GAME********************************************/

/*Output */

Size is 7

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

Page 7: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

7

2 - - - - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - -

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 8

Invalid square, try again:

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - -

Add bomb: choose square x(between 0 and 7): 4

Add bomb: choose square y(between 0 and 7): 6

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - - - 9

5 - - - - - - -

6 - - - - - - -

Remove bomb: choose square x(between 0 and 7): 4

Remove bomb: choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - -

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - -

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Page 8: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

8

Choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 5

Choose square y (between 0 and 7): 5

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - - - -

5 - - - - - 1 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 4

Choose square y (between 0 and 7): 4

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 - - - -

4 - - - - 1 - -

5 - - - - - 1 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 3

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - 3 2 - - -

4 - - - - 1 - -

5 - - - - - 1 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 2

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

Page 9: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

9

0 - - - - - - -

1 - - - - - - -

2 - - 3 - - - -

3 - - 3 2 - - -

4 - - - - 1 - -

5 - - - - - 1 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 1

Choose square y (between 0 and 7): 1

0 1 2 3 4 5 6

0 - - - - - - -

1 - 2 - - - - -

2 - - 3 - - - -

3 - - 3 2 - - -

4 - - - - 1 - -

5 - - - - - 1 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 0

Choose square y (between 0 and 7): 0

0 1 2 3 4 5 6

0 1 - - - - - -

1 - 2 - - - - -

2 - - 3 - - - -

3 - - 3 2 - - -

4 - - - - 1 - -

5 - - - - - 1 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 1

YOU LOSE! YOU HIT A BOMB!!

0 1 2 3 4 5 6

0 1 9 2 1 1

1 2 2 3 9 2 1

2 2 9 3 2 9 1

3 3 9 3 2 1 1

4 9 3 9 2 1 1

5 1 2 1 2 9 1

6 1 1 1

Do you want to play again?

y

Size is 7

0 1 2 3 4 5 6

Page 10: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

10

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - -

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - - -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 5

Choose square y (between 0 and 7): 5

0 1 2 3 4 5 6

0 - - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 0

Choose square y (between 0 and 7): 0

0 1 2 3 4 5 6

0 0 - - - - - -

1 - - - - - - -

2 - - - - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 1

Choose square y (between 0 and 7): 1

0 1 2 3 4 5 6

0 0 - - - - - -

1 - 0 - - - - -

Page 11: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

11

2 - - - - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 2

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 0 - - - - - -

1 - 0 - - - - -

2 - - 1 - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 2

Choose square y (between 0 and 7): 1

0 1 2 3 4 5 6

0 0 - - - - - -

1 - 0 - - - - -

2 - 0 1 - - - -

3 - - - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 1

0 1 2 3 4 5 6

0 0 - - - - - -

1 - 0 - - - - -

2 - 0 1 - - - -

3 - 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 0

0 1 2 3 4 5 6

0 0 - - - - - -

1 - 0 - - - - -

2 - 0 1 - - - -

3 1 1 - - - - -

Page 12: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

12

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 0

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 0 - 0 - - - -

1 - 0 - - - - -

2 - 0 1 - - - -

3 1 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 0

Choose square y (between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 - - -

1 - 0 - - - - -

2 - 0 1 - - - -

3 1 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 0

Choose square y (between 0 and 7): 4

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 - - - - -

2 - 0 1 - - - -

3 1 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 1

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 - - - -

2 - 0 1 - - - -

3 1 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

Page 13: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

13

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 1

Choose square y (between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 - - -

2 - 0 1 - - - -

3 1 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 1

Choose square y (between 0 and 7): 4

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 - - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - - 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Choose square y (between 0 and 7): 5

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - - -

4 - - - - - - -

5 - - - - - 2 -

6 - - - - - 1 0

Page 14: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

14

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 5

Choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - - -

4 - - - - - - -

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 4

Choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - - -

4 - - - - - - 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - - 1

4 - - - - - - 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 4

Choose square y (between 0 and 7): 5

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - - 1

4 - - - - - 2 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Page 15: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

15

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 5

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 - - - -

3 1 1 2 - - 3 1

4 - - - - - 2 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 2

Add bomb: choose square y(between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 - - -

3 1 1 2 - - 3 1

4 - - - - - 2 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 2

Choose square y (between 0 and 7): 4

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 - - 3 1

4 - - - - - 2 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 3

Choose square y (between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 - - - - - 2 0

6 - - - - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Choose square y (between 0 and 7): 2

Page 16: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

16

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 - - - - - 2 0

6 - - 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 5

Choose square y (between 0 and 7): 0

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 1 - - - - 2 0

6 - - 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Choose square y (between 0 and 7): 0

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 1 - - - - 2 0

6 0 - 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Choose square y (between 0 and 7): 1

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 1 - - - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 5

Choose square y (between 0 and 7): 1

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

Page 17: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

17

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 1 1 - - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 5

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - - - - - 2 0

5 1 1 2 - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 4

Add bomb: choose square y(between 0 and 7): 1

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - 9 - - - 2 0

5 1 1 2 - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 4

Choose square y (between 0 and 7): 2

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 - 3 1

4 - 9 2 - - 2 0

5 1 1 2 - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 4

Choose square y (between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

Page 18: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

18

3 1 1 2 3 - 3 1

4 - 9 2 3 - 2 0

5 1 1 2 - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 3

Add bomb: choose square y(between 0 and 7): 4

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 9 3 1

4 - 9 2 3 - 2 0

5 1 1 2 - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 4

Add bomb: choose square y(between 0 and 7): 4

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 9 3 1

4 - 9 2 3 9 2 0

5 1 1 2 - - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 5

Add bomb: choose square y(between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 9 3 1

4 - 9 2 3 9 2 0

5 1 1 2 9 - 2 0

6 0 0 1 - - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 6

Choose square y (between 0 and 7): 3

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 9 3 1

4 - 9 2 3 9 2 0

Page 19: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

19

5 1 1 2 9 - 2 0

6 0 0 1 2 - 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 6

Add bomb: choose square y(between 0 and 7): 4

0 1 2 3 4 5 6

0 0 - 0 0 1 - -

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 9 3 1

4 - 9 2 3 9 2 0

5 1 1 2 9 - 2 0

6 0 0 1 2 9 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

a

Choose square x (between 0 and 7): 0

Choose square y (between 0 and 7): 6

0 1 2 3 4 5 6

0 0 - 0 0 1 - 1

1 - 0 1 1 3 - -

2 - 0 1 9 3 - -

3 1 1 2 3 9 3 1

4 - 9 2 3 9 2 0

5 1 1 2 9 - 2 0

6 0 0 1 2 9 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 2

Add bomb: choose square y(between 0 and 7): 5

0 1 2 3 4 5 6

0 0 - 0 0 1 - 1

1 - 0 1 1 3 - -

2 - 0 1 9 3 9 -

3 1 1 2 3 9 3 1

4 - 9 2 3 9 2 0

5 1 1 2 9 - 2 0

6 0 0 1 2 9 1 0

Choose: A for choose square, B for add Bomb, C for remove bomb:

b

Add bomb: choose square x(between 0 and 7): 0

Add bomb: choose square y(between 0 and 7): 5

Bombs found: 8

You appear to think you've found all the bombs

Choose: D for check for Win, or C for remove bomb:

d

YOU WON!!! WOO WOO!!!

0 1 2 3 4 5 6

0 1 9 1

1 1 1 3 2 2

Page 20: Lab2: Minesweeper - University of Delaware · Lab2: Minesweeper (85 pts, Due Sunday, Mar 1, midnight) Note: you may work with a partner or you may work alone. If you choose to work

20

2 1 9 3 9 1

3 1 1 2 3 9 3 1

4 1 9 2 3 9 2

5 1 1 2 9 3 2

6 1 2 9 1

Do you want to play again? (y or n)

n