Preparing for the Battleship program
Classwork:
You can start working on the Battleship pygame program or you can choose to write a few programs to handle individual scenarios. Gradually, you will have the final version of the program.
Battleship development by parts:
Write a program, Corners4_YI.py to handle the following scenario:
– a hit is found on one of t the corners on the 3 x 3 board and based on the user’s response write the code to find the ship and sink it.
The idea at every scenario is to find a pattern so you can minimize the code and reuse it.
– Use a list of three lists with 3 items each.
– Randomly select the corner where the program will place the ship.
Application’s Logistics:
Your program should only maintain as a minimum two boards:
1. The computer’s calls of the player’s ships locations.
2. The player’s guesses as either M(issed) or H(it).
Minimum requirements:
Display one board using pygame: either a or b
a. A board with the computer’s guesses with blue if it is a Miss or yellow and a portion of a ship if it is a Hit.
b. A board with the player’s guesses with blue if it is a Miss or yellow and a portion of a ship if it is a hit.
Some suggestions:
>>> listoflists=[['A','B','C'],['D','E','F'],['G','H','I']] >>> for i in range(len(listoflists)): for j in range(len(listoflists[0])): print(listoflists[i][j],end=' ') print() A B C D E F G H I >>>