Preparing for the Battleship program
Play Battleship in a 3 by 3 board and only two ships: two and three squares long with a partner:
Here is an example:
- Can you group the locations of the ships in categories?
The ships could be:- Vertical or Horizontal
- In a corner
- By the edges
- In the middle
If you found a ship at a location, what would be your next move based on the grouping mentioned above?
With a partner play multiple times in a 3 x 3 board. Then play with this hit:
Suggested labeling convention: rows by columns
A code snippet to help you print each location:
>>> 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 >>>
In pseudocode, write the next possible places that you might choose for the Hit above.
Homework:
Write the pseudocode to choose the next move when finding a hit in each of the four corners.