Skip to main content

A Battleship game using Python and Flask

Project description

BATTLESHIP GAME

Table of contents

Introduction

This is a Python implementation of the Battleship game, with a Flask UI.

Description

Players can place their ships on a board, and can play against an AI opponent (or multiplayer in a future iteration!), taking turns to sink eachothers ships until one or the other sinka all ships, declaring one side the winner!

There are 3 different versions of the game. One is a simple version, where you can attack ships on a predetermined board, giving coordinates in the terminal. The second is with an AI opponent, which can attack your board and you aim to destroy all the opponents ships before it destroys yours, which is also in the terminal. The third is the main game which can be played on the browser against the AI opponent.

Prerequisites

To install Battleship, you will need to have python installed. Download python here

  • Python 3.7 or higher

Installation

Flask is an external python library and so needs to be installed using pip.

  1. Type cd followed by a space in the command prompt window
  2. Drag and drop the battleship folder into the window and press Enter
  3. Type in pip install -U Flask to download flask

For more information check out the official flask documentation:

Getting started

To play the Battleship game, follow these steps:

  1. Type cd followed by a space in the command prompt window
  2. Drag and drop the battleship folder into the window and press Enter

Windows:

$ cd C:\Users\user\Downloads\battleship

MacOS:

$ cd /Users/username/Downloads/battleship
  1. Run the main application:
$ flask --app main run
  1. Open your web browser and navigate to http://127.0.0.1:5000/placement
  2. Click to place your battleships, with 'r' or 'R' to rotate the ships and start the game.

Testing

All tests are present in a tests folder where each file contains the keyword "test".

Pytest is an external python library and so needs to be installed using pip.

$ pip install pytest

You will also need to install these plugins:

$ pip install pytest-depends

$ pip install pytest-cov

To run the tests, use the following command:

Windows:

$ python -m pytest 

MacOS:

$ pytest

Details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Battleship_yousufaa-0.0.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

Battleship_yousufaa-0.0.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file Battleship_yousufaa-0.0.1.tar.gz.

File metadata

  • Download URL: Battleship_yousufaa-0.0.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.0

File hashes

Hashes for Battleship_yousufaa-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ee0f7cce5297b5d0d1a03a8186eb1ac1a726f70802676ba07a77b6b132a5e780
MD5 97a75ed8ad0c8b339423f4283de8b399
BLAKE2b-256 593e170568b70d0a64a9341d6d5fdbbc445402f5c2e55c31dfdcf27613cc8daa

See more details on using hashes here.

File details

Details for the file Battleship_yousufaa-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for Battleship_yousufaa-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16ff6685fedf29d1142862b3edfffd6bc40a68709d42a975bb9a49486ca460c9
MD5 fbfe123ea50d1120becfbbc871910670
BLAKE2b-256 f3fb9464f272fcbe17f209706c685df878279a61e799d0314d51a083e5be4a0f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page