Introduction:Battleship is a two player game of sea warfare. You and your opponent each place 5 ships on the board, and you then alternate "firing" torpedoes at each others ships. The game is won when one player has destroyed/sunk all of the other players ships.Setup:Each player has two 10x10 boards to use, the ship board and the target board. The ship board is used to initially position your ships and record where the enemy has guessed. The target board is used to keep track of where you have guessed, and what the outcome of each guess was.To setup the board, each player must place his five ships on the ship board. The ships have different sizes and can be placed either horizontally or vertically. The five ships are: For a two player game, each player would set up his own ship
board. Since your opponent for this assignment will be the computer,
you should set up your own board, and have the computer randomly place his
five pieces (legally of course).
Playing the game:You play the game by each player calling out positions on the board and having the opponent tell them whether the position was a "hit" or "miss". You respond with "hit" if the position your opponent called out coresponds to a position on your ship board with a ship on it, otherwise, your respond "miss". A position on the board is indicated by a row and a column. The row is a letter between "A"and "J"and the column is a number between "0"and "9"(really 1-10, but it will be easier if you use 0-9). The process of "firing" at the opponent is repeated until all the ships of one player have been sunk. Also every time one of your ships is sunk, you must tell your opponent which ship was sunk.Your program should take care of detemining the correct response of each
move such as "hit", "miss" or "you sunk my battleship".
Also, since your opponent is the computer, it should automatically make a
move on its turn at a position that it hadn't guessed before.
Winning:As stated before, the game is over when one player has sunk all the opponents ships.If you are still unclear about the rules of the game you can play a sample game.Use this sample game as your guide to implementing a correct battleship. |
(Last modified: 12/02/97)