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:
- 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.
- We will still have 4 types of ships, but in addition to the symbol, they have some
characteristic differences as well.
- Airplane carrier (A) - takes up 4 consecutive cells in a row or a column. The
ship is destroyed when all 4 cells are hit. Earns 125 points if destroyed, as before.
- Destroyer (D) - takes up 2 consecutive cells in a row or a column. This ship
is destroyed when both cells are hit. Destroying a destroyer earns 50 points as before.
- Submarine (S) - takes up 2 consecutive cells like the destroyer, but it is
destroyed with one single hit on either of the cell. Destroying a submarine earns
75 points as before.
- Warship (W) - takes up 3 consecutive cells, and is destroyed when 2 of the
three cells have been hit. Destroying a warship earns 100 points as before.
You should use inheritance to implement different types of ships in this assignment.
- 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.
- 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).
- 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:
- Point your web browser to https://www.indiana.edu/~s420/handin.html
(notice the https instead of http - this indicates your
information is sent through a secure server). If your browser asks if
you want to display the non-secure items, say Yes.
- Type in your email address (including the @indiana.edu part) and
your 10 digitstudent ID without any dashes or spaces in the appropriate
boxes.
- Upload the two files for submission in the two fields
provided by clicking on the Browse button and selecting the
appropriate file. If you are using steel to write your code, you
will need to download the java files from steel to the machine
where you are using the web browser. Submit only the .java
files. No class files. Follow the namig convention as stated in
the assignment. If you have created other java files that you
need to submit, you can use the third box, or submit them after
you submit the first two files. Your submission is cumulative,
so you will see all files in the submission so far after your
second submission.
- Click on "Submit Assignment", and wait until you get the
confirmation page. This may take a couple of minutes - do not
click multiple times. The system will display a confirmation
page.
- You are not done yet! Check your email for a confirmation
email from the submission system. It may take upto 5 minutes for
you to receive the confirmation email. Make sure you read
and understand the email, including the information that it
gives you. Do not assume that your assignment submission was
successful until you receive an email with no error
message. Look in particular for the file "CompilationErrors". If
it says "Empty file!" for this, you are fine. If any compilation
errors are shown, you will need to fix them. Your assignment
will be severly penalized if you have compilation errors.
- You may submit as many times as you would like - future
submissions will overwrite any file submitted with the same
name. If you change only one file, you can submit only that
file. The confirmation message will include all files submitted
so far. Keep a copy of the confirmation message. This will be
proof that your submission was successful in the case of a
system glitch later.