Prior to writing his famous
trilogy: The Lord of the Rings, Professor John Robert Reuel Tolkien had
already published "The Hobbit"1 a tale of the
adventure of Bilbo Baggins and the Company of thirteen dwarves. (JT's comment:
This is an exert from the second edition of the book that could describe
the plot far better than I ever could):
"The Hobbit is a tale of high adventure,
undertaken by a company of dwarves, in search of dragon-guarded gold. A
reluctant partner in this perilous quest is Bilbo Baggins, a
comfort-loving, unambitious hobbit, who surprises even himself by his
resourcefulness and his skill as a burglar.
Encounters with trolls, goblins, dwarves,
elves and giant spiders, conversations with the dragon, Smaug the
Magnificent, and a rather unwilling presence at the Battle of the Five
Armies are some of the adventures that befall Bilbo. But there are
lighter moments as well: good fellowship, welcome meals and song."
- J.R.R. Tolken "The Hobbit"
For this assignment you are to write a text based game with an
overhead view of the dwarven kingdom: Erebor (see Figure 2). This game
re-creates the portion of Bilbo's quest just after the secret entrance
tunnel to Erebor has been discovered and a 'volunteer' is needed to go
in. The full version of the game will allow Bilbo to sneak into the
Erebor in order to retrieve as much of the treasure as possible. The
treasure is guarded by the dragon "Smaug the Golden". Although Smaug
himself doesn't directly appear in the game the effects of his dragon
fire do. At the start of the game Bilbo starts off at the entrance to
the dwarven hall: Coordinates (0,E). Smaug will be asleep so Bilbo can freely move
about (the game is in "mode 1"). Once Bilbo is in the main hall
Smaug will awaken and begin bombarding the hall with fireballs (the game
now enters "mode 2"). Bilbo, like all Hobbits, is a stout fellow
but even he cannot withstand dragon fire for long so it will be a
tradeoff between collecting as much treasure as possible and getting out
of Erebor alive. Once Bilbo has reached the entrance tunnel, Smaug knows
that the would be thief has almost escaped so he will stop breathing
fire into the main hall but will instead focus on the tunnel. By the
time that Bilbo starts moving back up the tunnel's exit, Smaug will have
positioned himself at the entrance to the tunnel and start breathing
fire into it (the game now enters "mode 3"). At this point it's a
race against time for Bilbo (actually a race against the flames) as he
tries to reach the entrance before he gets caught by the fire. If
Bilbo's hit points reaches zero then he has been slain, the player has
lost and the game ends. If however Bilbo returns to the entrance/exit
then the game ends and the player's success is determined by how much
treasure has been gathered.
The world will consist of a 2D list with each element a string of
length one (a character). Different characters will be used to represent
different types of Middle Earth objects:
<space> = empty locations, '*'
= dragon fire, 't' = treasure, '#' =
wall, 'H' = the hobbit Bilbo |
|
Figure 2: Erebor, the game world |
- Displays an introduction at the beginning of the game just after
it starts. The introduction should explain the rules.
|
|
- Displays a conclusion when the game ends. In the full version of
the game it should display the game state: lost (Bilbo slain),
exited (Bilbo reaches exit) and how much treasure (if any) was
collected by the player but the is provided (in the A5 directory0.
|
|
- The game world 'Erebor'
consists of a 2D list of single characters. The list is initialized
with the start positions of all the entities in Erebor. (Your
program must use the same starting positions as mine).
|
|
- The program should display the game world using a numbered grid
so that columns and rows can be clearly identified.
|
|
- As Erebor is displayed, information about Bilbo's current hit
point level and gold collected is also shown (see top Figure 2).
|
|
- Displays the main (move) menu to the player. The 4 cardinal
directions (N, S, E, W) and inter-cardinal directions (NW, NE, SW,
SE) are mapped to positions on the computer keypad (1 = SW, 2 = S, 3
= SE, 4 = W, 5 = No move, 6 = E, 7 = NW, 8 = N, 9 = NE).
|
|
- If the player selects a hidden option '0'
at the main menu then the cheat menu will be displayed. Cheat
options: (d)ebug mode toggle (i)nvulnerability mode Program displays
cheat menu and get user selection. Entering any other value just
returns back to the main menu (time advances to the next turn).
|
|
- Player can quit the game by entering a negative value at the
main menu.
|
|
- Getting input for the main menu: the program can handle invalid
input type (i.e., it won't 'crash' if the player enters a
non-numeric value).
|
|
- Game tracks the following attributes for Bilbo:
Hit points (starts at 20), gold (starts
at 0). Bilbo's hit points will
go down as he is comes into contact with dragon fire and his gold
score increases as he picks up treasure. (JT's suggested
approach: there will likely be several pieces of information you
want to track about Bilbo (these two and likely his current
location). It might be easier to pass this information in a list
rather than individual variables. If you do this then make sure you
define some named constants to make it clear what information is
being accessed e.g., BILBO_HIT_POINTS = 0, bibloInfo = [20,0,0,0] #
HP=20, gold =0, row = 0, column = 0, if accessing hit points then
use the named constant e.g., print(bilboInfo[BILBO_HIT_POINTS]) is
clearer than print(bilboInfo[0])
|
|
- Debug mode implemented: To get credit for this feature the
player can toggle debugging messages on/off at the cheat menu and
debugging messages will be displayed during the 'on'
state. In order to get credit for features labeled "Debug must
show feature working" debug mode must show enough information so
that the marker can quickly determine if the feature has been
implemented correctly. You can check with your marker for the
specifics on this but generally you are should show the value of
different variables to demonstrate that the feature works e.g., when
Bilbo is invulnerable show him getting hit with dragon fire but a
message is displayed indicating that he won't take damage, when
invulnerability is turned off show him taking damage (hit points
before, damage inflicted, hit points afterwards).
|
|
- Invulnerability mode implemented. It's toggled on/off at the
cheat menu. When turned on, Bilbo will not take damage. The mode
(on/off) must be displayed as Bilbo's stats are displayed. Debug
must show feature working (different from just showing status,
it must somehow show that Bilbo would actually incur some damage
during a turn but doesn't because invulvnerability is enabled.
|
|
- Bilbo can move onto any location (except for walls). You will
progressively receive more credit as you implement more of the
sub-features listed below (a) - (c). Debug must show feature
working.
|
|
|
- Bilbo can move from one square to another (except into walls).
|
|
|
- Bilbo will take 4 points of damage if he's moved onto a square
that contains dragon fire '*'
|
|
|
- Bilbo will pick up 3 pieces of gold from squares that contain
treasure 't'. The treasure is
gone after Bilbo has picked it up and won't appear after he leaves
the square.
|
|
- Mode 2 implemented: as long as Bilbo is in the main hall Smaug
will breath fire into the hall. Each turn some randomly determined
locations will contain dragon fire. Locations that previously
contained fire can either contain fire again or the fire may die out
if Smaug doesn't breath into the same location. Potentially any
empty square (or the one containing Bilbo) in the main hall can be
hit with the fire. You will progressively receive more credit as you
implement more of the sub-features listed below (a) - (d). Debug
must show feature working.
|
|
|
- Each square has a 10% chance of getting blasted with fire.
Squares that were hit previously (but not hit again this turn) will
revert back to their old appearance (empty or containing treasure).
|
|
|
- Dragon fire only appears in empty squares (or the one containing
Bilbo).
|
|
|
- If the fire appears in the same square as Bilbo then he sustains
4 points of damage.
|
|
- Mode 3 implemented: When the player re-enters the tunnel (from
the main hall: location row = 14, column = 15) then the dragon fires
in the main hall will die out (the squares will be cleared) and a
message will appear indicating that Smaug is now moving towards the
tunnel. When the player moves off this square (up or down - although
the latter wouldn't be a good idea for the player because Bilbo is
now trapped by the flame...in this latter case the program stays in
mode 3 and doesn't revert back to mode 2) fire will appear at row
13, column 14 (entrance to the main hall. 50% of
the time Smaug's fire will travel zero squares, 25% of the time it
will move up one square while the remainder of the time it will move
up two squares. The fire is progressive, once it appears in the
tunnel it won't die out and will travel 0 - 2 squares each turn.
Debug must show feature working.
|
|
- Program can detect the lose gain condition (Bilbo's hit points
reaches zero or less and he is slain). At this point the world
should be displayed one last time and the game should end with an
appropriate status message displayed. The player is not eligible for
a high score (feature #18).Debug must show feature working.
|
|
- Program can determine when the exit has been reached by Bilbo
(he re-enters row 1 - he has to actually leave the square before it
can be re-entered). At this point the game should end and a status
message should appear that indicates that Bilbo has escaped as well
as the amount of treasure that he managed to get (this is the
player's 'score').
|
|
- The program tracks high scores in a file called "scores.txt".
When Bilbo exits Erebor the program will read the high scores from the file.
The file has two lines: an integer to signify the largest amount of
gold stolen and another to indicate the hit points of Bilbo
matched to the game in which the amount of gold was stolen (not
the maximum hit points ever retained when the game ended). For
example if Bilbo's current gold is 9 and hit points are 20 but
the file's current score is 12 gold and 10 hit points, because the file has a
higher gold value the current value of 20 hit points are not
recorded into the file. If the file doesn't exist then the
program should create a new file and then record Bilbo's current two
stats. If the file does exist then it will only update the two lines
if the amount of gold in the current game exceeds the gold score
recorded in the file. High scores are recorded only if Bilbo is
still alive: if the file exists when he dies then it remains
unchanged, if it didn't exist and Bilbo dies then a new one won't be
created.
|
|
- Extra bonus feature: instead of displaying the simulation in
text a graphical library is used (e.g., "tkinter").
The interface itself can still be console based (i.e., select a menu
option via keyboard input) just the output can be graphical to get
credit. Your
graphics don't have to be fancy (e.g., you can use different
primitives, color and/or text to distinguish the objects) but the
graphical version must clearly represent the same information as the
text-based equivalent (e.g., don't use rectangles of the same size
and appearance for Bilbo, the treasure, the walls and the dragon
fire). You won't get a lot of extra marks for implementing this
feature (because graphics isn't a key feature of this program). But
I did include this feature in case you wanted to spice up your
program and/or you wanted to increase the probability that your
assignment received a higher grade.
|
|