#### 联系方式

• QQ：99515681
• 邮箱：99515681@qq.com
• 工作时间：8:00-23:00
• 微信：codehelp

#### 您当前位置：首页 >> Web程序Web程序

###### 日期：2023-10-22 06:55

COMP1511 23T3 — Programming Fundamentals
1/9
Assignment 1 - CS Pacman
Overview
Welcome to CS Pacman! CS Pacman is an adaptation of the 1980 maze game. In this assignment you will be implementing 1511's
simplified version of this game and trying to get your Pacman to collect all the dots! Please read most of the spec before starting the
assignment. (although you can save reading stages 2, 3 and 4 for later).
Assignment Structure
This assignment will test your ability to create, use and manipulate 2D arrays and structs to solve problems. To do this, the map used in
the game has been implemented as a 2D array of tiles. These tiles are each represented by a struct tile , which is outlined below:
struct tile
Purpose:
To store information about the tiles of the map.
Contains:
enum entity entity
The type of entity that exists on this tile.
All entity types are found in the enum entity definition.
struct enemy enemy Represents the enemy at this location (if one exists).
struct enemy
Purpose:
To store information about a particular enemy
Contains:
enum direction move_direction
The direction the enemy is moving.
All directions are found in the enum direction definition.
int is_present Represents whether the enemy is present
You will need to add more fields to this struct in later stages.
The provided enums are quite extensive. Definitions of each are provided below:
enum entity
Purpose:
Represent possible entities that can exist on a tile
Possible values:
EMPTY_ENTITY Represents no entity. Some tiles will have no entity present, this allows us to represent that.
WALL
A wall that blocks the movement of Pacman and enemies
DOT
A collectable that gives Pacman points (Stage 2)
APPLE
A collectable that gives points, helps collect DOT s and can destroy WALL s (Stage 2)
BANANA
A collectable that gives points and helps collect DOT s (Stage 2)
POWER_UP
A collectable that gives points and helps catch ghosts (Stage 3)
STAIRCASE_UP
Allows Pacman to travel up to a higher floor (Stage 4)
COMP1511 23T3 — Programming Fundamentals
2/9 STAIRCASE_DOWN
Allows Pacman to travel down to a lower floor (Stage 4)
enum direction
Purpose:
Represent the direction of a ghost's movement
Possible values:
UPDOWN LEFT RIGHT
Program phases
There are two main phases to the overall game:
1. Create level phase. This is where you will be placing Pacman and adding features to the map. This is started in Stage 1 and you
will add to this throughout the rest of the assignment.
2. Gameplay phase. This is where you will handle Pacman's movement throughout the level. This is started in Stage 2 and you will
add to this throughout the rest of the assignment.
How To Get Started
There are a few steps to getting started with CS Pacman.
1. Create a new folder for your assignment work and move into it.
\$ mkdir ass1
\$ cd ass1
directory:
Or, copy this code to your CSE account using the following command
\$ 1511 fetch-activity cs_pacman
3. Run 1511 autotest cs_pacman to make sure you have correctly downloaded the file.
\$ 1511 autotest cs_pacman
NOTE:
When running the autotest on the starter code (with no modifications), it is expected to see failed tests.
5. Spend a few minutes playing with the reference solution -- get a feel for how the assignment works.
\$ 1511 cs_pacman
HINT: You might also find it helpful to draw diagrams and write pseudocode between later stages, especially stage 3 and stage 4!
7. Start coding!
Reference Solution
To help you understand the proper behaviour of the game, we have provided a reference implementation. If you have any questions
about the behaviour of your assignment, you can check and compare it to the reference implementation.
To run the reference implementation, use the following command:
COMP1511 23T3 — Programming Fundamentals
3/9
\$ 1511 cs_pacman
The provided starter code has done some setup for you. This is explained below.
Before the main function, the starter code has:
1. Imported the standard input/output library.
2. Defined some initial #define 's and enums.
3. Defined the struct(s) described above.
In the main function, the starter code:
1. Creates a 2D array of struct tile s called map .
2. Initialises this map with some default values.
3. Prompts you to write your own code!
HINT: To start with, feel free to write your code in the main function! You can also add in your own functions as you go - we would
definitely recommend this :)
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.
A video explanation to help you get started with the assignment can here found here:
Stage 1.1 - Placing Pacman
Your first task for this assignment is to place our Pacman on the map! Currently, the starter code creates a 2D array of struct tiles ,
and initialises them with the initialise_map() function that we’ve provided.
Your program should scan in the coordinates (first row, then column) at which Pacman should be placed. The updated map should
then be printed out, using the provided print_map() function.
Assumptions / Restrictions / Clarifications
You can assume that you will always be provided with two integers for the row and column for Pacman.
The row/column provided will always fall within the map.
COMP1511 23T3 — Programming Fundamentals
4/9
Examples
Autotest
NOTE:
You may like to autotest this section with the following command:
1511 autotest-stage 01_01 cs_pacman
Now that we’ve placed Pacman, we also need to place some features on the map! At this stage, the only feature that your program
should handle is placing walls — but you will need to extend this to other features in later stages, so have a think about how best to
do that!
To add features, your program should read characters in a loop, followed by a variable number of inputs based on which feature is
being added. The loop should terminate when the user enters the 'S' character (meaning “Start the game”).
As mentioned, the only feature for this stage is the placement of walls. To place a wall, the user will first type the character 'W' ,
followed by the wall’s start and end coordinates (first row, then column).
...
Create the level:
W [start_row] [start_col] [end_row] [end_col]
...
For this stage, you can assume that the walls will either be horizontal or vertical, and that the start values will be less than or equal
to their end counterparts. In other words, every coordinate pair received will have either the row OR column equal, and go from left to right, or top to bottom.
In this stage, every wall entered will be valid — meaning that all walls will fall entirely within the map.
Once all of the walls have been placed, the map should be printed.
HINT: You might like to start by creating a loop that scans in one character repeatedly until an 'S' is entered.
Inside your loop, you might want to add a way to check if the character 'W' was entered (i.e. add WALL ), and then scan in
the remaining integers for start_row , start_col , end_row and end_col .
This command loop is very similar to both:
count_char_type from the week 3 lab
cs_calculator from the week 4 lab.
Make sure that you understand these exercises if you’re struggling with this task!
Assumptions / Restrictions / Clarifications
You can assume that input for this stage will always end with S .
In this stage, all walls entered will be horizontal or vertical (for each coordinate pair, either the column will be the same, or the
row will be the same).
In this stage, you will not be given walls that fall outside the map.
You can assume that start_row will always be less than or equal to end_row . You can assume that start_col will always be less than or equal to end_col .
A wall could be a single block ( start_row equals end_row and start_col equals end_col ) ＋ Example 1.1.1: Place Pacman
COMP1511 23T3 — Programming Fundamentals
5/9
Examples
Autotest
1511 autotest-stage 01_02 cs_pacman
Stage 1.3 - Validating Walls
In this stage, the walls given may not be horizontal or vertical, and thus unable to be placed. If this occurs, the error message "Given wall is not horizontal or vertical!" should be printed, and the program should continue reading input.
We also need to handle the case where some or all of the wall falls outside the map. If part or all of a wall lies out of the map, then that
part should be ignored. The part of the wall that lies within the map should still be placed.
HINT:
It might be useful to create a function which checks if a given coordinate pair falls on the map!
Assumptions / Restrictions / Clarifications
You can still assume that you receive a valid number of inputs.
You can still assume that start_row will always be less than or equal to end_row . You can still assume that start_col will always be less than or equal to end_col .
If a wall is not horizontal/vertical AND falls outside of the map completely, you should still print "Given wall is not horizontal or vertical!"
Examples
Autotest
1511 autotest-stage 01_03 cs_pacman
Stage 1.4 - Placing Dots
Once the setup phase has finished, and all features have been placed, we need to fill all the remaining squares with dots. These are the
points which Pacman will collect while moving around the map. Any square which does not already have an entity on it should have a
dot placed on it.
Assumptions / Restrictions / Clarifications
Dots should not be placed on tiles with another entity already present.
A dot should be placed under Pacman
＋ Example 1.2.1: Adding a wall
＋ Example 1.2.2: Adding multiple walls
＋ Example 1.3.1: Adding invalid/partially valid walls
＋ Example 1.3.2: Adding non-horizontal/vertical walls
COMP1511 23T3 — Programming Fundamentals
6/9
Examples
Autotest
1511 autotest-stage 01_04 cs_pacman
Testing and Submission
Remember to do your own testing
Are you finished with this stage? If so, you should make sure to do the following:
Run 1511 style , and clean up any issues a human may have reading your code. Don't forget -- 20% of your mark in the
assignment is based on style and readability!
Autotest for this stage of the assignment by running the autotest-stage command as shown below. Remember -- give early, and give often. Only your last submission counts, but why not be safe and submit right now?
\$ 1511 style cs_pacman.c
\$ 1511 autotest-stage 01 cs_pacman
\$ give cs1511 ass1_cs_pacman cs_pacman.c
Assessment
Assignment Conditions
Joint work is not permitted on this assignment.
This is an individual assignment.
The work you submit must be entirely your own work. Submission of any work even partly written by any other person is not
permitted.
Except, you may use small amounts (< 10 lines) of general purpose code (not specific to the assignment) obtained from a site such
as Stack Overflow or other publically available resources. You should attribute clearly the source of this code in an accompanying
comment.
Assignment submissions will be examined, both automatically and manually for work written by others.
Do not request help from anyone other than the teaching staff of COMP1511, e.g. in the course forum & help sessions.
Do not post your assignment code to the course forum - the teaching staff can view assignment code you have recently
autotested or submitted with give.
Rationale: this assignment is designed to develop the individual skills needed to produce an entire working program. Using code
written by or taken from other people will stop you learning these skills. Other CSE courses focus on the skill needed for work in a
team.
The use of code-synthesis tools, such as GitHub Copilot, is not permitted on this assignment.
Rationale: this assignment is intended to develop your understanding of basic concepts. Using synthesis tools will stop you
learning these fundamental concepts.
Sharing, publishing, distributing your assignment work is not permitted. ＋ Example 1.4.1: Placing dots after no setup
＋ Example 1.4.2: Placing dots after adding entities
COMP1511 23T3 — Programming Fundamentals
7/9
Do not provide or show your assignment work to any other person other than the teaching staff of COMP1511. For example, do
not message your work to friends.
Do not publish your assignment code via the internet. For example, do not place your assignment in a public GitHub repository.
Rationale: by publishing or sharing your work you are facilitating other students using your work which is not permitted. If they
submit your work, you may become involved in an academic integrity investigation.
Sharing, publishing, distributing your assignment work after the completion of COMP1511 is not permitted.
For example, do not place your assignment in a public GitHub repository after COMP1511 is over.
Rationale: COMP1511 sometimes reuses assignment themes using similar concepts and content. Students in future terms find
your code and use it which is not permitted and you may become involved in an academic integrity investigation.
Violation of the above conditions may result in an academic integrity investigation with possible penalties, up to and including a mark of
0 in COMP1511 and exclusion from UNSW. Relevant scholarship authorities will be informed if students holding scholarships are involved in an incident of plagiarism or other
misconduct. If you knowingly provide or show your assignment work to another person for any reason, and work derived from it is
submitted you may be penalised, even if the work was submitted without your knowledge or consent. This may apply even if your work
is submitted by a third party unknown to you.
Note, you will not be penalised if your work is taken without your consent or knowledge.
plagiarism:
0 for the assignment Knowingly providing your work to anyone and it is subsequently submitted (by anyone).
0 for the assignment Submitting any other person's work. This includes joint work.
0 FL for COMP1511 Paying another person to complete work. Submitting another person's work without their consent.
Submission of Work
You should submit intermediate versions of your assignment. Every time you autotest or submit, a copy will be saved as a backup. You
can find those backups here, by logging in, and choosing the yellow button next to 'cs_pacman.c'.
Every time you work on the assignment and make some progress you should copy your work to your CSE account and submit it using
the give command below.
It is fine if intermediate versions do not compile or otherwise fail submission tests.
Only the final submitted version of your assignment will be marked.
You submit your work like this:
\$ give cs1511 ass1_cs_pacman cs_pacman.c
Assessment Scheme
This assignment will contribute 20% to your final mark.
80% of the marks for this assignment will be based on the performance of the code you write in cs_pacman.c
20% of the marks for this assignment will come from manual marking of the readability of the C you have written. The manual marking
will involve checking your code for clarity, and readability, which includes the use of functions and efficient use of loops and if
statements.
Marks for your performance will be allocated roughly according to the below scheme.
100% for Performance Completely Working Implementation, which exactly follows the spec (Stage 1, 2, 3 and 4).
85% for Performance Completely working implementation of Stage 1, 2 and 3.
65% for Performance Completely working implementation of Stage 1 and Stage 2.
COMP1511 23T3 — Programming Fundamentals
8/9
35% for Performance Completely working implementation of Stage 1.
The Challenge stage of the assignment is NOT worth any marks, but is something fun for you to work on getting to know a new library
and building something more visual!
Style Marking Rubric
0 1 2 3 4
Formatting (/5) Indentation (/2) - Should use a consistent indentation
scheme. Multiple instances throughout code of inconsistent/bad indentation
Code is mostly correctly indented Code is consistently indented throughout the program Whitespace (/1) - Should use consistent whitespace (for example, 3 + 3 not 3+ 3) Many whitespace errors No whitespace errors Vertical Whitespace (/1) - Should use consistent
whitespace (for example, vertical whitespace between sections of code) Code has no consideration
for use of vertical whitespace Code consistently uses reasonable vertical
whitespace Line Length (/1) - Lines should be max. 80 characters long Many lines over 80 characters No lines over 80 characters
Documentation (/5) Comments (incl. header comment) (/3) - Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID and a program description) has been included No comments provided throughout code
Few comments provided throughout code Comments are provided as needed, but some details or
explanations may be missing causing the code to be difficult to follow
Comments have been used throughout the code above code sections and functions to explain their purpose. A header comment (with name, zID
and a program description) has been included
Function/variable/constant naming (/2) -
Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code
Functions/variables/constants names do not follow naming conventions in style guide and help in understanding the code
Functions/variables/constants names somewhat follow
naming conventions in style guide and help in understanding the code
Functions/variables/constants names all follow naming conventions in style guide and help in understanding the code Organisation (/5)
Function Usage (/4) - Code has been decomposed into appropriate functions separating functionalities No functions are present, code is one main function
Some functions are present, but functions are all more than 50 lines Some functions are present, and all functions are approximately 50 lines long Most code has been moved to sensible/thoought
out functions, but they are mostly more than 50 lines (incl. main function) All code been meaning decompo into functions approx 5 lines (inc main function)
Function Prototypes (/1) -
Function Prototypes have been used to declare functions above main
Functions are used but have not been prototyped All functions have a prototype above the main function or no functions are used
COMP1511 23T3 — Programming Fundamentals
9/9 COMP1511 23T3: Programming Fundamentals is brought to you by
the School of Computer Science and Engineering
at the University of New South Wales, Sydney.
For all enquiries, please email the class account at cs1511@unsw.edu.au
CRICOS Provider 00098G
Elegance (/5) Overdeep nesting (/2) - You
should not have too many levels of nesting in your code (nesting which is 5 or more levels deep) Many instances of overdeep nesting <= 3 instances of overdeep nesting No instances of overdeep nesting Code Repetition (/2) - Potential repetition of code has been dealt with via the use of functions or loops Many instances of repeated code sections <= 3 instances of repeated code sections Potential repetition of code has been dealt with via the use of functions or loops Constant Usage (/1) - Any magic numbers are #defined None of the constants used throughout program are
#defined All constants used are
#defined and are used consistently in the code Illegal elements Illegal elements - Presence of illegal elements including:
Global Variables, Static Variables, Labels or Goto Statements CAP MARK AT 16/20
Due Date
This assignment is due 24 October 2023 20:00:00. For each day after that time, the maximum mark it can achieve will be reduced by 5%
(off the ceiling).
For instance, at 1 day past the due date, the maximum mark you can get is 95%.
For instance, at 3 days past the due date, the maximum mark you can get is 85%.
For instance, at 5 days past the due date, the maximum mark you can get is 75%.
No submissions will be accepted after 5 days late, unless you have special provisions in place.

【上一篇】：到头了
【下一篇】：没有了