COMP2129 Assignment 2
Due: 11:59pm Monday, 21 April 2014
This assignment is worth 12% of your final assessment
Task description In this assignment we will develop a simplified version of Nintendo’s
Super Mario Bros in the C language using dynamic data structures and ensuring that no memory leaks occur.
In each game there is Mario, a short, pudgy, Italian plumber who resides in the Mushroom Kingdom,
a dystopic world under constant attack from Bowser the King of Koopa. Mario will use his expert
plumbing skills to rescue Princess Peach the damsel in distress from the prying hands of Bowser.
Mario must navigate his way to Princess Peach. Each stage has a one way exit that is linked to the
next in the list and an optional set of pipes, all of which take Mario into another predetermined stage.
The input of your program consists of a series of instructions that are read from standard input. In
the initialisation phase, the game settings, stages and pipes are defined along with the start and final
stages. The game phase involves playing the game in which Mario can either enter the next stage in
the list or another stage through a given pipe, collect coins from the current stage, or make a wager.
Mario must finish the game within the given timeframe and also collect enough coins on his way to
the final stage. Mario starts at the start stage with no coins and can move into the next stage in the list
or through a given pipe until he reaches the final stage. Each stage contains a defined number of coins
that can be collected. Mario can also try to wager some of his coins, which based upon his choice of
odd or even will result in doubling or forfeiting the given wager. Each move Mario makes takes one
minute except collecting coins which instead deduct one minute for each coin that is collected.
Academic declaration
By submitting this assignment you declare the following:
I declare that I have read and understood the University of Sydney Student Plagiarism: Coursework Policy and Procedure, and except where specifically
acknowledged, the work contained in this assignment/project is my own work, and has not been copied from other sources or been previously submitted
for award or assessment.
I understand that understand that failure to comply with the Student Plagiarism: Coursework Policy and Procedure can lead to severe penalties as
outlined under Chapter 8 of the University of Sydney By-Law 1999 (as amended). These penalties may be imposed in cases where any significant
portion of my submitted work has been copied without proper acknowledgement from other sources, including published works, the internet, existing
programs, the work of other students, or work previously submitted for other awards or assessments.
I realise that I may be asked to identify those portions of the work contributed by me and required to demonstrate my knowledge of the relevant material
by answering oral questions or by undertaking supplementary work, either written or in the laboratory, in order to arrive at the final assessment mark.
I acknowledge that the School of Information Technologies, in assessing this assignment, may reproduce it entirely, may provide a copy to another
member of faculty, and/or communicate a copy of this assignment to a plagiarism checking service or in-house computer program, and that a copy of
the assignment may be maintained by the service or the School of IT for the purpose of future plagiarism checking.
assignment2
Hint:
Develop and run your code on the undergraduate server to access the included testing tools.
Implementation details
The header file
smbdefines the dynamic data structure needed to implement the game.
The contents of the header file smbh is shown below:
All of the stages must be stored in a circular linked list which is to be built and maintained when
defining and playing the game. You may decide whether to implement any additional data structures.
The stage data structure contains the
name
of the stage, a pointer to the
next
stage in the list and a one
dimensional array of pointers to the stage that each pipe connects to. The number of
coins
stores the
amount of coins in the stage, and the number of
pipes
stores the amount of pipes in the stage.
In order to obtain full marks, your program
must
free all of the dynamic memory it allocates. This
will be automatically checked using
valgrind
. Even if your program produces the correct output for
a given test case, if it does not free all the memory it allocates it will fail that test case.
Warning:
Ensure that you do not modify the included header file or Makefile
Operating Systems and Machine Principles Page