代做COMP10002 Foundations of Algorithms Semester 1, 2025 Assignment 1: Exploring Spaces代做Statistics统计

COMP10002 Foundations of Algorithms

Semester 1, 2025

Assignment 1: Exploring Spaces

Due: 11:59 pm Friday 02 May 2025

Version: 1.4.2

April 28, 2025

IMPORTANT NOTES:

  Clarified where to write bonus challenge code (V1.4.2)

•  Please be aware that we have changed the submission location to be on GRADESCOPE, instead of ED. You will need to submit one file a1 . c onto the grade-scope submission tab.

•  Please note that the auto-grader on gradescope will provide sugges- tions on your coding style. that will contribute to the style. mark.

  The expectations for Task 2 have been further clarified.

•  For the bonus challenge we have made it count for 1 bonus mark

Please see the FAQ for instructions on how to submit the assignment.

At some point in time you may have seen one of these...  You have prob-

ably even encountered them in a variety of video games from Pac-man to Animal Crossing...

Or maybe you have heard the myths of labyrinths with monsters hidden in their depths...

This is because spatial exploration puzzles, like mazes are one of the old- est form. of playful activities we have.

We live a world where we are constantly physically exploring and nav- igating with our bodies.  So it’s almost a no-brainer that we would see this kind of activity show up in our play. Spatial exploration puzzles span many different types of navigation problems, but for today we will focus on one called pathfinding.

Pathfinding is the act of finding a possible path between two locations. Of- ten we are looking for the shortest-path, but sometimes we may look for other types of paths. In modern games, pathfinding is used to tell charac- ters how to move through the world. When people are chasing you in the Untitled Goose Game, or your Sim can’t get out of the pool because you deleted the ladder, those are examples of path finding at work.

For this assessment, we are going to be putting our algorithmic thinking to the test by exploring simple pathfinding.

About the Assignment

Assignment Structure

Like a game, this assignment is divided into levels with different tasks. Like any good game, each subsequent level builds on the skills and tech- niques you used in the previous level. We recommend trying them all in order for this reason.

To help get you started, each level will outline the problem, your require- ments for the level, any information about the problem space that may be useful to you, and an example of output from one of the provided test files.  Occasionally we will also highlight helpful hints and tips in a blue box like so:

Hey! Listen!

This is an example of what a hint/tip will look like.

Bonus Challenge:

At the end of the assignment, there is a skill-testing bonus challenge. The bonus challenge is a slightly more advanced problem that you are invited to try. There is one bonus mark associated with this.

Learning Outcomes

By completing this assessment you will demonstrate your understanding of the following coding concepts:

  Input processing,

•  Control structures (conditionals and loops), •  Functions, and

  Arrays.

You will also be demonstrating your algorithmic problem solving skills, particularly showing how you understand searching problems and recur- sion.

Getting Started

For this assignment, you will be given the following:

•  a skeleton code file (a1. c) with a semi-complete main function, a set of function prototypes for you to complete, and comment space for your answers to written questions;

•  a set of test input les for the various levels (test0 . txt, test1 . txt, test2. txt); and,

  examples of correct outputs for the test files both in this document,

and as a set of files such as (test0-level1-out. txt, test0-level2-out . txt, test0-level3-out. txt, test0-level4-out. txt) etc.

Before you start coding, you need to get to know the structure of the game. After reading this assignment and the FAQ at the end of this document, spend time familiarizing yourself with  (a1. c).  Pay attention to the vari- ables, constants, and function prototypes already in-place.  These will be useful hints at how to complete the functions later!

And remember, Algorithms are fun!

Level 1: Hello World? [4 marks]

In order to do any pathfinding, we need a representation of a “world” that we can move around in. But how do we represent that on a computer?

There are a variety of ways, but for simplicity we can think of our world like a map with a grid imposed on top of it.  This way every location on the map has an x and y coordinate that tells us where on the map it is.

We can extend this understanding to think about our map as a two-dimensional array. Every element of this 2D array is the relevant structure at that  (x, y) point.  For example, imagine a world where there are walls blocking our path; the array could store a symbol of a wall at the real wall’s (x, y) location to show us that it is there.

This leads us to our rst task: create the map for our world!

Requirements

To successfully complete this level you must:

1.  Complete the function FillMap() so it can read in the map data from the test file;

Hey! Listen!

We are running your code using input redirection (using < in commandline) to pass the test file to program so you can use the standard input functions, like scanf! To have a closer look at the command we are running, see the BUILD HELP . txt file in the skeleton code folder we have provided.

2.  Complete a function called PrintMap() that prints out the map to the terminal screen; and,

3.  Save the starting and ending locations you found to the appropriate variables in the main function.

Hey! Listen!

Think about how this task interacts with C scopes, and what tools we have to manipulate variables in different scopes.

What we know about the problem

File structure.   The input file will always contain at least 3 lines of data.

  Line 1:

 Two positive integers representing the row (y coordinate) and column (x coordinate) of the STARTING position

  Line 2:

 Two positive integers representing the row (y coordinate) and column (x coordinate) of the ENDING position

  Line 3:

 One positive integer representing the number of obstacles (i.e. BLOCKS) on the map

Depending on the number of blocks, the input file will also have the coor- dinates for those blocks.

Map size.   To make the process easier, we have fixed the map size as a square grid. The specific size value is defined as a preprocessor directive using #define!N at the top of the  (a1. c) file.  During graded testing this number and the input we test on may change. So when creating your code, make sure it can scale with the map size.

Location information.   You can assume for this input that we will not put the starting, ending, and/or blocks in the same location. This means the start and end will not be the same place. This will be true for all tests.

Sample Output

Your output for the Level given the same test file, should look like Fig. 1.

Figure 1: Example of expected output for Level 1 using test2 . txt

Level 2: Na…ıve Pathfinding [6 marks]

Great! Now we have our map rendered in the computer and know where the starting and ending points!

We now want to start working towards finding our way from the starting point to the exit point! Let’s start by taking a somewhat intuitive approach we will call na¨ıve pathfinding.

See requirements for a description of the algorithm below. Fig. 2 renders what the map would look like after each step.

 

Figure 2:  Example of each step the path would take for Level 2 using test2 . txt

For your second task, you will need to implement the described function and answer some questions about it.

Requirements

To successfully complete this level you must:

•  Complete the function SimpleDirections() so it can both render a path between the starting and ending space using +, and output the number of steps needed to reach the end. The pathfinding must use the following logic:

 From the starting point, the path will always try move along the rows towards the row containing the end point,

 If the path hits a block, it will move left or right one column in the direction towards the end point,

 The path will repeat the previous two steps until it reaches the correct row.

 The path then begins to move across the columns in the direc- tion of the end point.

 If at any stage, you cannot make a move following the above rules you must stop.

  Modify the skeleton code, so that in the case that you have no more valid moves from the above algorithm, so that it now prints "SimpleDirections took N steps and got stuck. \n\n", and then the map instead of

"SimpleDirections took N steps to find the goal. \n\n"and then the map, where N is the number of steps taken before not having any valid moves or reaching the end point.

•  Answer the following questions in the comment section indicated at the end of your a1 . c file:

 List some cases where this process will not produce our ex- pected result of reaching the end point? Why is this?

Hey! Listen!

Think about how the assumptions we have to make about the problem space (i.e. the map).

 Do you think this process will beefficient for bigger maps? Why, or why not?

What we know about the problem

Assumptions about the map.   At this point you can assume the follow- ing information:

•  We have provided an example in Fig. 4 of the expected output.

•  There is only one starting and one ending position.  However, you should consider that the starting and ending positions could be any- where on the map grid.

Sample Output

Your output for the Level given the same test file, should look like Fig. 3 or Fig. 4.

 

Figure 3: Example of output from Level 2 using test2 . txt input.

 

Figure 4: Example of output from Level 2 using test3 . txt input.

Level 3: Closest Neighbours [4 marks]

Hooray that’s one way to find a path to the end! Let’s try to come up with another (slightly more generic) process!

Intuitively, we may want to start by finding a valid (i.e. unblocked, empty) space adjacent to our starting space — i.e. its neighbour. If we then move into that new valid space, we can repeat the search process by just looking for the next adjacent empty space.  In this way, we are not pre-emptively deciding on the direction of our search, and so we do not need to give our search an end point. We call this process Closest Neighbours.

Our third task, is to implement this Closest Neighbours algorithm as discussed. Fig. 5 illustrates what the path looks like on the map at every step of this Closest Neighbours algorithm.

 

Figure 5:  Example of each step the path would take for Level 3 using test1.txt

Requirements

To successfully complete this level you must:

•  Complete the function ClosestFreeNeighbour() to find a path from a known starting position to an unknown ending position using the following logic:

 Check if your neighbour is empty, and if yes then move to it

 We check the neighbours in the following order:

1.  Above

2.  Right

3.  Down

4.  Left

 We end the function once we find the ending position or there is no available neighbour to move to.

What we know about the problem

Assumptions about neighbours.   We know that any individual location will have at most four (4) neighbours: above, right, down, and left. Based on this we should be able to know where a neighbour is relative to our current location.

Structure of the process.   We can see that this process requires complet- ing the same process on a smaller version of the same problem.  We can leverage this to approach this problem using a particular technique that we covered in lecture.

Hey! Listen!

Think about the Triangles and Tower of Hanoi example from lecture!

Assumptions about Map data.    

This function is not needed in the current iteration of the program that runs each level with a seperate instance of the program, it does however still exist within the program.

Sample Output

Your output for the Level given the same test file, should look like Fig. 6.

 

Figure 6: Example of output from Level 3 using test2 . txt input.

 

 

热门主题

课程名

mktg2509 csci 2600 38170 lng302 csse3010 phas3226 77938 arch1162 engn4536/engn6536 acx5903 comp151101 phl245 cse12 comp9312 stat3016/6016 phas0038 comp2140 6qqmb312 xjco3011 rest0005 ematm0051 5qqmn219 lubs5062m eee8155 cege0100 eap033 artd1109 mat246 etc3430 ecmm462 mis102 inft6800 ddes9903 comp6521 comp9517 comp3331/9331 comp4337 comp6008 comp9414 bu.231.790.81 man00150m csb352h math1041 eengm4100 isys1002 08 6057cem mktg3504 mthm036 mtrx1701 mth3241 eeee3086 cmp-7038b cmp-7000a ints4010 econ2151 infs5710 fins5516 fin3309 fins5510 gsoe9340 math2007 math2036 soee5010 mark3088 infs3605 elec9714 comp2271 ma214 comp2211 infs3604 600426 sit254 acct3091 bbt405 msin0116 com107/com113 mark5826 sit120 comp9021 eco2101 eeen40700 cs253 ece3114 ecmm447 chns3000 math377 itd102 comp9444 comp(2041|9044) econ0060 econ7230 mgt001371 ecs-323 cs6250 mgdi60012 mdia2012 comm221001 comm5000 ma1008 engl642 econ241 com333 math367 mis201 nbs-7041x meek16104 econ2003 comm1190 mbas902 comp-1027 dpst1091 comp7315 eppd1033 m06 ee3025 msci231 bb113/bbs1063 fc709 comp3425 comp9417 econ42915 cb9101 math1102e chme0017 fc307 mkt60104 5522usst litr1-uc6201.200 ee1102 cosc2803 math39512 omp9727 int2067/int5051 bsb151 mgt253 fc021 babs2202 mis2002s phya21 18-213 cege0012 mdia1002 math38032 mech5125 07 cisc102 mgx3110 cs240 11175 fin3020s eco3420 ictten622 comp9727 cpt111 de114102d mgm320h5s bafi1019 math21112 efim20036 mn-3503 fins5568 110.807 bcpm000028 info6030 bma0092 bcpm0054 math20212 ce335 cs365 cenv6141 ftec5580 math2010 ec3450 comm1170 ecmt1010 csci-ua.0480-003 econ12-200 ib3960 ectb60h3f cs247—assignment tk3163 ics3u ib3j80 comp20008 comp9334 eppd1063 acct2343 cct109 isys1055/3412 math350-real math2014 eec180 stat141b econ2101 msinm014/msing014/msing014b fit2004 comp643 bu1002 cm2030
联系我们
EMail: 99515681@qq.com
QQ: 99515681
留学生作业帮-留学生的知心伴侣!
工作时间:08:00-21:00
python代写
微信客服:codinghelp
站长地图