You will be using an adjacency list to store edges between nodes. A maze will consist of a grid, where each vertex is adjacent to the vertices directly, above, below, to the left and to the right.
Input
You will be provided input via stdin, with the algorithm to use being passed in through a command line argument.
Your program should be able to be executed such that: `./prog5 bfs < maze1.in` will run the program with the BFS algorithm
And: `./prog5 astar < maze1.in` will run the program with the A* algorithm
The input via stdin will consists of 3 sections:
The file will start with the line "======= Nodes ======="
List of nodes, one per line in the form: `x y`.
Line consisting of: "======= Edges ======="
List of undirected edges, one per line in the format: `node_idx_1 node_idx_2`
Line consisting of: "======= Find paths ======="
One path per line in the format: `start_node_idx end_node_idx`
Output
You will output to stdout.
For each line specifying a path to find, print a line of the following format:
`number_explored path_length left_steps right_steps up_steps down_steps`
Where number_explored is the total number of nodes that were explored using the pathfinding algorithm,
path_length is the total length of the path,
left_steps is the number of left neighours followed,
right_steps is the number of right neighbors followed,
up_steps is the number of up neighbors followed,
down_steps is the number of down neighbors followed.
The grid is defined using the same method as Cairo uses, with the origin being in the top left corner, with x increasing to the right and y increasing down.
Therefore, up_steps will be the number of times the neighbour node had a smaller y value.
################################ #e.................e...........# ##############################.# ##### #.......# ###### #.## ##### #s..#########.......#######....# ##..# #...# #...#......##..................###...##### #...# #...#....................................######...# #...#......######.................................# #.......................s.......e.............#...# #...................s..................#......#...# #################...###########...................# #...# ######...#......##### ##### #...######## #####
Rubric:
You start off with 100 points. - 40 points for passsing Unit tests on Graph ADT - 40 points for passing Program tests - 20 points for code style and commenting - 20 bonus points for passing A* program tests You lose credit for missing functionality, incorrect results, poorly documented or formatted code, or not following instructions. Below is a partial list: - up to 10 points off for inadequate comments or hard-to-read code - up to 10 points off for not following instructions - up to 10 points off for special handling to grade your homework (usually because you did not check that it runs on the computers in the lab first). Make sure you: a. include the Makefile, .c files, and .h files b. generate an executable file called prog5 with your Makefile c. have confirmed that it compiles and runs properly on unix.ic.ucsc.edu d. followed the general instructions described in overview.html e. submit early and often with: submit cse101-ap.f21 prog5 prog5.zip
??: ?? ??: ??
Last modified Tuesday, 30-Nov-2021 02:24:44 PST.