This is an implementation of the game battleships in Python 2. To run the game, simply run the file.
You will be prompted at the start, if you want to place your own ships or have a random board that you play with be created for you. The random board is the default for speed and testing's sake.
The game is completely played in the terminal and will print the tracking board and your own board to the screen.
Relevant comments in the code have been included to show what the code is doing and aid the understanding.
The functions are
- printing the boards to your screen
- creating a board
- converting characters to numbers
- placing the ships on the board
- define the shiplength
- test the placement of the ships and if it is valid
- creating a random board
- creating a random coordinate
- shooting
- a sunk ship function to show which boats are sunk
- a main function that controls the flow of the game.