Giter VIP home page Giter VIP logo

python-battleship-game's Introduction

Python Battleship Game

Battleship is a python terminal game, which runs in the code institute mock terminal on heroku, This game is made for single player against the computer in which user can win the game by guessing the exact location of ship hidden in the board.

project3

The deployed link can be found here: Live

Table of contents

Users stories:

As a player I want to set up the guess board using the matrix size.

  • Randomly generate a board.

As a player I want to select the row and column where I'm attacking.

  • select row, column and place 'X' if I missed the shot.
  • select row, column and place 'k' if I hit the target.

As a player I must have few turns to hit the target.

  • five turns are given to hit the target.

As a player I want to know who has won.

  • game over.
  • message of who win or lose.
  • message of "play again".

Back to top

How to play

This is a single player guessing game in which there will be the guess board with one ship hidden in the board and the user will have the five turns to hit the ship by guessing the location given in the board, If the user hit the ship 'k' symbol will be shown on the board with the message of winning and if the user missed the targets 'x' symbol will be shown on the board with the message that he has missed the target.

Back to top

Existing Features

  • Start the game

    • Only press Enter button will start the game.
    • Error message will display if you don't press enter button first.
    shot1
  • User Matrix_size selection

    • After input the username accurately
    • User can select the size of the matrix
    • User must input the valid integer
    • Error message will display if the user does not put the name accurately
    • Error message will display if the user does not input the valid integer
    • Error message will display if the user does not select the matrix size in range given
    shot2
  • Ship row and column selection

    • User must enter the valid row and column (integer) for the board
    • User must enter the input within the range given
    • User must not repeat the values for row and column
    • Error message will display if the user does not enter valid row and column
    • Error message will display if the user does not input within the range given
    • Error message will display if the user repeats the values for row and column
    shot3
  • Losing the game

    • If the user misses all his 5 guess shots
    • Then user will lose the game
    • A message will display of losing the game
    shot4
  • Winning the game

    • If the user selects the right row and column where the ship was hidden
    • Then user will win the game
    • A message will display of winning the game
    shot5
  • Restart the game

    • when the game finished there will be the question that 'Do you want to play again?'
    • If the user wants to play again then simply press 'Y' or 'y'
    • If the user wants to quit then press 'n' or 'N'
    shot6

    Back to top

Technology Used

Back to top

Features left to implement

  • In future, I am thinking about using the classes when creating the games
  • I will create the two players game or multiple players games in the future

Testing

I have manually tested this project by doing the following:

  • Passed the code through a PEP8 linter and confirmed there are no problems
  • Given invalid inputs: strings when numbers are expected, out of bounds inputs, same input twice
  • Tested in my local terminal and the Code Institute Heroku terminal

Validator Testing

Back to top

Bugs

solved bugs

 when I created the ship for the board, I assigned the value to the
 row and column to randomly generate the ship in the board like randint(0, matrix_size)
 but the bug was created and it generated the ship out of range to the matrix_size.
 I solved this bug by adding the minus one to the matrix_size like randint(0, matrix_size-1)
 and in this way bug was solved and ship was generated within the range of matrix_size 
 in the board.

Unfixed Bugs

  • No unfixed bugs.

Back to top

Colour

  • I imported the colours from library using the command 'from colorama import Fore, Style'
  • I used three colours red, green and blue for the text in the terminal.

Back to top

Deployment

This project was deployed using the code institute's mock terminal for heroku.

  • Steps for deployment:
    • Fork or clone this repository
    • Create a new heroku app
    • Set the buildpacks to Python and NodeJS in that order
    • Link the heroku app to the repository
    • Click on Deploy

Back to top

Credits

Content

  • The Idea of README.md file and the codes used for game were also learnt from Code Institute
  • Some codes used for game were taken from Stackoverflow
  • Some codes used for game were taken from this tutorial video Python battleship
  • Codes for colour were taken from pypi

Media

Acknowledgements

  • My mentor who supported me throughout the project.
  • Code institute for the deployment terminal.

Back to top

python-battleship-game's People

Contributors

shahery avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.