Giter Club home page Giter Club logo

battleship2's Introduction

Battleship2

Build Status

Play the classic game of Battleship in this new and improved REPL version.

How to install it

  1. Install Ruby in your machine.
  2. Clone this repo
  3. Once you have your local clone, enter the following in your terminal:
$ cd battleship2
$ bundle install
$ ruby lib/battleship_runner.rb

And you're ready to play!

How to play

Setup

The game will ask you to create your own ships or use two by default (a 2 units-long Destroyer and a 3 units-long Submarine) and to enter the height & width of the board.

setup screenshot

Placing your ships

Enter coordinates to place your ships on the board. For the coordinates to be valid they have to be:

  • Equal to the length of the ship
  • Vertical or horizontal
  • Consecutive coordinates
  • Exist within the board
  • Do not overlap with other ships.

ship placement screenshot

Placing your shots

After placing all your ships you will be asked to enter coordinates for your shot. For the coordinates to be valid they have to:

  • Exist within the board
  • Be new coordinates. You can't shoot in the same place twice.

player shots screenshot

Reading the board

  • 'S' means there is a ship there. It will be visible in the 'Player Board'
  • 'M' means the shot was a Miss.
  • 'H' means the shot was a Hit.
  • 'X' means the ship has been sunk.
  • '.' it is a cell that has not been shot and does not contain a ship.

Winning

You have to sink all of your opponents ships before they do! Be careful! If the computer hits a ship, it will start shooting surrounding cells to try to beat you!

Built With

  • Ruby 2.4.1

Testing

All test are done with Minitest with an 80.53% code coverage (calculated with SimpleCov)

To run all tests, enter in your terminal:

$ cd battleship2
$ rake

To run a single test:

$ cd battleship2
$ ruby test/ship_test.rb

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.