home *** CD-ROM | disk | FTP | other *** search
- Chapter 2 page 1 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- CHAPTER 2
-
- 2.1 The Programming Exercise
-
- The programming example chosen in this book as the learning
- application is the game of Startrek. It is a complex simulation
- with a minimal amount of i/o, and is thus ideally suited for a
- training exercise, because the i/o can be customized for any
- machine by the student. First written for teletypewriter
- terminals and later modified for CRT terminals it comes in
- numerous incarnations ranging from simple to highly
- sophisticated.
-
- The game is supposed to be based on the highly acclaimed
- television series. Usually the only resemblances are that the
- names of the crew and the enemy are those used in the TV show and
- that the player assumes the role of Captain Kirk, the commander
- of the Starship Enterprise, The rules of the version of the game
- we are going to discuss are as follows.
-
- 2.2 Rules of the Game
-
- The Federation is currently at peace with the Klingon Empire
- by virtue of the treaty of Organia. There are however other
- borders which may or may not remain peaceful, such as the truce
- with the Romulans. There is also always the remote possibility
- of conflict with a yet unknown race from the unexplored section
- of the galaxy. Students at the Starfleet Academy are thus
- currently required to undergo periodic training on a war game
- simulator. In order not to antagonize any paranoid neighbors who
- may find out about this training program, the program in the
- simulator is written assuming a Klingon enemy even though the
- Orgainians have made war with the Klingon's all but impossible.
-
- 2.3 Background
-
- You are assigned the role of the commander of the starship
- Enterprise your mission is to search the galaxy to seek out and
- destroy the enemy. The two dimensional representation of the
- galaxy is organized as a matrix of 64 quadrants arranged as 8
- rows by 8 columns, and numbered accordingly as shown below.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 2 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- 1 2 3 4 5 6 7 8
-
- 1 *** *** *** *** *** *** *** *** COMPASS DIRECTION
- 4 3 2
- 2 *** *** *** *** *** *** *** ***
- \ ! /
- 3 *** *** *** *** *** *** *** *** \ ! /
- \ ! /
- 4 *** *** *** *** *** +206+ *** *** \!/
- 5 ----.---- 1
- 5 *** *** *** *** *** *** *** *** /!\
- / ! \
- 6 *** *** *** *** *** *** *** *** / ! \
- / ! \
- 7 *** *** *** *** *** *** *** ***
- 6 7 8
- 8 *** *** *** *** *** *** *** ***
-
- The numbering is given as row, column so that for example
- Quadrant 4,6 (shown scanned) is the quadrant that is located four
- rows down and 6 columns across the map. Each quadrant is itself
- split up into 64 sectors also arranged as an 8 row by 8 column
- matrix.
-
- Your mission is to search the galaxy, locate and destroy or
- capture the enemy who are called Klingons, making sure that they
- don't destroy you in the meantime. In order to do this you are
- equipped with weapons and sensors. You have two kind of sensors
- (Short range and Long range) and two kinds of weapons (Energy
- and Projectile) as described below.
-
- When the game begins; the Enterprise is located at a random
- quadrant within the galaxy when it receives a Code One warning
- message from Starfleet Command telling you that the exercise has
- begun. In order to make your mission as difficult as possible
- you are not told anything about the galaxy. You do not know the
- location of your starbases or any of the enemy vessels, you are
- however told how many have been detected entering Federation
- territory. As you travel through the galaxy or even outside it,
- you are able to scan the quadrants you pass through using your
- Short Range Sensors and neighboring ones using your Long Range
- Sensors. You can also send out Long Range Probes to scan distant
- quadrants in any desired direction. You thus locate the enemy
- and your starbases by moving and scanning. Data concerning the
- scanned quadrants are stored in your ship's computer when it is
- working (ie. undamaged). Traveling through the galaxy uses
- energy (fuel). The physics of faster than light travel are such
- that it takes approximately one Stardate to travel anywhere at
- warp speed. The energy you use up however is a function of the
- distance traveled. You may thus cross the galaxy in one stardate
- using a lot of energy, or take two days to do the trip and use
- less than half the amount that the fast journey required.
- Traveling time is not wasted however because your Engineering
- section may utilize it to make necessary repairs to any part of
- the ship that has been damaged.
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 3 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
-
- When you encounter the enemy, you are to destroy or capture
- them. You may attempt to capture a Klingon by using your phasers
- to beat his shields down to a low value. The Klingon captain
- decides to surrender, self-destruct or fight on, based on how
- powerful he perceives you to be, effectively basing his decision
- on the amount of energy in your shields. You may fight the enemy
- with your Phasers (Energy weapons) or Photon torpedoes
- (Projectile weapons). You may also refuel, effect repairs and
- resupply at your nearest starbase, however, efficient as
- Starfleet Command is, it still may takes about half a stardate
- for them to check over the ship and replace any malfunctioning
- system.
-
- As you progress through the game, you will find that most
- moves cost you either time or energy.
-
- As captain of the starship you have a number of moves at
- each turn as follows;
-
- NAV Navigation
- SRS Short Range Sensors
- LRS Long Range Sensors
- PHA Phasers (Energy weapon)
- TOR Photon Torpedoes (projectile weapon)
- COM Computer
- SHE Shield control
- LRP Long Range Probe
- SHU Shuttlecraft
- TRA Transporter
- DAM Damage Control
- VIS Visual observation
- RES Resign
- MAP Galactic Map
- KST Klingon Status
- SAV Save the state of the game
- LSG Load a Saved Game
-
- These moves are described in detail below.
-
- 2.4 NAV NAVIGATION
-
- Navigation gets you around the galaxy. The compass is set up
- as follows;
-
- 4 3 2
- \ | /
- \ | /
- \|/
- 5 ---0--- 1
- /|\
- / | \
- / | \
- 6 7 8
-
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 4 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- Thus for example direction 3 is to the top of the CRT, direction
- 1 is -> way etc. You may also use fractional directions such as
- 1.4 to travel in any direction you like.
-
- You move from place to place by setting the warp speed. The
- warp factor is the distance which you travel across the galaxy.
- Thus warp 1 will move you a distance of 1 quadrant (horizontal or
- vertical) while warp 6 will move you 6 quadrants. For traveling
- around inside a quadrant (ie. to a different sector within the
- quadrant), use fractional warp velocities. Traveling on the
- diagonal, you will have to allow more warp speed (remember
- Pythagoras). Traveling at warp speed, you take about one
- stardate to get anywhere, irrespective of the warp factor. Warp
- factor thus has no bearing on time, but has a tremendous
- influence on the amount of energy you use to get anywhere. The
- faster you go, the more energy you use.
-
- 2.5 SRS SHORT RANGE SENSORS
-
- Short range sensors display the contents of the particular
- quadrant in which you are situated at any time as well as game
- status information. The display shows up as a matrix of 8 X 8
- sectors. Each sector may contain only one object at a time. An
- example of such a display is as follows;
-
- SHORT RANGE SENSORS IN QUADRANT 4,6
-
- 1 2 3 4 5 6 7 8 SCORE 5
- 1 . . . . . . . . TIME LEFT 23.9
- 2 * . . . . . . . CONDITION RED
- 3 . . . K . . . K SHIELDS 255.6
- 4 . . . . . . . . ENERGY 3456.0
- 5 . . . . * . . . PHOTON TORPEDOES 3
- 6 . . . * * . * . STARBASES 2
- 7 . . . . . E . . KLINGONS LEFT 21
- 8 . . . . . * . . KLINGONS CAPTURED 0
-
- Things that may be displayed inside the quadrant are as follows;
-
- . Blank sector
- * Star
- E The Enterprise (you)
- K A Klingon ship (enemy)
- B A Starbase (refuel depot)
-
- The Short Range sensor display also contains the game status
- display as follows;
-
- SCORE your score at any time. The score is a function of the
- amount of time survived so far, and the number of
- Klingons destroyed and captured.
-
- TIME LEFT the amount of play time left in the game.
-
- CONDITION the state of the Enterprise. There are 3 possible
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 5 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- conditions,
-
- RED Battle area, enemy in quadrant
- YELLOW Something is damaged, or the Energy level has
- fallen to below 400 units.
- GREEN Everything is fine, no enemy detected, no
- damage, and sufficient energy aboard the ship.
-
- SHIELDS the amount of energy allocated to the ship's shields.
- If this energy level is ever beaten down to zero by the
- enemy, the Enterprise is destroyed and you lose the
- game.
-
- ENERGY the amount of energy on board the Enterprise. If this
- ever falls to zero, the Enterprise becomes a derelict
- in space, and you lose the game.
-
- PHOTON TORPEDOES the number still on board the Enterprise
-
- STARBASES the number of starbase in the galaxy, even if you have
- not located them all.
-
- KLINGONS LEFT the number of enemy ships in the galaxy. When you
- have destroyed them all, you win the game.
-
- KLINGONS CAPTURED the number of enemy vessels you have captured.
- Each one captured is a bonus multiplier on your score.
-
- 2.6 LRS LONG RANGE SENSORS
-
- Long Range sensors show the contents of the neighboring
- quadrants but in minimal detail. An example of a long range
- sensor scan is shown below;
-
- LONG RANGE SENSORS FOR QUADRANT 4,6
-
- 001 012 104
- 002 206 307
- 717 001 003
-
- The Enterprise is located in the quadrant shown in the center of
- the display. The contents of each quadrant are described as a
- three digit number with the following convention.
-
- The 100's digit = number of Klingons
- the 10's digit = number of Starbases
- the 1's digit = number of Stars,
-
- thus for example, 317 means that the quadrant contains 3
- Klingons, 1 Starbase and 7 stars. Quadrants that are outside the
- galaxy show up as "***" on the display.
-
-
-
-
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 6 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- 2.7 PHA PHASERS
-
- Phasers are energy weapons. You tell the ship's computer
- how much energy to fire at all the enemy ships in the quadrant
- and it divides that amount of energy by the number of enemy
- ships. It then locks on to the enemy ships and fires the same
- amount at each ship. Then if your short range sensors are
- working, the computer will tell you how much energy hit the
- Klingon, and how much it has left in its shields.
-
- When the Klingon begins to run out of energy, it may
- surrender or self destruct. If it surrenders you have to board
- it and place a prize crew aboard. It takes about half a stardate
- to transfer prisoners, documents and make the arrangements for
- the prize crew. Captured enemy vessels are multipliers on your
- score.
-
-
- 2.8 TOR PHOTON TORPEDOES
-
- Photon Torpedoes are projectile weapons. The Enterprise can
- normally carry only 10. When you have used some,you may replenish
- your supply later at a starbase. You can however only carry 10
- at any one time.
-
- You instruct the computer as to which direction you want the
- missile fired and it does. It also prints out the track of the
- torpedo as it travels across the sector. Torpedo take 0.01
- Stardates to travel across a sector.
-
- Torpedoes are homing devices they thus usually hit the
- occupant of a sector. Thus if they enter a sector containing a
- star they will tend to home in on it and be absorbed by the star.
- Should they be traveling to fast to be deflected enough to
- actually hit the star, they will come out of the sector on some
- new course, having been deflected by the star. if they enter a
- sector containing a starbase, they will always home in on the
- base and destroy it. Destroying a starbase with its shields up
- is not normally possible with any weapon as yet known to the
- Federation. Your ability to destroy one in this simulation,
- penalizes you for sloppy aiming. Note that there is nothing to
- stop you from destroying your only starbase.
-
- 2.9 MAP OF GALAXY
-
- The map of the galaxy resides inside the ship's computer.
- The map shows an example of the two dimensional representation of
- the galaxy as follows
-
-
-
-
-
-
-
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 7 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
-
- MAP FOR QUADRANT 4,6
-
- 1 2 3 4 5 6 7 8
- 1 *** *** *** *** *** *** *** ***
- 2 *** *** *** *** *** *** *** ***
- 3 *** *** *** *** *** *** *** ***
- 4 *** *** *** 001 012 104 *** ***
- 5 *** *** *** 002 +206+ 307 *** ***
- 6 *** *** *** 717 001 003 *** ***
- 7 *** *** *** *** *** *** *** ***
- 8 *** *** *** *** *** *** *** ***
-
- All quadrants that have been scanned show up as three digit
- numbers in the same manner as the long range sensors. Quadrants
- that have not been scanned show up as "***". The computer
- automatically updates the map as long as it is undamaged when a
- short range scan or a long range scan is ordered, or when
- information is received from a Long Range Probe. The quadrant
- shown bracketed by the "+" signs (+206+) is the one currently
- occupied by the Enterprise.
-
- 2.10 SHE SHIELD CONTROL
-
- Shield control allocates some fraction of the ship's power
- to the ship's shields. Should the shields become damaged, you
- will not be able to allocate any energy to the shields. They
- will still however work normally in all other respects. Namely
- they will absorb a Klingon phaser blast.
-
- Klingon phaser blasts draw energy from the shields of the
- Enterprise so that in a fight the shields may have to be
- replenished from time to time. If a massive phaser blast is
- received, and a temporary overload occurs damage to one of the
- ship's sub-systems may result.
-
- Klingons also leave space mines floating around for you to
- run into. This is a departure from the scenario of the TV series
- but logical. If the Enterprise runs into one of these, energy is
- used up in the shields, just as if the Enterprise was hit by a
- phaser blast. Klingon Space Mines are put into the game to make
- you travel with your shields up. Note that you may require up to
- 400 units of energy to cope with a Klingon Space Mine explosion.
-
- 2.11 LRP LONG RANGE PROBES
-
- Long Range Probes are a means to find out what lies beyond
- the range of the Long Range Sensors without moving. You can fire
- a probe in any direction just as you would fire a photon torpedo.
- The probe speeds away at about Warp Factor 10, as such it takes
- about 0.1 stardates to cross a quadrant.
-
- The probe sends back a status report in the same format as
- the long range sensor/map data, as it enters each new quadrant.
- The data received from the probe is automatically placed into the
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 8 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- computer, if the computer is up at the time that the data is
- received. The communications technology used by the probes give
- it a limited range however. The signal grows too weak to be
- received when the probe is about five quadrants away from the
- Enterprise.
-
- If the probe enters a quadrant containing Klingons there is
- a probability that they may detect and destroy it. The probe may
- also collide with a star and be destroyed. The more stars there
- are in a sector, the greater the probability that the probe will
- collide with a star (and be destroyed) when it passes through the
- quadrant. Should you try and launch one when in a battle
- situation, the simulator will stop you.
-
- 2.12 TRA and SHU TRANSPORTER and SHUTTLECRAFT
-
- The Transporter and the Shuttlecraft allow you to possibly
- obtain energy and spare parts/materials without docking at a
- starbase. You can use the computer to scan the quadrant you are
- in and possibly locate sources of energy and materials or parts.
- You cannot however stock up on parts to expedite future repairs,
- you can only obtain parts to repair anything damaged at the time.
- The Enterprise is a starship not a freighter. Should you mine a
- lot of energy, and have an excess when you dock at a starbase,
- the base will relieve you of the excess and send you on your way
- with the standard amount.
-
- The Transporter allows you to beam a landing party down to a
- star system. The Shuttlecraft allows you to send a landing party
- to the system. The transporter uses energy, the shuttlecraft
- uses time. Once the landing party have reached their
- destination, Mr. Spok will notify you how much time the landing
- party have to spend on the ground to achieve their aims.
-
- The function of the landing party depends on where they are.
- If they have been landed near a source of Dilithium crystals,
- they will mine the crystal and then purify them using some
- equipment that Mr. Scott will lash together. Mr. Spok will give
- you an estimate of the amount of energy that you can expect to
- receive from the crystal that can be mined in a day. You then
- decide how long the mining operation lasts, they stay there for
- that amount of time and then return.
-
- If the landing party is on an inhabited planet, they will
- make a quick estimate of the amount of parts and materials that
- they can find so that the repairs to the Enterprise can be
- expedited. You will again be asked to decide how much time the
- landing party is to spend on the ground. They will stay there
- for that amount of time, and then return.
-
- The Transporter cannot be operated, or the Shuttle launched
- if the shields are up. On board sub-system repair goes on while
- the landing party are doing their thing.
-
-
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 9 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- 2.13 DAM DAMAGE CONTROL
-
- Damage control allows you to examine the state of repair of
- your ship's sub-systems. Engineering also gives you an estimated
- time for repairs to be completed. You may then decide to stop
- where you are in space and effect repairs, or continue on your
- way making repairs as you move. Mr. Spok sometimes comes up with
- a new repair technique and speeds up the process.
-
- If you are in the middle of a battle, you cannot stop to
- effect repairs, because the enemy is not going to wait around for
- you.
-
- 2.14 VIS VISUAL OBSERVATION
-
- Visual observations are the way in which you determine the
- contents of the neighboring sectors in the quadrant if the short
- range sensors are damaged. You are shown the contents of two
- sectors on each side of the Enterprise, but are not shown the
- sector location numbers. A typical visual observation is as
- follows;
-
- . * K . .
- . . . . .
- * . E . B
- . * * . .
- $ $ $ $ $
-
- Sectors outside the Quadrant are represented by dollar signs. In
- the above example, the Enterprise is obviously located close to
- the bottom of a quadrant.
-
- Visual observations are normally only used when the short
- range sensors are damaged.
-
- 2.15 RES RESIGN
-
- This is the way you end the game. If you are in the middle
- of a battle, the enemy will not accept your resignation
- (surrender) and you must fight on.
-
-
- 2.16 The Enemy
-
- The enemy are known as Klingons. They have taken up
- positions in various quadrants of the galaxy. They may travel
- alone or in fleets of up to seven vessels. Each Klingon you
- encounter may have up to 1000 units of energy aboard. Weapons
- technology in the Klingon Empire is almost at par with the
- Federation. Klingons are thus armed with phasers and photon
- torpedoes.
-
- During a battle, should your photon torpedo hit a Klingon it
- will be destroyed. Klingon's however take evasive action when
- they detect the torpedo coming at them and can sometimes dodge
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-
- Chapter 2 page 10 STARTREK THE COMPUTER PROGRAM By Joe Kasser
-
-
- them. The Federation however has superiority in photon torpedo
- technology. If the Enterprise is hit by a Klingon torpedo, it
- usually suffers damage to the area of the ship closest to the
- point of impact. A Federation torpedo, on the other hand will
- always destroy a Klingon ship if a hit is scored.
-
- Klingon phaser blasts draw energy from the shields of the
- Enterprise so that in a fight the shields may have to be
- replenished from time to time. If a massive phaser blast is
- received, and a temporary overload occurs damage to one of the
- Enterprise's on board sub-systems may result.
-
- The enemy also leave space mines floating around for you to
- run into. This is a departure from the scenario of the TV series
- but a logical one. If the Enterprise runs into one of these,
- energy is used up in the shields, just like being hit by a phaser
- blast. Klingon Space Mines are put into the game to make you
- travel with your shields up. Note that you may require up to 400
- units of energy to cope with a Klingon Space Mine explosion.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Copyright (c) Joe Kasser 1989
-
-
-
-
-