DPST1091-无代写-Assignment 1
时间:2024-02-27
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 1/12
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
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 2/12
Allows Pacman to travel up to a higher floor (Stage 4)
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:
UP
DOWN
LEFT
RIGHT
Program phases
There are two main phases to the overall game:
. 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.
. 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.
Create a new folder for your assignment work and move into it.
$ mkdir ass1
$ cd ass1
Download cs_pacman.c here, or copy it to your CSE account using the following command:
$ cp -n /import/reed/A/dp1091/public_html/24T1/activities/cs_pacman/cs_pacman.c .
$ 1091 autotest cs_pacman
NOTE:
When running the autotest on the starter code (with no modifications), it is expected to see failed tests.
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 the standard input/output library.
. Defined some initial
#define
's and enums.
. Defined the struct(s) described above.
In the main function, the starter code:
. Creates a 2D array of
struct tile
s called
map
.
. Initialises this
map
with some default values.
. 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 :)
HINT:
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 3/12
You might also find it helpful to draw diagrams and write pseudocode between later stages, especially stage 3 and stage 4!
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:
$ 1091 cs_pacman
Start coding!
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.
Stage 1 ●◌◌ Stage 2 ●◌◌ Stage 3 ●●◌ Stage 4 ●●● Challenge ☠
Stage 1
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.
Examples
− Example 1.1.1: Place Pacman
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 4/12
Autotest
NOTE:
You may like to autotest this section with the following command:
1091 autotest-stage 01_01 cs_pacman
Stage 1.2 - Adding Features
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.
$ dcc cs_pacman.c -o cs_pacman
$ ./cs_pacman
Welcome to cs_pacman!
Enter Pacman's starting coordinates: 3 4
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 5/12
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
)
Examples
− Example 1.2.1: Adding a wall
$ dcc cs_pacman.c -o cs_pacman
$ ./cs_pacman
Welcome to cs_pacman!
Enter Pacman's starting coordinates: 3 4
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
Create the level:
W 1 1 1 5
S
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| ||||||||||||||||||||| | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
− Example 1.2.2: Adding multiple walls
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 6/12
Autotest
1091 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
.
$ dcc cs_pacman.c -o cs_pacman
$ ./cs_pacman
Welcome to cs_pacman!
Enter Pacman's starting coordinates: 3 4
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
Create the level:
W 1 1 1 5
W 2 3 2 9
W 4 5 7 5
S
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| ||||||||||||||||||||| | | | |
-----------------------------------------
| | | |||||||||||||||||||||||||||||
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | ||||| | | | |
-----------------------------------------
| | | | | ||||| | | | |
-----------------------------------------
| | | | | ||||| | | | |
-----------------------------------------
| | | | | ||||| | | | |
-----------------------------------------
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 7/12
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
− Example 1.3.1: Adding invalid/partially valid walls
$ dcc cs_pacman.c -o cs_pacman
$ ./cs_pacman
Welcome to cs_pacman!
Enter Pacman's starting coordinates: 3 4
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
W 1 1 1 20
W 1 -1 1 2
W -1 1 5 1
W 1 1 12 1
S
-----------------------------------------
| ||||| | | | | | | |
-----------------------------------------
|||||||||||||||||||||||||||||||||||||||||
-----------------------------------------
| ||||| | | | | | | | |
-----------------------------------------
| ||||| | |^_^| | | | | |
----------------------------------------
| ||||| | | | | | | | |
-----------------------------------------
| ||||| | | | | | | | |
-----------------------------------------
| ||||| | | | | | | | |
-----------------------------------------
| ||||| | | | | | | | |
-----------------------------------------
− Example 1.3.2: Adding non-horizontal/vertical walls
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 8/12
Autotest
1091 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
Examples
$ dcc cs_pacman.c -o cs_pacman
$ ./cs_pacman
Welcome to cs_pacman!
Enter Pacman's starting coordinates: 3 4
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
W 1 2 3 4
Given wall is not horizontal or vertical!
W 1 1 3 3
Given wall is not horizontal or vertical!
S
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | |^_^| | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
| | | | | | | | | | |
-----------------------------------------
+ Example 1.4.1: Placing dots after no setup
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 9/12
Autotest
1091 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 1091 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?
$ 1091 style cs_pacman.c
$ 1091 autotest-stage 01 cs_pacman
$ give dp1091 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 DPST1091, 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.
Do not provide or show your assignment work to any other person other than the teaching staff of DPST1091. 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.
+ Example 1.4.2: Placing dots after adding entities
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 10/12
Sharing, publishing, distributing your assignment work after the completion of DPST1091 is not permitted.
For example, do not place your assignment in a public GitHub repository after DPST1091 is over.
Rationale: DPST1091 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 DPST1091 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.
For more information, read the UNSW Student Code, or contact the course account. The following penalties apply to your total mark
for 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 DPST1091 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 dp1091 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
10% of the marks for this assignment will be given from the automatic style checker that will be run on your code. The utility
1091
style
can help with this!
10% 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.
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!
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 11/12
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)
A
b
m
d
i
f
a
l
m
f
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
Elegance (/5)
2024/2/27 11:47 DPST1091 24T1 - Programming Fundamentals!
https://cgi.cse.unsw.edu.au/~dp1091/24T1/assignments/ass1/index.html 12/12
DPST1091 24T1: Programming Fundamentals!
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 1 March 2024 200000. 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.
essay、essay代写