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.
- Type cd followed by a space in the command prompt window
- Drag and drop the battleship folder into the window and press Enter
- 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:
- Type cd followed by a space in the command prompt window
- 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
- Run the main application:
$ flask --app main run
- Open your web browser and navigate to http://127.0.0.1:5000/placement
- 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
- Authors: Yousuf Ahmed Linkedin
- License: This project is licensed under the MIT License - see the LICENSE file for details.
- Source: GitHub Repository
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee0f7cce5297b5d0d1a03a8186eb1ac1a726f70802676ba07a77b6b132a5e780 |
|
MD5 | 97a75ed8ad0c8b339423f4283de8b399 |
|
BLAKE2b-256 | 593e170568b70d0a64a9341d6d5fdbbc445402f5c2e55c31dfdcf27613cc8daa |
File details
Details for the file Battleship_yousufaa-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: Battleship_yousufaa-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16ff6685fedf29d1142862b3edfffd6bc40a68709d42a975bb9a49486ca460c9 |
|
MD5 | fbfe123ea50d1120becfbbc871910670 |
|
BLAKE2b-256 | f3fb9464f272fcbe17f209706c685df878279a61e799d0314d51a083e5be4a0f |