A super cool, fun, and easy to play command line implementation of Battleship, the classic 2-player guessing game. Built in JavaScript, battleship-cli
is a simple NodeJS program, with CLI interface enabled by InquirerJS, and colorized by chalk.
- Node
- With NPM*:
npm install -g battleship-cli
- With Yarn*:
yarn global add battleship-cli
- Manually (for hacking):
- clone repo
- run
npm install
oryarn install
to install dependencies - run
npm i -g
to make the module available globally
- To play:
- In your favorite terminal, simply run the
battleship
command from any directory - For the best experience use a terminal that has full color and emoji support
- In your favorite terminal, simply run the
*Note: If anything except version 1.1.0
gets pulled down, please explicitly install the correct version instead by appending @1.1.0
to either command.
Type help
and hit return at any time during gameplay to show these instructions.
- Type
show score
at any time to check the status of the game. - Type
quit
orq
at any time to quit the game.
- NOTE: If your terminal does not support Emojis, please disable Emojis in the settings menu.
- For a more challenging game, you can choose a larger board size.
- You can also adjust the computer's skill level.
- Each player has a battlefield represented by a 10x10 grid on which they place 5 ships, hidden to their opponent.
- The goal of the game is sink all of your opponents ships! A ship is sunk when it is hit once for each space it occupies.
- In other words, a submarine, which occupies 3 spaces, is sunk after being hit 3 times.
- The 5 ships occupy 17 total spaces, so the first player to register 17 hits wins!
- To play, follow the prompts to configure your five ships in any pattern you'd like (diagonal placements are not allowed).
- Valid configuration instructions include a ship name, a starting coordinate (A1-J10 for default 10x10 board), and a direction (right, left, up or down).
- For example:
submarine e3 up
orcarrier j7 left
. Ships cannot overlap, and you must stay within the bounds of the board. - Once both players have configured their ships, the race is on to sink your opponent's ships before they sink yours!
- Fire torpedoes at your opponent's ships by guessing coordinates on the 10x10 board.
- Rows are represented by the letters A-J, and columns with the numbers 1-10 (10x10 board).
- Valid guesses include a row followed by a column, e.g.
A1
,B7
,J10
, etc. - You will be informed if you've hit, missed, or sunk a ship.
- Sink all 5 of the computer's ships to win!
- When placing ships, you can also use abbreviations to make your life easier!
- Use the ship's abbreviations (see legend), and single letters for directions.
- e.g.
btl a9 r
orcru i6 u
- Battleship (BTL), 4 spaces
- Carrier (CAR), 5 spaces
- Cruiser (CRU), 3 spaces
- Destroyer (DST), 2 spaces
- Submarine (SUB), 3 spaces
- A hit looks like 💥 or
X
(depending on Emoji support) - A miss looks like ❌ or
0
(depending on Emoji support)