Battleship game in Python!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.3KB

Battleship!

Build Status codecov

Battleship game in Python:

  • 1 Player & 2 Player
  • Heavily tested
  • Can be used as an library (For instance it can be played via a REST API.)

Made with ❤ in pure Python.

Usage via CLI

The usage via CLI is pretty simple, you don’t even need to install anything. Simply get a clone of the code and run it from the root of the project.

$ python setup.py game

or install it first and then run via the binary:

$ python setup.py install # once finished, the battleship binary will be available to start the game
$ battleship # game will start ;)

Demo

Welcome to Battleship Game!
Enter 1 for one player or 2 for two player: 2
Please enter Player 1 name: Alireza
Please enter Player 2 name: Amir
Player Alireza turn!
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Guess Row: 1
Guess Col: 2
The hit was a miss!
Player Amir turn!
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Guess Row: 3
Guess Col: 4
The hit was a miss!
Player Alireza turn!
O X O O O
O O O O O
O O O O O
O O O O O
O O O O O
Guess Row: 2
Guess Col: 5
The hit was a miss!
Player Amir turn!
O O O O O
O O O O O
O O O X O
O O O O O
O O O O O
Guess Row: 5
Guess Col: 4
The hit was a miss!
Player Alireza turn!
O X O O O
O O O O X
O O O O O
O O O O O
O O O O O
Guess Row:

Development

To get a copy of the source code and start implementing:

  • $ git clone git@github.com:Alir3z4/battleship.git && cd battleship
  • $ pip install -r requirements-dev.txt

To run the game:

$ python setup.py game

Installing

To install the game simply clone the source code and run the install command:

  • $ git clone git@github.com:Alir3z4/battleship.git && cd battleship
  • $ python setup install

Tests

The implementation is well tested and all the tests can be run via:

$ python setup.py test

Code Coverage

To review the code coverage report run:

$ python setup.py coverage

It will generate the code coverage, printed on screen and saved in HTML format under htmlcov/ dir.

CI

On every push travis-CI will trigger the tests and report the code coverage.