GithubHelp home page GithubHelp logo

battleship_101's Introduction

Battleship 101 Game

Introduction

This game is the single-player battleship game, we have made used of grids. Each ship occupies a number of consecutive squares on the grid, arranged either horizontally or vertically. The number of squares for each ship is determined by the type of ship. The ships cannot overlap (i.e., only one ship can occupy any given square in the grid). This grids consists of a minimumof 5 rows and maximum of 26 rows and A-Z columns of the battleship where you can destroy and sink the ships.

Our main goal

The game is a discovery game which players need to discover their opponents ship positions.

https://battleship-101.herokuapp.com/

ImageHere

How it works

  • A grid size has been set to a minimum of 5 and maximum of 26
  • Players can choose the grid size they want to play
  • Players can also choose the number of bullets to be shot
  • You can choose a row and column such as B5 to indicate where to shoot
  • For every shot that hits or misses it will show up in the grid
  • If all ships are unearthed before using up all bullets, you win else, you lose and it's game over!

Features

  • Define the pattern grid
    • we defined a hidden grid of size 10
    • we defined a guess grid of size 10
    • we used a letter A-Z and numbers to form the grid

    ImageHere

  • The Create Ship Function
    • from random we import randint
    • we use the for loop function to create the number of our ships
    • The ship row is the number [1-100]
    • the ship column is the alphabet [A-Z]
    • the randint randomly assigns values to the ship row and column
    • the while loop function continues until the grid row and column is X
    • The grid will get the values ‘X’ once the hidden pattern and guess pattern hits the same ship

    ImageHere

  • Define Print Grid
    • the function print the column grid from A-J
    • prints the row number ".|" symbol for each row on the grid

    ImageHere

  • Function for ship location
    • this validates the row number and column
    • return the function row less by 1 than the value provided and let_to_num[column]

    ImageHere

  • Function for counting ships
    • the count is assigned 0
    • for each row on the grid and each column in the row if the column ==’X’ the count increases by 1 and returns the count
    • the function counts the number of ships hit and sunk.

    ImageHere

  • The run all function
    • we called the function create_ship that creates the ship
    • The print_grid (Guess_Pattern) creates the guess_pattern grid.
    • if the guess_pattern == ‘-‘ then it prints “You have already guessed”.
    • If the hidden patterns Hidden_Pattern[row][column] == ‘X’: then it prints ‘ Congratulations you have hit the battleship’
    • If the count_hit_ships and the guess_pattern are exactly same i.e 5 then it will print “Congratulations you have sunk all the battleships”
    • Once the turns value becomes zero the program will print “ Game over”.

    ImageHere

Testing

I have manually tested this project by doing the following:

  • I passed the codes through a PEP8 and confirmed there are no errors
  • It gives valid input, strings and float numbers are not allowed.
  • Tested in my local terminal and the Code Institute Heroku terminal

Bugs

  • At the point of deplomyent to Heroku, I could not connet to git connect, i was getting 'internal servive error'. However i was able to deploy through git CLI

Validator Testing

  • PEP8
    • No errors were returned from pep8online.com

Technology Used

  • run.py
  • Heroku

Deployment

  • Steps for Deployment
    • Create a new app
    • Set my config vars to store my sensitive data
    • Set the buildbacks to Python and NodeJS in that order
    • Click on deploy

Credits

battleship_101's People

Contributors

kiksgold avatar

Watchers

 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.