In this assignment you will write a program to let you play the Black Box "game." Although called a game, Black Box is actually a kind of puzzle, where the computer sets up the puzzle, and you try to solve it, by figuring out where things are inside the "box".
Wikipedia has a good description of the game.
The basic idea is this: The computer "hides" four atoms somewhere on an 8x8 grid. You, the player, try to figure out where the balls are by shooting in "rays" from any of the 32 positions along the sides of the grid (8 on each side, including the top and the bottom), and seeing where the ray comes out, or if it comes out at all. For each ray you send in, there are three cases:
afor the first time it occurs,
bfor the second time,
cfor the third time, etc. There is no need to mark which is the entry and which the exit.
| If the game board looks like this*:
|| You could represent it like this:
Or like this:
Or like this:
|This is how the board prints out initially:||This is what it might look like after shooting in a few rays:|
8, followed by a letter
Tfor top, and
Bfor bottom. (Also allow lowercase letters
b.) In the second picture above, rays have been shot in from
H). To mark a location, the user should enter a row number followed by a column number, such as
4 4) in the above example. Do not limit the user to four marks.
4 4in the above example is correct, that will be 30 points for the three atoms that haven't been marked.
The game board should be printed out after each user input, showing the effects of shooting rays, and the markers that the user has placed. After scoring the game, the program should tell the user where the atoms are actually hidden, preferably with a similar kind of output.
Normal people don't start counting with zero. Only programmers do that.
So when you print the board, you should add 1 to all the row numbers and
all the column numbers, and when you get row or column numbers from the
user, you should immediately subtract 1 from them. Inside the program
we'll use 0 to 7, not 1 to 8.
After each game, the program should ask the user whether he/she wants to play again.
new_game(location1, location2, location3, location4)
(row, column)tuple. Row and column numbers are
7. Clears any leftover data from any previous game. Returns
entryis a string using the same syntax that a user would type in (
'1L', etc.). Returns the exit point of the ray in the same syntax, or
Nonein the case of a "hit."
togglemarks where the user thinks the atoms may be; it does not affect where they actually are.
At the end of your Python program (after all your function definitions), insert the following lines:
if __name__ == "__main__": main() # or whatever your starting method is
Turn in your one zip file to Canvas by 6am Wednesday, September 30.
Notes on submitting your work:
* "BlackBoxSample1" by Life of Riley - Own work. Licensed under GFDL 1.2 via Commons -https://commons.wikimedia.org/wiki/File:BlackBoxSample1.svg#/media/File:BlackBoxSample1.svg