************************************************* * EXAMPLE OF INPUT VALIDATION AND A LOSING GAME * ************************************************* bash-4.1$ python proj3.py This program allows you to play Minesweeper. The object of the game is to flag every mine, using clues about the number of neighboring mines in each field. To win the game, flag all of the mines (and don't incorrectly flag any non-mine fields). Good luck! Enter the file to load the board from: board1.txt 1 2 + + + + 1 + . . + 2 + . . + + + + + There are 1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 0 That number is not allowed. Please try again! Enter a number between 1 and 2 (inclusive): 3 That number is not allowed. Please try again! Enter a number between 1 and 2 (inclusive): -1 That number is not allowed. Please try again! Enter a number between 1 and 2 (inclusive): 9 That number is not allowed. Please try again! Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: flag That's not a valid action. Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: Flag That's not a valid action. Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: F That's not a valid action. Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: why That's not a valid action. Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: dogs? That's not a valid action. Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: oh That's not a valid action. Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + F . + 2 + . . + + + + + There are 0 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 + + + + 1 + F . + 2 + . . + + + + + Field 1, 1 must be unflagged before it can be revealed There are 0 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + . . + 2 + . . + + + + + Flag removed from 1, 1 There are 1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 + + + + 1 + 1 . + 2 + . . + + + + + There are 1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 2 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 + + + + 1 + 1 X + 2 + . . + + + + + You detonated a mine! Game Over! ********************************************************* * EXAMPLE OF FLAGGING TOO MANY MINES AND A WINNING GAME * ********************************************************* bash-4.1$ python proj3.py This program allows you to play Minesweeper. The object of the game is to flag every mine, using clues about the number of neighboring mines in each field. To win the game, flag all of the mines (and don't incorrectly flag any non-mine fields). Good luck! Enter the file to load the board from: board1.txt 1 2 + + + + 1 + . . + 2 + . . + + + + + There are 1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + F . + 2 + . . + + + + + There are 0 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 2 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + F F + 2 + . . + + + + + There are -1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 2 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + F F + 2 + F . + + + + + There are -2 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 2 Please choose the column: Enter a number between 1 and 2 (inclusive): 2 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + F F + 2 + F F + + + + + There are -3 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 1 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + . F + 2 + F F + + + + + Flag removed from 1, 1 There are -2 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 2 Please choose the column: Enter a number between 1 and 2 (inclusive): 2 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + . F + 2 + F . + + + + + Flag removed from 2, 2 There are -1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 2 Please choose the column: Enter a number between 1 and 2 (inclusive): 2 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 + + + + 1 + . F + 2 + F 1 + + + + + There are -1 mines left to find Please choose the row: Enter a number between 1 and 2 (inclusive): 2 Please choose the column: Enter a number between 1 and 2 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: f 1 2 + + + + 1 + . F + 2 + . 1 + + + + + You won! Congratulations, and good game! ********************************** * EXAMPLE OF REVEALING AN ISLAND * ********************************** bash-4.1$ python proj3.py This program allows you to play Minesweeper. The object of the game is to flag every mine, using clues about the number of neighboring mines in each field. To win the game, flag all of the mines (and don't incorrectly flag any non-mine fields). Good luck! Enter the file to load the board from: board2.txt 1 2 3 4 5 + + + + + + + 1 + . . . . . + 2 + . . . . . + 3 + . . . . . + 4 + . . . . . + 5 + . . . . . + + + + + + + + There are 5 mines left to find Please choose the row: Enter a number between 1 and 5 (inclusive): 3 Please choose the column: Enter a number between 1 and 5 (inclusive): 2 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 3 4 5 + + + + + + + 1 + . . . . . + 2 + . . . . . + 3 + . 1 . . . + 4 + . . . . . + 5 + . . . . . + + + + + + + + There are 5 mines left to find Please choose the row: Enter a number between 1 and 5 (inclusive): 3 Please choose the column: Enter a number between 1 and 5 (inclusive): 1 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 3 4 5 + + + + + + + 1 + . . . . . + 2 + 1 1 . . . + 3 + 1 . . . + 4 + 1 . . . + 5 + 1 . . . + + + + + + + + There are 5 mines left to find Please choose the row: Enter a number between 1 and 5 (inclusive): 5 Please choose the column: Enter a number between 1 and 5 (inclusive): 5 Enter 'r' to reveal the space, or enter 'f' to mark the space with a flag: r 1 2 3 4 5 + + + + + + + 1 + . . . . . + 2 + 1 1 . . . + 3 + 1 . . . + 4 + 1 . . . + 5 + 1 . . X + + + + + + + + You detonated a mine! Game Over!