S428/S528

Assignment 3 - Part 2 (Group Assignment)

Due Thursday, Mar 24, 2005 before class

The Battleship game - Advanced version

In this assignment, you will need to complete your implementation of the Battleship game to a full version, more like the actual game, where you can use strategies for placing your ships, and strategies for firing, and ships now can take up more than one cell.

Description

As before, the basic objective of the game stays the same, with the following new features and differences:

  1. Because of larger ships in this assignment, we are going to use a bigger grid (10x10) and smaller number of ships (3 of each). This still makes the placement complex, since 33 of the 100 cells are filled. You should still try to parameterize the grid size and number of ships.
  2. We will still have 4 types of ships, but in addition to the symbol, they have some characteristic differences as well. You should use inheritance to implement different types of ships in this assignment.
  3. Initial positioning: One of the challenges in this assignment is the initial positioning. Remember that you must place the ships so that they don't go over one another. You are welcome to come up with any kind of strategies you want, as long as your strategy comes up with somewhat different positioning of the ships.
  4. Hit reporting: Now, since some ships may not be destroyed in one hit, the report should say how many hits and how many destroyed. A destroyed ship will not be reported as a hit. So if you hit two ships and one is destroyed, you should report 1 hit and 1 destroyed. (Of course, a submarine is destroyed when its hit, so its not necessary to ask for hits on submarines).
  5. Firing strategies: You can go as intelligent on firing as you want, or just simply fire at random - its up to you, as long as you make sure you don't fire at the same place twice, since that doesn't gain you anything

Once again, follow last assignment's conventions - you can start or the opponent can start. Make sure all classes are appropriately tested. Document all classes and methods using the Javadoc syntax.

What to submit: You will need to create a word document called Battleship.doc with the class diagram for your assignment. You only need to have the class diagram, and not any sequence diagrams. However, the class diagram must be complete, it should have all the classes, and their attributes and methods, and the associations between them. This will count for 25% of your points, and even if your code does not work, a good class diagram will make you elligible for partial credit.

I/O Convention: Here is a sample

C:\>java Battleship
Usage: java Battleship [self|opponent]
C:\>java Battleship opponent
Setting up my board..
My board is:
  0123456789
0 S..DD.....
1 S.W..S....
2 ..W..SAAAA
3 ..W...AAAA
4 .....DD...
5 ....SS....
6 AAAA..W...
7 ...DD.W...
8 ......W...
9 .....WWW..

Opponent's turn. 

Opponent's move: 
shot 1 (x): 3 
shot 1 (y): 6 

Opponent hits: A
Opponent destroys: X
Opponent's score is 0
My remaining ships: A: 5, D: 5, S: 5, W: 5. 

My board is:

  0123456789
0 S..DD.....
1 S.W..S....
2 ..W..SAAAA
3 ..W...XAAA
4 .....DD...
5 ....SS....
6 AAAA..W...
7 ...DD.W...
8 ......W...
9 .....WWW..


My turn.
My move is: (1,1) 

My hits: W 

I destroyed: X 

My score is: 0 
Opponent's remaining ships: A: 5, D: 5, S: 5, W: 5. 

Continue playing? yes

Opponent's turn. 
Opponent's moves: 

....

Opponent's remaining ships: A: 0, D: 0, S: 0, W: 0.

Opponent's ships are all destroyed, I win!
My score is: .... Opponent's score is: ....

Submission method You will need to submit your assignment using the online submission system. To submit, use the following steps: