Skip to main content

Battleship 🛥️

Simple Battleship game in Python.

This is a simple implementation with dynamic grid support (defaults to 10x10).

Challenge

Create an application to allow a single human player to play a one-sided game of Battleships against ships placed by the computer.

The program should create a 10x10 grid, and place a number of ships on the grid at random with the following sizes:

  • 1x Battleship (5 squares)
  • 2x Destroyers (4 squares)

The player enters coordinates of the form “A5”, where "A" is the column and "5" is the row, to specify a square to target. Shots result in hits, misses or sinks. The game ends when all ships are sunk.

Run

pip3 install battleship-py
python3 -m battleship

Commands

Name Description
HELP Prints an help message about the commands.
QUIT Quits the Battleship game.
DESTROY Destroys the game by shooting all the vessels.
PRINT Prints the current state of the game to console.
EMOJI Prints the emoji version of the state.
(X)(Y) Shoots the target at coordinate (eg: A5).

Build Automation

Build Status PyPi Status License

Metadata

Release files for battleship-py 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for battleship-py 0.2.2
File Size Uploaded
battleship-py-0.2.2.tar.gz 8.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for battleship-py 0.2.2
File Interpreter ABI Platform
battleship_py-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.5 kB

Release files / battleship-py-0.2.2.tar.gz

Download URL battleship-py-0.2.2.tar.gz
Size 8.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f820126ec469be1dce1858ebf65a59faefebdea13c87e790543ceac742e4d10f
BLAKE2b-256 checksum
How to use checksums
42559fbffcbe666f82e8102e9baacff1790d991830999e9154c902ef310bb3f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

Release files / battleship_py-0.2.2-py3-none-any.whl

Download URL battleship_py-0.2.2-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04e0a9deca4357894c8a65a94ff45ba85993bedd448bfe0a4aaa643cb2181a2a
BLAKE2b-256 checksum
How to use checksums
5c3b7e484a73373af911d280aa81175c5a8fc8f74794388267932dd6b5ade7c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.9.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.10.1 urllib3/1.26.13 tqdm/4.64.1 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.5 CPython/3.6.15

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page