By: Team W14-3
Since: Jan 2019
Licence: MIT
1. Introduction
Ships ahoy! Battleship is a simple computer-based remake of the classic Battleship game.
It is for people who want to experience the joy of playing Battleships without the hassle and fuss of dealing with physical game pieces.
Battleship is optimised for people who want to use a Command Line Interface (CLI), while still retaining the benefits of a Graphical User Interface (GUI).
It’s a single-player game, and provides a fully functional computerised enemy player for the player to play against, guaranteeing many hours of fun! Can’t wait to get started? Head over to Section 2, “Quick Start” to fire away!
What is a Command Line Interface (CLI) and a Graphical User Interface (GUI)? A Command Line Interface (CLI) interacts with the user by accepting words that are typed in by the user. Conversely, a Graphical User Interface (GUI) interacts with the user visually. It uses icons and graphics to show the user what the program is doing. |
As you will see, Battleship is a hybrid application. It combines both a CLI and GUI, meaning that the user must type in commands but will see the changes caused by those commands graphically.
2. Quick Start
-
Ensure you have Java version
9
or later installed in your Computer. -
Download the latest
battleship.jar
here. -
Copy the file to the folder you want to use as the home folder for Battleship.
-
Double-click the file to start the app. The GUI should appear in a few seconds.
-
Type commands in the command box and press Enter to execute them.
e.g. typinghelp
and pressing Enter will open the help window. -
Initialise the map to a size between 6 to 10. eg:
init 6
. -
Deploy your battleships:
-
Deploy your aircraft carrier:
put n/aircraft carrier c/a1 r/h
-
Deploy your cruiser(s):
put n/cruiser c/c1 r/h
-
Deploy your destroyer(s):
put n/destroyer c/e1 r/h
-
-
Start the game:
start game
-
Shoot the enemy’s map at a specific cell. eg:
shoot a1
The game will go on until either party’s ships are totally destroyed.
Refer to Section 4, “Features” for details of each command.
3. Game Rules
This section will describe the game rules and how to play the classic Battleship game.
Goal
Sink all your opponent’s ships before they sink yours.
Captain, deploy ships!
Depending on the chosen size of the map, as specified through the init <map_size>
command,
you will be given different numbers of each ship.
The ships available are:
-
Cruiser: size 2
-
Destroyer: size 3
-
Aircraft Carrier: size 5
Depending on your map size, your fleet will have different numbers of each ship.
Ready, aim, fire!
After you have placed all your ships, enter begin
to start the battle.
You will always be given the first turn.
You may fire shots at the enemy map through the command shoot
, for example shoot a1
.
If the shot hits a ship, you may continue taking shots until they miss. Upon a miss, the turn will be handed over to the enemy. The same goes for the enemy - the enemy will take its shot automatically, firing until it misses, before passing the turn back to you.
Good Game!
Whoever is first to destroy all their opponent’s ships will be declared the winner.
Had fun? You can view the game statistics with the command stats
.
4. Features
This section will describe the features of the game in more detail.
Command Format
-
Words in
UPPER_CASE
are the parameters to be supplied by you e.g. ininit MAP_SIZE
,MAP_SIZE
is a parameter which can be used asinit 10
. -
Items in square brackets are optional e.g
put n/NAME [t/TAG]
can be used asput n/Destroyer t/bestship
or asput n/Destroyer
. -
Items with
…
after them can be used multiple times including zero times e.g.[t/TAG]…
can be used ast/alpha
,t/best t/captain
etc. -
Parameters can be in any order e.g. if the command specifies
n/NAME c/COORDINATES
,c/COORDINATES n/NAME
is also acceptable.
Pressing the ↑ and ↓ arrows will display the previous and next input respectively in the command box. |
Some commands can only be executed at some part of the game, e.g. |
4.1. General commands
This section describes commands that can be executed at any point of time during the game.
4.1.1. Viewing help : help
Opens a help window that displays this User Guide.
Format: help
4.1.2. Exiting the program : exit
Exits the program.
Format: exit
4.2. Preparation phase
This section describes the commands used in the preparation phase.
4.2.1. Initialising the maps : init
The init
command initialises both your map and the enemy AI’s map to the size that you specify. The size of the maps must be between 6 and 10, inclusive.
Format: init MAP_SIZE
Example: init 10
Figure 1 below shows how the maps will be displayed in the UI.
Throughout the course of the game, the cells in the map will change colour based on their status.
Cell statuses:
|
Figure 2 below shows which colour is used for each status.
4.2.2. Managing ships: put
, list
, listTags
4.2.2.1. Placing a ship on the map: put
Adds a ship onto your map. The coordinates specified is the position of the ship’s head.
Format: put n/NAME c/COORDINATES r/ORIENTATION [t/TAGS]
Examples:
-
put n/destroyer c/a1 r/vertical
-
put n/aircraft carrier c/b1 r/h t/tag1
The head of a ship is the top-most and left-most cell of the ship. When coordinates are specified in the put
command, it specifies the coordinates of the head of the ship, as shown in the figure below.
put
command refer to the coordinates of the ship head.The orientation of the ship can be horizontal
or vertical
. This may be shortened to h
or v
, respectively. The orientation of the ship must be specified.
When putting a ship on the map grid, you should specify the head coordinates such that:
-
The ship falls within the map grid.
-
The ship does not collide with another ship that is already on the map grid.
4.2.2.2. Listing all ships : list
Shows a list of all of your ships that have been deployed on the map. There are four ways of using the list
command:
-
List all ships:
list
. -
List ships that match certain tags:
list t/[TAGS]
. -
List certain ships:
list n/[NAME]
. -
List certain ships that match certain tags:
list n/[NAME] t/[TAGS]
Examples:
-
list
-
list t/blueFleet
-
list n/destroyer
-
list n/destroyer n/cruiser t/blueFleet t/greenFleet
The list will show the ship’s head coordinate, the ship’s orientation, and the ship’s tags in square brackets. The format of each entry in the list is: [NAME] [CURRENT LIFE] at [HEAD COORDINATE] [ORIENTATION] [TAGS]
. An example is given below.
Input: list n/destroyer t/blueFleet t/greenFleet
Output: destroyer (3/3) at g5 vertical [redFleet][blueFleet][greenFleet]
destroyer (3/3) at c3 horizontal [blueFleet][greenFleet]
4.2.2.3. Listing all tags: listTags
Lists all the tags that have been used to tag the ship deployed on the map.
Format: listTags
4.3. Battle phase
4.3.1. Beginning the battle: begin
Begins the battle against the computer enemy.
Format: begin
Alternative command: start
4.3.2. Shooting at a coordinate: shoot
Launches an attack against given coordinate on the enemy’s map.
Format: shoot COORDINATES
Alternative commands: attack
, fire
, hit
Examples:
-
shoot a6
-
attack b5
4.3.3. Retrieving game statistics: stats
Retrieves the gameplay statistics data displays them on a pop-up window.
Format: stats
5. Features Coming in v2.0
This section describes features that have not been implemented yet and are scheduled to be released in version 2.0.
5.1. Special map shapes
You will be allowed to use maps that are randomised in shape. This adds an extra layer of challenge and fun.
Both yourself and the enemy AI will not be able to place ships on the grey tiles. The enemy AI will also have a randomised map that will not be the same as your map. You will not be able to see the shape of the enemy map and can shoot grey cells which will be counted as a miss.
The image below shows an example of a randomised map.
5.2. Quick start
Randomly deploys the all of your ships onto the map and starts the battle.
Format: quickStart
5.3. Save and load pattern of deployed ships
Save and load the pattern that you used to deploy your ships.
Format: pattern i/OPTION p/PATTERN]
Examples:
-
pattern i/save
-
pattern i/load p/circle
5.4. Display high score across games
Display the high score across more than two games.
Format: stats highscore t/ATTRIBUTE
Examples:
-
stats highscore t/time
Display game data from the game that won in the shortest amount of time -
stats highscore t/accuracy
Display game data from the game with the highest accuracy.
6. Command Summary
Feature | Format | Purpose | Example |
---|---|---|---|
Attack |
|
Attacks a selected cell on the enemy map. |
|
Display manual |
|
Opens up the help guide window. |
|
Create map of size 6-10 |
|
Initializes the map grid. |
|
List ships |
|
Lists all available ships, optionally filtering by name and tag(s) |
|
List tags |
|
Lists all tags. |
|
Put ship on map |
|
Places a ship on the specified position on the map, optionally adding tag(s). |
|
View statistics |
|
Opens the Statistics window. |
|
Start battle |
|
Begins the battle. |
|