COMP1511 22T1 — Programming Fundamentals
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
COMP1511 22T1 — Programming Fundamentals
CS Explorer
CS Explorer is a 2D map game written in C that will allow you to put your last few weeks of COMP1511 skills into practice. Please read the entire specification before starting the assignment.
Note: At time of release of this assignment (Week 4), COMP1511 has not yet covered all of the techniques and topics necessary to complete the later stages of the assignment. At the end of Week 3, the course has covered enough content to be able to read in a single command and process that input. However, you have not yet seen two dimensional arrays or be able to handle multiple commands ending in End-of-Input (Ctrl-D). We will be covering these topics in the lectures, tutorials, labs, and a live stream in Week 4. The links for these have been shared in the Week 4 announcement.
Overview
The time has come to go forth and explore the dark and dusty corners of the UNSW CSE buildings. CS_Explorer is a simulation of your exploration, it is a 2D game with the following game pieces in play:
Player
Monster
Potions
Boulders
The aim of the game is for the player (you) to destroy all the monsters hiding in the building by moving around the map, whilst also regenerating health by consuming health potions.
Assignment Structure
CS Explorer uses a 2D array of structs to represent the game map, i.e. each coordinate of this map is a struct, which contains the information outlined below. The user will interact with the program using keyboard inputs.
You can see a revision video on structs here: https://www.youtube.com/watch?v=nkkYk6PcPCc
struct location
Purpose: To store the state of each point on the map.
Contains:
char occupier - Type of object at this position. Options include:
‘Bʼ = Boulder
‘Eʼ = Empty
‘Hʼ = Healing Potion
‘Mʼ = Monster
‘Pʼ = Player
int points - The health damage/healing the occupier at this map position can inflict. For example Points > 0 = Healing
Points < 0 = Damage
Key Terminology
All terminology
Term |
Meaning |
"Map" |
The 2D array of location structs that all items reside within. |
"Location" |
A struct that contains information about the occupier at a certain point on the map. |
"Game
pieces"
r 1 1 2 2 M Count points in a box
Throughout the specificiation, the replaced with
bracketing referes to placeholders. For example,
m [direction]
would be
m u |
The entire
[direction]
has been replaced with
u .
Assignment Resources
Livestream
|
Reference Implementation
To help you understand the proper behaviour of CS Explorer, we have provided a reference implementation. If you have any questions about the behaviour of CS Explorer, you can check them against this reference implementation.
To access the reference Implementation
$ 1511 cs_explorer |
Allowed C Features
In this assignment, there are no restrictions on C Features, except for those in the Style Guide.
We strongly encourage you to complete the assessment using only features taught in lectures up to and including Week 4. The only C features you will need to get full marks in the assignment are:
int variables
char variables
if statements, including all relational and logical operators
while loops
printf and scanf
t t
structs
arrays, including two dimensional arrays
Your own helper functions
Using any other features will not increase your marks (and will make it more likely you make style mistakes that cost you marks).
If you choose to disregard this advice, you must still follow the Style Guide. You also may be unable to get help from course staff if you use features not taught in COMP1511.
Features that the Style Guide strongly discourages or bans will be penalised during marking. You can find the style marking rubric below.
How To Get Started
There are a few steps to getting started with CS Explorer.
. Create a new folder for your assignment work and move into it.
$ mkdir ass1 $ cd ass1 |
. Download the starter code (cs_explorer.c) hereor use this command on your CSE account to copy the file into your current directory:
$ cp -n /web/cs1511/22T1/activities/cs_explorer/cs_explorer.c . |
to make sure you have correctly downloaded the file.
$ 1511 autotest cs_explorer |
When running the autotest on the starter code (with no modifications), it is expected to see failed tests.
Spend a few minutes playing with the reference solution -- get a feel for how the assignment works.
$ 1511 cs_explorer |
Read through Stage 1.
Think about your solution, draw a diagram of the map to help you get started.
Start coding!
About the Starter Code
The provided starter code has done some setup for you. This is explained below.
Before the main function the starter code has:
. Imported libraries, defined some initial #define 's, and defined the struct described above
. Declared some functions, which are used to setup the game. Some of these you will not need to use, some of them you will. Please read the comments
. Declared a print_game_play_map function which you will have to use in stage 1.1 and beyond.
. Declared a print_cheat_map function which you will have to use in stage 1.2.
In the main function the starter code has:
. Created a 2D array of struct location s called map .
. Initialised the map using the init_map function:
This function sets all locations (except bottom left) of the map to store:
Sets the |
|
& |
|
to store: |
. Prints the game play map
. Prompts you to write your own code!
Your Tasks
This assignment consists of four stages. Each stage builds on the work of the previous stage, and each stage has a higher complexity than its predecessor. You should complete the stages in order.
- - - - H - - - |
- - - - - M H P |
- - - - - H M - |
- - - - - - M - |
- - - H - - - - |
- - - - - - - - |
- - - - - - - - |
- - - - - - - - |
| | | | | | | | |
Enter command: q
Exiting Program!
4.2. Monster Attack
Command
a |
2022-06-23