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 a dwarven drinking chalice which is guarded by the dragon Smaug. At the start of the game Bilbo starts off at the entrance to
the dwarven hall. Smaug will be asleep so Bilbo can freely move about
(the game is in "mode 1").
Once Bilbo reaches and obtains the chalice Smaug will awake and begin bombarding
the hall with fireballs (the game now enters "mode 2"). At this point the player controlling Bilbo should
to return to the entrance as quickly as possible. Once Bilbo has reached
the entrance tunnel with the chalice, Smaug knows that the would be thief has almost escaped with his prize
so he will stop breathing fire into the main hall but will instead move to 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 at any time (either in the main hall
or in the tunnel) Bilbo gets caught by Smaug's fiery breath, the player has lost
and the game ends. If however Bilbo returns to the entrance with the
chalice then the player has won the game.
- The 2D character array that represents Erebor has been declared and
initialized with the proper starting positions (as shown in the
partially completed program 'hobbit.p' in the assignment directory).
Characters are used to represent different things in this
game: "*" is a solid wall, "B" is the hobbit Bilbo, "C" is the dwarven
chalice, empty areas are represented with spaces ("F" will be used
to represent Smaug's fireballs in the full version of the game). Your
representation of Erebor must use these starting positions.
Smaug does not physically appear in the game, only his fireballs appear
(in the later version) so you don't have to allocate array elements to
show him onscreen.
|
- After initialization the program will loop until the player chooses
to quit the game (there are no win or lose game conditions for this
version of the game).
|
- For each iteration of the loop the game will do the following:
|
|
- The array is displayed onscreen along with the alphanumeric legend
along the left and top of the array. The variable "hasChalice" in
the main procedure is set to false so your program should display a
message indicating that Bilbo is still searching for the chalice.
(In later versions of the game the message displayed here will depend
upon whether it is true or false that Bilbo has reached the chalice).
|
|
- The main menu will display two options: (m):
move Bilbo to another square, (q): to
quit the game. For this version of the assignment, only the
quit game option has to work . In addition the main menu will
contain a 'hidden'
(meaning that it doesn't show up when the other menu
items are shown onscreen) cheat menu that will
shown up if option 'C' or 'c' is
selected.
|
|
- When invoked from the main menu, the cheat menu will display three options: (d): Turns debugging mode
on or off (set the global variable 'debugOn' to true or false)2,
(t): teleport Bilbo. The teleport option need not be implemented for this version of the
assignment, (q): quit the cheat menu and return to the main menu.
Note: entering and leaving the cheat menu uses a player's turn
and causes time to pass. For this version of the assignment
there is no visible effect to the player, the program is in "mode 1" by default
and nothing aside from the player is moving in Erebor. In the fully working version
(when mode 2 & 3 have been implemented) Smaug's fireballs
will appear and disappears after the player has expended
his or her turn.
|
|
|
|
|
|
Extra features:
Unless indicated or there is some other compelling reason you can
implement the features below in whatever order or combination that you
desire. Correctly implementing basic assignment and all the extra
features makes you eligible to receive an "A+" (GPA = 4.3!).
The "other submission requirements" (shown below) and the
coding style requirements
must also be fulfilled. Prior to implementing the features below you
should get the 'teleport' option in the cheat menu working (to allow you
and your marker to be able to quickly test your program).
Implementing some of the features below but missing
the teleport option will cost you two letter "steps" so
don't forget to do it. The
teleport option will allow Bilbo to magically disappear from his current
square and reappear in any other square inside the array except for ones that contains a
wall. |
|
- Bilbo can move (worth 1 letter 'step'): When option
'm' is selected at the main menu the player will be shown the choice of
movement options that are possible. The values 1 - 4 and 6 - 9
correspond to the 8 compass directions that the Bilbo can move
(selecting option 5 will allow the player to pass on his or her move).
When Bilbo moves, the square where he currently
resides will be cleared and he will appear at his new destination . The program should
continue prompting the player for a direction if a value outside of this
range of 1 - 9 is entered
for the direction. You do not have to check if the destination
square is occupied to receive credit for this feature (that's to be
implemented in the next feature). If the player moves onto an occupied square then it will appear that
Bilbo has 'erased' the character that was previously located
there.
|
|
|
|
- The program checks that the destination doesn't contain a wall (worth 1
letter 'step'): If the player tries to move Bilbo into a wall
then the program should display a suitable error message and continue
prompting the player for a movement direction until either one is
provided or direction '5' is entered (don't move). If the player moves Bilbo into the dragon fire then a suitable lose game
message should be displayed and the game should end. For this
version of the game, your program does not have to enter mode 2 if Bilbo
moves onto the square containing the chalice (which is part of feature
#4).
|
|
|
|
- The program checks that the destination is within the bounds of
the array (worth 1 letter 'step'): Each time that the player
moves Bilbo the program will check that the destination is within the
bounds of the array. If the player tries to move Bilbo outside of
the array then the program should provide a suitable error message and
the program will again prompt the player to enter the direction until
either a proper direction is provided or the player chooses to pass on
his or her move.
|
|
|
|
Note: In order to
get credit for features 4 & 5 your program must be able to detect when
Bilbo has moved into a square containing dragon fire or if the dragon fire
appears in a square where Bilbo resides. In either case the program
should provide a suitable lose game message and the game should end. |
|
|
|
- Mode 2 is implemented (worth 2 letter 'steps'): When
Bilbo enters the square containing the chalice a number of things will
happen: 1) The 'hasChalice' variable will be set to true so when
the array is displayed the program will thereafter indicate that Bilbo
has found the chalice (it's not possible to 'lose' the chalice one it's
been found) 2) The variable 'smaugMode' will enter mode 2 ("fire
breathing"). The latter will mean that Smaug will start breathing fire
in the main hall (row 15 - 29, column 1 - 31) in an attempt to
incinerate the intruder. For each empty square (or the one
that contains Bilbo) in the main hall, there is a one in ten chance that Smaug will breath fire into
it. If Bilbo is hit by the dragon
fire then: the square that he resides on changes to an 'X', a suitable
lose game message appears and the game ends. Smaug will not
breath fire into a square containing a wall. Squares that
previously contained dragon fire will be cleared (Smaug will not breath
into the same square twice in a row so that squares that are currently
on fire will have the fire die out in the
following turn). In summary: when you write the code
for Smaug to blast the main hall with fire the following will occur: empty squares (or the one
with Bilbo on it) will each have a one in ten chance of getting hit with
fire, squares that contain fire will be cleared back to a space).
|
- Mode 3 is implemented (worth 2 letter 'steps'):
When the player has the chalice and enters the deepest part of the
tunnel (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 flames) Smaug will start breathing fire up the tunnel in a last ditch attempt to
catch the little thief. The distance that the fire travels will be
determined as follows: 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.
Again if the fire reaches the square where Bilbo resides then the square
should be marked by the 'X", a lose
game message will appear and the game will end.
|
|
- The game can be won (worth 1 letter 'step'): Prior to
getting credit for this feature you must first implement mode 2 /
feature #4 (the
ability to detect that the chalice was picked up by Bilbo) and likely
you'll have also implemented some other features like being able to move
Bilbo. When Bilbo reaches any of the empty squares on row 1
(column 14, 15 or 16) with
the chalice the game has been won. When this happens a suitable
win game message should appear and the game will end.
|
|
Grading: Non-working submissions
|
|
|
|
D submissions
|
|
|
- The
student has invested considerable time
and effort into the assignment3, 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 assignment3, but it does not compile.
|
|
|
|
Other submission requirements
|
|
|
- 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, insufficient documentation or the use of global
variables other than the debugging variable or variables). For additional details see the marking
guide for coding style.
|
|
|
|
- Assignments (source code/'dot-p' file and the README file) must be
electronically submitted via submit.
In addition a paper print out of the source
code and README must be handed into the assignment drop box (located on the
second floor of the Math Sciences building) for the tutorial that you are
registered in. Your README file
must indicate what grade level has been completed (e.g., 'A') and which
features have been implemented. Also
you should include your contact information:
your name, university identification number
and UNIX login name so that your marker knows
whose assignment that he or she is marking. Omitting the necessary
information from this file will result in the loss of a letter 'step'
(assuming that the marker can actually figure out who the assignment
belongs to).
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.
Omitting the paper printout of your program will result in the loss of a letter 'step'. Omitting
the electronic submission of your program will only allow you to receive a maximum grade of D-.
|
|
|
|
- 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.
|
|
|
|
Relevant files
|
|
|
You
can run a sample executable called 'hobbit'
which can be found in the UNIX directory:
/home/231/assignments/assignment7. In addition there is a Pascal
program called 'hobbit.p' that provides
the source code for some of the required functionality of your program. |
|
|
|
1The Lord of
the Rings trademark is owned by
Tolkien Enterprises.
The license to the movie is owned by
Warner Brothers..
References to either the original trademark or the inclusion of images
from the movie are for education fair use only and are not meant as a copy
write challenge. |
|
|
|
2 The effect of
turning on debugging mode is to show onscreen messages about the state of
the program that, if properly implemented, will help you debug your
program. The exact content of these messages is left to your
discretion but you can run the sample executable for some idea of how it
should work. You should be writing these debugging messages as
you implement the various functions and procedures in your program so they
can be used in testing. What you should not do is write your
whole program and then add in a few token output messages afterwards (because this
totally defeats their purpose which is to help you as
your write your code). Note using a debug
variable is the only exception to the restriction on using global
variables in your assignment submissions. You are allowed to
use multiple debugging variables if you wish e.g., one indicates whether
the messages for the function/procedure calls show up, another to
determine if the program shows information for the current row/column
coordinates of Bilbo. |
|
|
|
3
What does and doesn't constitute a sufficient amount of time and effort?
It's a judgment call on the part of your marker. More often than not
if you put in a reasonable amount of effort into your assignment and for
some reason you just couldn't get it to work then you will receive some
credit for your work. An example of when you wouldn't receive
credit is when you simply handed someone else's work (such as the hobbit.p
program in form that is identical to the one in the course directory).
This latter case assumes that you properly cited the other person's work,
if you didn't cite your source and tried to claim that it was your own
work then it would be an example of academic misconduct (cheating). |