Giter Site home page Giter Site logo

battleship's Introduction

BATTLESHIP

Purpose

Battleship is a classic board game (AxB grid) with the aim of guessing and shooting enemy ships.

This is a python project I worked on in high school as part of my overall grade. The aim was to recreate a simple game using concepts taught in class.

Directions

To play, simply download the .py and run it with your local version of python.

Alternatively, you can pull to your desired location using git:

 git pull https://github.com/yousefakbar/battleship.git

and launch it from there.

How to play

When launched, the game generates a 5x5 grid with letters for rows and numbers for columns. Here is what the grid looks like:

Image of example grid

When initiated, the game generates 5 ship locations and scatters them around the map.

Information about each grid element is stored in a 3-dimensional list. Information stored consists of co-ordinates, hit status, and ship_piece boolean value.

Status symbols: โ–ก = Available, X = Not Available, # = Ship.

The game is won when all 5 ship pieces are destroyed. You cannot lose :).

Concepts mastered in this project

  • RNG number generation
  • List functionality and manipulation
  • Usage of multi-dimensional lists as arrays
  • While loops as a simple basis for gameplay
  • Formatting print statements to display nicely

Enjoy!

battleship's People

Contributors

yousefakbar avatar

Watchers

James Cloos 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.