Introduction to Computer Science I by James Tam | Return to the course web page |
It's hard to believe but the "Trek" franchise has been around for almost 40 years. Production of the first episode "The Cage" began in late 1964. It was given a budget by NBC of $640,000 and produced by Desilu Studios (which was since taken over by Paramount Studios). Since that historic date, Star Trek has become a part of television and motion picture history and includes an six separate TV series and ten motion pictures. |
|
|
The ship that started it all! |
Figure 1: The starting locations for objects in the milky way galaxy. |
Ships are propelled using a faster than light mechanism known as "space warping" or warp speed for short. Time passes in the game on a turn by turn basis. Each turn is broken down into three sub-turns and occur in the following order: 1) Player's movement 2) The spatial anomaly moves 3) The ferengi ship moves. The goal of the game is to go to the sector that contains the dilithium and bring it back to the earth (game is won). Along the way spatial anomalies may appear and destroy the ship (game is lost) or ferengi raiders may try to steal the dilithium (the player must get the dilithium back).
Basic assignment "C+"
- The galaxy is initialized to the required starting positions and displayed with a numbered grid (see Figure 1).
- An introductory message is displayed when the program is first run.
- The player can move (warp) the ship. Limitations on movement:
1) A ship can travel a maximum of one sector per turn.
Figure 2: Ships can warp to adjacent sectors. 2) Ships cannot travel onto sectors that contain stars (*) or the earth (E). If the player tries to move his or her ship onto a sector that is occupied with one of these objects an appropriate error message will be displayed (which will differ slightly for each of these cases).
3) Ships cannot travel beyond the bounds the galaxy. If the player tries to warp outside of the milky way, the program will show another error message indicating that this is not possible.
4) The player can "pass" on moving his or her ship during a turn by entering the coordinates where the ship currently resides.
The game enters cheat mode if the player enters (0,0) for the row, column for the destination coordinates. This version of cheat mode will only allow the player to (t)oggle the debugging messages on and off. The exact information that will be displayed is up to you, because they are used as a tool by the programmer for fixing logic errors. Typically they display the values of different variables as the program runs (run the executable in the assignment 6 directory for some sample debugging messages). Selecting cheat mode when the debugging messages are on will turn the messages off, selecting cheat mode again will turn the debugging messages back on.
Extra features:
Implementing each of the extra features listed below will yield a grade increase of one "step" (e.g., "C+" to "B-"). Implementing all six features may result in a maximum grade of A+ (assuming that other submission requirements, such as coding style, have been met). Unless otherwise noted these extra features can be implemented in any order that you wish.
Expanded cheat mode. When cheat mode is invoked the player will have two options: 1) To toggle the debugging messages (as described above) 2) To enter (e)dit mode. Edit mode will allow the player to edit any of the sectors and change them to one of the following characters: *, D or a space. Although the player can edit sectors that don't contain these characters unpredictable results can occur (e.g., if the player changes the square containing the ferengi ship to a space, the ferengi ship will temporarily disappear only to reappear the next time that it moves). Changing a sector that does contain one of these characters to another one these characters should work as normal, it is only when the player tries to edit an object that moves when strange results start occurring.
Wormhole. A wormhole is a "tunnel" is space that connects two points. Each of these two points are invisible so that the player won't know that a sector contains a wormhole until his or her ship has entered it. (Moving your ship onto a sector containing a wormhole causes the ship to enter the wormhole). Entering the wormhole at one point allows for reciprocal and near-instantaneous travel across distant sectors of space. The locations of the "openings" of the wormhole will be at sector (3, 3) and (9, 7). When the player's ship enters one of these sectors a message will be displayed onscreen indicating that a wormhole has been entered and the ship's coordinates will now be changed to the location of the other wormhole. The galaxy will then be displayed showing the player's ship at the new location. If the player passes on his or her movement the next turn then the ship will again enter the wormhole and it will end up at its original location.
Figure 3: You won't know there is a wormhole there until you've already entered it
Spatial anomaly: It starts in sector (5, 4), represented by the '@' character, but it will randomly move around the galaxy. After player has moved (or has passed on his or her move), the program will randomly generate a new set of coordinates for the anomaly. The new location can be on any empty sector in the galaxy or the sector that is occupied by the player's ship. The program will continue generating new coordinate pairs until the resulting sector is either empty or contains the player's ship. A spatial anomaly is similar to a wormhole in that both are "rifts" in space but it is less benign: if the player's ship moves into a spatial anomaly or if a spatial anomaly forms on top of the player's ship, the game is lost and the program immediately ends with an appropriate error message displayed onscreen.
Figure 4: A spatial anomaly has formed on top of your ship!
Ferengi: "The Ferengi have a culture which is based entirely upon commerce. They follow a code of conduct known as "The Ferengi Rules of Acquisition." These rules ordain conduct such as "Never place family before business."2 Their ship is computer-controlled and starts out in sector (1, 1), represented by the 'F' character. Each turn the ferengi ship will move a maximum of one sector. This value will be determined by randomly generating a delta for the row and column coordinates of: -1, 0 or 1. That is, the row and column coordinate can go up by one, down by one or not change. A separate delta is generated for the row and column and added to the current set of coordinates for the ferengi ship. If the resulting sector is unoccupied and within the bounds of the galaxy then the ferengi ship will move there. The program will continue generating a set of delta's until an empty destination sector has been found. The ferengi ship is not effected by the wormhole or spatial anomaly and will not move onto sectors which contain objects such as stars, the dilithium, the earth or the player's ship. It will only move onto sectors that contain a space.
Figure 5: A contract is a contract is a contract...but only between ferengi!
- Dilithium: Although the dilithium shows up in the other versions of the game, with this feature you can pick up the dilithium by moving onto the sector that contains it (1, 4). At this point the game will tell the player that his or her ship is now carrying the dilithium and they the player should move their ship back to the earth. Each time that the galaxy is displayed the game will indicate that the player is carrying the dilithium. The player wins the game if their ship is carrying the dilithium and it is moved to a sector that is adjacent to the earth.
Figure 6: The positive conclusion of the game.
- Ferengi raiders (to get credit for this feature you must have first implemented features 4 & 5). If your ship is carrying the dilithium the ferengi will now steal it if they are adjacent to your ship. When this occurs a message will be displayed each time that the galaxy is displayed indicating that the ferengi have the dilithium. The player can get the dilithium back if they move their ship next to the ferengi ship during the movement phase. If the ferengi's randomly generated coordinates result in a destination that is still adjacent to the player's ship then the ferengi will steal the dilithium yet again. If the ferengi's randomly generated coordinates result in a destination that is still not adjacent to the player's ship then the player retains the dilithium.
U F
U F
U F
U F Player has dilithium Ferengi steals dilithium Player stays on square and retakes dilithium Ferengi ship moves off (player keeps dilithium)
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.