Giter VIP home page Giter VIP logo

battleship's Introduction

Battleship

Welcome to Battleship is a war ruby game played on ocean by two players. Each player gets the same number of battleships of a particular type placed on the battle area. Note: One player cannot see the other player’s battleship locations.

It take input from text file and display output on ruby console.

Requirement :

  • Ruby version (>= 2.1.0)

  • Bundler version (>= 1.14.6)

Steps :

  • Unzip battleship folder

    Unzip battleship

    cd battleship/

  • Resolve Dependencies

    run -> bundle install

  • Run Application

    ruby application.rb

Sample Input :

Enter area boundaries: 5 E
Type for battleship 1: Q
Dimension for battleship 1: 1 1
Location of battleship 1 for player A: A1
Location of battleship 1 for player B: B2
Type for battleship 2: P
Dimension for battleship 2: 2 1
Location of battleship 2 for player A: D4
Location of battleship 2 for player B: C3
Missile targets for player A: A1 B2 B2 B3
Missile targets for player B: A1 B2 B3 A1 D1 E1 D4 D4 D5 D5

Sample Output:

Player 1 fires a missile with target A1 which missed
Player 2 fires a missile with target A1 which hit
Player 2 fires a missile with target B2 which missed
Player 1 fires a missile with target B2 which hit
Player 1 fires a missile with target B2 which missed
Player 2 fires a missile with target B3 which missed
Player 1 fires a missile with target B3 which missed
Player 2 fires a missile with target A1 which missed
Player 1 has no more missiles left
Player 2 fires a missile with target D1 which missed
Player 1 has no more missiles left
Player 2 fires a missile with target E1 which missed
Player 1 has no more missiles left
Player 2 fires a missile with target D4 which hit
Player 2 fires a missile with target D4 which missed
Player 1 has no more missiles left
Player 2 fires a missile with target D5 which hit
Player 2 won the battle

Thanks! Piyush Awasthi

battleship's People

Contributors

piyushawasthi avatar

Watchers

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