Lecture notes for the Introduction to multidisciplinary Computer Science II by James Tam Return to the course web page

CPSC 219: Assignment 5

New Concepts to be applied for the assignment

Introduction

Among science fiction programs the Star Trek universe has one of the largest and most diverse set of alien races. Although many of them are largely humanoid (bipedal and approximately the size and mass of an average human) some are quite exotic and include: silicon-based "rock monsters", many gaseous life forms (e.g., the calamarian), energy-based entities like the Medusans whose appearance is so alien that they drive most humanoids to madness when viewed, even ones that have no fixed shape or form such as the allasomorphs or the changelings but can change their appearance at will. Each has their own unique characteristics, culture, history and technology.

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 founding races of the Federation and perhaps the most ubiquitous are humans.  Most humans are an equal parts 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 honor above everything (even their own life).  Klingon ships are designed with powerful offensive capabilities that suit their aggressive natures.

A young Klingon warrior wielding a Bat'leth in mock combat. "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 a 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 are 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 defenses to the attack.  In addition the Borg are not native to the Federation quadrant (quarter) of the galaxy: 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."

Your mission for this assignment

You are to take your program from the previous assignment and 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: the Klingon empire, the Dominion and the Borg. The 'cheat' capabilities will be greatly expanded.

Features needed from Assignment 4

New features for Assignment 5

  1. Expanded cheat options. Game cheats have been expanded so when the user enters zero at the attack or movement menu, a full blown "cheat menu" will come up:

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 player to enter the destination (row, column) values and if the sector is unoccupied the player's ship will move to the new sector. The ship cannot open a slip stream tunnel to the current 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 one 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 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.

Enter debugging mode (option 'D')
  • It's to be implemented in a fashion similar to the previous assignment (off by default, and when turned on it will display debugging messages to help you find the errors in your program). Because of the many new features to be implemented for this assignment, the information displayed while debug mode is turned on is now more specific than was with the previous assignment.  This will help speed up marking.
Quit the cheat menu (option 'Q')
  • Invoking the cheat menu will use up some time in the game. That means that if the cheat menu was invoked from the movement menu then exiting the cheat menu (either by selecting quit or another option) will return the player to the attack menu (and vice versa).
  1. Create a Federation star ship. 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 previous 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).

  2. Create a Jem'Hadar battleship. 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.

  3. Create a Klingon attack cruiser. You are to implement a new class "KlingonAttackCruiser" that extends class StarShip.  This ship will replace one of the 3 computer-controlled 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).

     

  4. Create a Borg cube. 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 the 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.
    Attack number Damage reduction to the cube

    First

    No damage reduction

    Second

    Damage is reduced by 25%

    Third

    Damage is halved

    Fourth and successive attacks

    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 reduced 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 the 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.

     

Submitting your work:

  1. Assignments (source code/'dot-java' files) must be electronically submitted according to [the assignment submission requirements].
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].
  3. Before you submit your assignment to help make sure that you haven't missed anything here is a [checklist] of items to be used in marking.

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).

Some of the sources used to create 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.

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

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