🚢
Py-Battleship
Python125 lines· 
Original project by @robertlent — view source on GitHubReady when you are
Py-Battleship
Table Of Content
Description
Battleship is a Python command line game.
The player can choose the size of the grid, from 5x5 up to 15x15, and the ship will be randomly placed in that grid. The size of the grid also determines the number of turns the user gets, from 5 to 15.
The game handles incorrect entries and can be replayed repeatedly.
Installation
Download main.py, change to the directory where you downloaded the file and run it using python3 main.py
Py-Battleship is built with the following tools and libraries:
- Python
Usage
- Enter 'yes' or 'y' to start a new game
- Any input besides those two and 'no' or 'n' will be ignored
- You will be prompted to choose a number from 5 to 15, which sets the game board size and number of guesses to that number
- You will be prompted to choose a row number and then to choose a column number
- If either guess is less than 5 or more than the previously provided maximum, you will be prompted to choose a valid selection
- If you enter a row or column that you already guessed, you will be told such and you will have used a turn
- The game continues until you either make a correct guess or run out of guesses
- You will then be asked if you want to start a new game
GitHub
License
Pyodide-runnable
Yes - the top-level main.py is a pure-stdlib console game (os.system screen-clears were removed); battleship_v2 is also a stdlib-only CLI game.
battleship.py· Python 3.x
141 linesConsole· terminal