Introduction to Computer Science II by James Tam Return to the course web page

CPSC 233: Assignment 5 (Worth 8%)

 

 

Due Friday March 26

Extending the original Star Trek © Paramount game

Your mission for this assignment

You are to take your code from the previous assignment and to augment it by implementing special classes of ships that extend the basic StarShip class from the first assignment.  In the full version of the game the human player will control a Federation star ship while the computer controlled ships will include ones from: the Klingon empire, the Dominion and the Borg.

The Federation

The United Federation of Planets (or the Federation for short) is an egalitarian union of hundreds of different species and cultures.  To bring together such a large and diverse number of races under one governing body requires that something other than combat is used to settle differences of opinion.  One of the two founding races of the Federation and perhaps the most ubiquitous are humans.   Most humans are an equal parts of explorer and diplomat and provide the glue that holds the Federation together.   Their ships are well equipped with defensive and offensive weapons that are designed not to start a conflict but to end them.

WHY is this man SMILING!? (Amok)
The federation is a peaceful union of numerous races.  "To seek out new life, to explore new worlds."

The Klingon Empire

This warrior race has a genetic predisposition to hostility and a well-known streak of fatalism.   Klingons are also famous (or perhaps infamous) for their get-togethers in which a great deal of growling, wrestling, snarling where generally a lot of extroverted revelry takes place.   If you look beyond their boisterous and rather loud exteriors the Klingons are perhaps the most noble race of all: they hold honour above their own life.  Klingon ships are designed with powerful offensive capabilities that suit their aggressive natures.

A young Klingon warrior wielding a Bat'leth.  "Kapla!" (Success!)

The Dominion

The Dominion is a mighty planetary alliance composed of  several hundred dominated races led by a race of shape shifters (know as the "Founders"), administered by devious and cloned race (the "Vorta") and defended by a genetically bred race of soldiers (the "Jem'Hadar").  The founders are the dominion and dominion is the founders.  Their goals are simple: the imposition of (their) order on the galaxy.  Much like Klingon warships, the ships of the Dominion are built for a fight.

A Jem'Hadar soldier on guard. "Victory is life!"

The Borg

They are a cybernetic life-form which is part organic, part artificial life with a singular unifying goal, the consumption of useful technology.  They do this by "assimilating" other species (i.e., turning them into Borg) which they claim will, "..raise the quality of life for that species."1 The Borg skill at assimilating new technology allows their ships to adapt their defensive systems which will reduce the effectiveness of some enemy attacks over time.  Each attack on a Borg ship allows them to assimilate more information about the energy used in the attack which allows the Borg to adapt their defences to the attack.  In addition the Borg are not native to quadrant (quarter) of the galaxy where the Federation is situated: only the advanced Borg propulsion systems in their ships have made contact between humans and the Borg possible.

An attacking Borg drone. "You will be assimilated."

 

Grading: Working submissions

Some of the new classes needed for this assignment

  1. FederationStarShip
  2. KlingonAttackCruiser
  3. JemHadarBattleship
  4. BorgCube

Basic submission (C-):  

Required functions from Assignment 4

Extra function for Assignment 5

Menu option

Effect

Invulnerability (option 'I')

  • The player's ship becomes immune to all attacks until the player invokes the cheat menu again and turns off invulnerability mode.

Invoke the quantum slip stream drive (option 'S')

  • A very high speed means of travel allowing the player's ship to move to any unoccupied sector in the galaxy.

  • When invoked the program will prompt the person to enter the destination row, column values and if the sector is unoccupied the player's ship will move to the new sector. 

  • This is a separate means of propulsion from the regular engine and conceivably both can be invoked during a turn e.g., during the movement phase the player moves on sector using the warp drive while for the attack phase the player invokes the slip stream drive and moves to yet another sector.

Fire the photonic cannon (option 'P')

  • The player's ship discharges a high-energy burst that will totally destroy any ship anywhere in the galaxy (except for the player's ship of course). 

  • The weapon is not automatically fired during the regular attack phase, the player must enter cheat mode and select the 'P' option each time that he or she wishes to employ this weapon.

  • The firing of the photonic cannon is independent of the firing of the other weapon(s).  If the player invokes cheat mode during the movement menu and fires the photonic cannon, the phasers and the quantum torpedo (for the latter weapon refer to the description of the Federation star ship) can also be fired during the attack phase.

Extra features

  1. Implement the code for a Federation star ship (worth 2 letter steps).    You are to implement a new class, "FederationStarShip", that extends class "StarShip".  This ship will replace the basic star ship that was controlled by the human player in the fourth assignment.  The Federation star ship has all the features of the basic star ship except:

 

0

1

0

 

C

1

F

C

2

 

 

 

Computer-controlled ship at (0,1)

Ship's system

Point value

Shields

2150

Hull

400

 

Computer-controlled ship at (1,1)

Ship's system

Point value

Shields

4000

Hull

400

The person controlling the Federation ship chooses to fire the quantum torpedo at the first ship and enters (0, 1) for the (row, column) value.  Next comes the targeting of the phasers.  Although the player can (and probably should) attack the same ship he or she is not required to do so and in this example enters (1, 1) for the (row, column) value and inflicts 880 points of damage on the shields of the second ship.  After this combat phase the computer-controlled ships end up at the following state:

Computer-controlled ship at (0,1)

Ship's system

Point value

Shields

0 (down)

Hull

400

 

Computer-controlled ship at (1,1)

Ship's system

Point value

Shields

3120

Hull

400

 

A Sovereign class star ship.

When debug mode is turned on the program should show the shield value of the targeted enemy before the torpedo was fired (point value before being hit by the torpedo) and the shield value after it was fired (it should now be zero).

  1. Implement the code for a Jem'Hadar battleship (worth 1 letter step).  You are to implement a new class "JemHadarBattleship" that extends class "StarShip".  This ship will replace one of the 3 computer-controlled star ships from the game you wrote for the fourth assignment.  The Jem'Hadar battleship has all the features of the basic star ship except:

A Jem'Hadar battleship.

When the program is in debug mode it should show the amount of damage generated by the Jem'Hadar anti-proton beam, the shield and hull value of the player's ship before and after the attack.

  1. Implement the code for a Borg cube (worth 2 letter steps).  You are to implement a new class "BorgCube" that extends class "StarShip".  This ship will replace one of the 3 computer-controlled star ships from the game that you implemented for the fourth assignment.  For example, if you already implemented the code for Jem'Hadar battleship there will still be 3 computer-controlled ships: a Jem'Hadar battleship, a Borg cube and an instance of one of the standard star ships from assignment 4.  The Borg cube has all the features of the basic star ship except:

A Borg sphere ship travelling at transwarp (faster than warp) speed.

First hit by opponent during the game

No damage reduction

Second hit by same opponent

Damage is reduced by 25%

Third hit by same opponent

Damage is halved

Fourth and successive hits during a game

Damage is reduced by 75%

All fractional values are removed when determining damage.  For example, if 355 points of damage were randomly generated by a phaser hit on a Borg cube and this were the 4th attack then the damage inflicted would equal 88 points (355 / 4 = 88.75 which is rounded down to 88 points).

Example: The human player is controlling one of the old star ships from the previous assignment (an instance of class StarShip).  The first time that the player tangles with the Borg her phasers generate 880 points of damage.  All of this damage will be deducted from either the shields or hull of the cube depending on whether the shields are still up or not. The next turn the player fires on the cube again.  Her ship generates 800 points of damage.  A quarter of the energy is dissipated by the Borg's defensive systems (200 points) while the remaining 600 points are again deducted from the shields or hull of the cube.  The player fires a third time on the cube and phasers generate 100 points of damage but now the cube absorbs only 50 points of damage, the other 50 points have been dissipated.  By now the player has had enough and flees the battle.  Should she try to tangle with the Borg again the phasers on her ship will do only a quarter damage to the Borg.

Note however that the Borg ability to adapt applies to energy based weapons like the phaser.  It will have no effect on either the quantum torpedo or the photonic cannon. 

A Borg cube under attack by a Federation task force

When the program is in debug mode the program should show the full amount of damage generated by the player's phasers, the number of times that the Borg ship was hit by the player's ship and the damage that will actually be inflicted on the cube.

  1. Implement the code for a Klingon attack cruiser (worth 2 letter steps).  You are to implement a new class "KlingonAttackCruiser" that extends class "StarShip".  This ship will replace one of the 3 computer-controlled star ships from the game you implemented for the fourth assignment.  For example, if you already implemented the code for Jem'Hadar battleship and the Borg cube then there will still be 3 computer-controlled ships: a Jem'Hadar battleship, a Borg cube and now the Klingon ship replaces the last instance of the old-style star ship from Assignment 4.   The Klingon attack cruiser has all the features of the basic star ship except:

Example: The human player is controlling one of the standard star ships from the previous assignment and is taking on a Klingon attack cruiser.

Human player's ship

Ship's system

Point value

Shields

600

Hull

400

The damage generated for the cruiser's disruptor fire is 700 points.  Because the disruptor fire has double the effect on shields, only 300 points of damage are required to cause the shields on the human player's ship to go down.  That leaves 400 points of disruptor energy left.  This damage is now deducted from the hull of the human player reducing it zero.  Because Klingon ships attack first the human player's ship is destroyed and he or she has lost the game.  The results of the attack on the human player's ship is displayed and the game now ends indicating that it was lost.  

A Negh'var class attack cruiser de-cloaking for attack

If the game is in cheat mode then the game should display: 1) The amount of disruptor damage generated 2) The amount deducted from the shields 3) The amount deducted from the hull (if any).

  1. Implementing the full cheat menu by adding an extra option (worth 1 letter step).

Menu option

Effect

Activate covert sensors (menu option 'C')

  • Detailed information about the three computer controlled ships will be shown onscreen:

  1. The row, column coordinates in the galaxy (handy for ferreting out cloaked vessels).

  2. The current shield and hull value.

  • Unlike the photonic cannon, this cheat mode option will operate continuously (the information will be displayed while the covert sensors are turned on).

  1. During the movement phase all of the above information will be displayed.

  2. During the attack phase only the current shield and hull value will be shown.

  • If this menu option is again selected when the sensors are turned on then they will be turned off (selecting it acts as an on/off toggle).

Grading: Non-working submissions

D submissions:

The student has invested considerable time and effort into the assignment, the program does not fulfill any of the above requirements but it does compile.

D- submissions:

The student has invested considerable time and effort into the assignment, the program does not fulfill any of the above requirements and it does not compile.

 

Submission requirements for this assignment

In addition to having fulfill the generic assignment requirements, the requirements specific to this assignment include:

1. Good coding style and documentation:  They will play a role in determining your final grade for this assignment.  Your grade can be reduced by a letter step or more (e.g., "A" to "A-" for poor programming style such as employing poor naming conventions for identifiers or for not properly employing inheritance).

2. Include a README file in your submission:  For this assignment your README file must indicate what features have been completed as well as the estimated grade level.   This will allow your marker to quickly determine what he or she must look for and speed up the marking process.  Be specific about the features, don't just list the letter grade but state the break down as well:

e.g., I completed the "C-" level requirements plus:

Total estimated grade = 1.7 + 2 steps = 2.3.

As with previous assignments you must indicate if you use any external libraries (other than the tio or the ones produced by Sun). 

3. Assignments (source code and the README file) must be electronically submitted via submit.  In addition a paper print out of the source code and the README file must be handed into the assignment drop box for the lab that you are registered in (located on the second floor of the Math Sciences building).  Electronically submitting the assignment allows your marker to run the code in order to quickly determine what features were implemented.  Providing a paper printout makes it easier for your marker to read and flip through your source code.  Much like the case with Assignment 4, you will later schedule some time in lab to show to your TA which features of the game that you actually implemented.

 

New Concepts to be applied for the assignment

  1. Inheritance
  2. Software reuse

External libraries that can be used

  1. Libraries that allow for text-based (console) input and output.
  2. Libraries that will randomly generate numbers (e.g., class Random or class Math).

 

Sources of information for this assignment

   1.  The official Trek web site: www.startrek.com

   2.  "The birth of the federation" by Microprose

   3. "Star Trek: Borg" published and developed by Simon & Schuster Interactive

  4. "Star Trek: Armada" published by Activision

 

Note: The use of the Star Trek trademark © was for educational purposes only and not meant as a copy write challenge.

1 From Star Trek: The next generation, "The best of both worlds, Part II"