1. Overview
Figure 1: 3D Maze Configuration: grids world that contains travelable actions
Figure 2: Definitions of Actions in the Maze
Act X+ X- Y+ Y- Z+ Z- X+Y+ X+Y- X-Y+ X-Y- X+Z+ X+Z- X-Z+ X-Z- Y+Z+ Y+Z- Y-Z+ Y-Z-
Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Your programming task is as follows. Given as inputs: (1) a list of grid points with their available actions, (2) an entrance grid location, e.g., (0,0,0) in Figure 1, and (3) an exit grid location, e.g., (100,103,97) , your program must search in the maze configuration and find the optimal shortest path from the entrance to the exit, using a list of actions that are available along the way.
Conceptually, the specification of a grid location and its associated actions is given as a grid location with a list of actions. For example (Note: The exact input format will be given in section 5 and 6 below),
INPUT LINE: (60 45 97), Y+, Z-, X-Y+
INPUT LINE: (60 46 97), Y-, Y+
INPUT LINE: (60 45 96), Z+, Z-,
INPUT LINE: (59 46 97), X+Y-, X-Y+
is a specification, for Figure 1, that at the grid location (60,45,97), the available actions are Y+, Z-, and X-Y+. At the grid (60,46,97), the available actions are Y- and Y+, and at the grid (60,45,96), the available actions are Z+ and Z-, and at the grid (59,46,97), the available actions are X+Y- and X-Y+ for moving diagonally on the xy plane.
Once your agent finds an optimal path from the entrance to the exit, your agent should output a list of points that have been visited along the path. For example, if the entrance and exit would be changed at (60,103,97) and (64,103,97) respectively, then the correct output path would be:
OUTPUT: (60,103,97), (61,103,97), (62,103,97), (63,103,97), (64,103,97).
2. Grading
Your code will be tested and graded as follows: Your program should not require any command-line argument. It should read a text file called “input.txt” in the current directory that contains a problem definition. It should create and write a file “output.txt” with your solution in the same current directory. Format for input.txt and output.txt are specified as in section 5 below and will be supplemented with some details in section 6. End-of-line character is LF (since vocareum is a Unix system and follows the Unix convention).
The grading A.I. script will test your program for 40 test cases for grading as follows:
– Create an input.txt file and delete any old output.txt file.
– Run your code to create your output.txt file.
– Check the correctness of your program’s output.txt file.
– If your outputs for all 40 test cases are correct, you get 100 points.
– The 40 test cases are divided into four classes: Class1 (easy), 10 cases; Class2 (medium), 10 cases; Class3 (hard), 10 cases; and Class4 (complex), 10 cases.
– For Class1, each test is worthy of 1 point. For Class 2, each test is 2 points. For Class 3, each test is 3 points, and for Class 4, each test is 4 points.
Note that if your code does not compile, or somehow fails to load and parse input.txt, or writes an incorrectly formatted output.txt, or no output.txt at all, or OuTpUt.TxT, you will get zero points. Anything you write to stdout or stderr will be ignored and is ok to leave in the code you submit (but it will likely slow you down). Please test your program on Vocareum’s terminal window with the provided sample files to avoid any problems.
Do not copy code or written material from another student. Even single lines of code should not be copied.
Do not copy code from past students. We keep copies of past work to check for this. Even though this problem differs from those of previous years, do not try to copy from homeworks of previous years.
Do not ask on piazza how to implement some function for this homework, or how to calculate something needed for this homework.
4. Project Description
In this project, we twist the problem of path planning a little bit just to give you the opportunity to deepen your understanding of search algorithms by modifying search techniques to fit the criteria of a more realistic application. To give you a realistic context for expanding your ideas about search algorithms, we invite you to take part in a maze-solving mission in an unknown world. The goal of this mission is to send your sophisticated and intelligent agent from a specific entrance-location and travel as quickly as possible to an exit location. You are invited to develop three algorithms to find the optimal path and navigate through a complex 3D maze configuration based on a particular objective.
The input of your program includes three elements: the maze configuration, an entrance location, and an exit location, plus perhaps some other quantities that control the quality of the solution. Each possible 3D maze world can be imagined as a 3D grid of points in a 3-dimensional space. At each point inside the maze, your agent can perform one of the 18 actions, and move to one of the 18 possible neighbor grid points (See Fig. 2). To simplify things, your agent’s actions are assumed to be deterministic and error-free. If your agent’s action is legal, then your agent will always end up at the intended neighbor grid point. If your agent tries to move into a wall or outside a maze world, the result will be nil and your agent will remain in its current point location.
5. Search for the Optimal Paths
You will write a program that will take an input file that describes the maze configuration, the initial entrance grid location, the exit grid location, and characteristics of the agent. You should find the optimal path from the initial entrance grid location to that exit grid location. A path is composed of a sequence of legal moves. Each legal move consists of moving the agent from a point to one of its 18 neighbor points, using one of the elementary actions that are available at the current location.
Your agent must search through possible paths of movements and find the optimal path to travel from the entrance to the exit, and then output the results.
To find the solution you will use the following algorithms:
– Breadth-first search (BFS)
– Uniform-cost search (UCS) – A* search (A*).
To help us distinguish between your three algorithm implementations, you must follow the following conventions for computing operational path length:
Breadth-first search (BFS)
In BFS, each move from one location to any of its neighbors counts for a unit path cost of 1. You do not need to worry about the fact that moving diagonally actually is a bit longer than moving along the North/South, East/West, and Up/Down directions. So, any allowed move from one location to an adjacent location costs 1.
Uniform-cost search (UCS)
When running UCS, you should compute unit path costs in any of the 2D plane XY, XZ, YZ, on which you are moving. Let us assume that a grid location’s center coordinates projected to a 2D plane are spaced by a 2D distance of 10 units on X and Z plane respectively. That is, on the XZ plane, move from a grid location to one of its 4-connected straight neighbors incurs a unit path cost of 10, while a diagonal move to a neighbor incurs a unit path cost of 14 as an approximation to 10 when running UCS.
√
A* search (A*).
When running A*, you should compute an approximate integer unit path cost of each move as in the UCS case (unit cost of 10 when moving straight on a plane, and unit cost of 14 when moving diagonally). Notice for A*, you need to design an admissible heuristic for A* for this problem.
Input: The file input.txt in the current directory of your program will be formatted as follows:
● First line: Instruction of which algorithm to use, as a string: BFS, UCS or A*
● Second line: Three strictly positive 32-bit integers separated by one space character, for the size of X, Y, and Z dimensions, respectively.
● Third line: Three non-negative 32-bit integers for the entrance grid location.
● Fourth line: Three non-negative 32-bit integers for the exit grid location.
● Fifth line: A strictly positive 32-bit integer N, indicating the number of grids in the maze where there are actions available.
● Next N lines: Three non-negative 32-bit integers separated by one space character, for the location of the grid, followed by a list of actions that are available at this grid. The grid location is guaranteed to be legal and within the maze.
For example:
A*
100 200 100
0 0 0
3 3 0
4
0 0 0 7
1 1 0 7 10
2 2 0 7 10
3 3 0 10
In this example, the 3D maze is of size 100 x 200 x 100 (specifically, points range from (0,0,0) to (99,199,99)) , the entrance grid location is at (0,0,0), and the exit grid location is at (3,3,0). In this maze, there are 4 grid locations that have actions and they are specified in the next four lines. Namely, the grid (0,0,0) has one action X+Y+ (encoded as 7); the grid (1,1,0) has two actions X+Y+ and X-Y- (encoded as 7 and 10); the grid (2,2,0) has two actions X+Y+ and X-Y- (encoded as 7 and 10); and the grid (3,3,0) has one action X-Y- (encoded as 10).
.
Output: The file output.txt that your program creates in the current directory should be formatted as follows:
● First line: A single integer C, indicating the total cost of your found solution. If no solution was found (the exit grid location is unreachable from the given entrance, then write the word “FAIL” (all capital) without any other lines following.
● Second line: A single integer N, indicating the total number of steps in your solution including the starting position.
● N lines: Report the steps in your solution travelling from the entrance grid
location to the exit grid location as were given in the input.txt file.
– Write out one line per step with cost. Each line should contain a tuple of four integers: X, Y, Z, Cost, separated by a space character, specifying the grid location with the single step cost to visit that grid location by your agent from its last grid during its traveling from the entrance to the exit.
For example, the following is a sample output of the corresponding input above:
42
4
0 0 0 0
1 1 0 14
2 2 0 14
3 3 0 14
Notes and hints:
– Please name your program “homework.xxx ” where ‘xxx’ is the extension for the programming language you choose (“py” for python, “cpp” for C++, and “java” for Java). If you are using C++11, then the name of your file should be “homework11.cpp” and if you are using python3 then the name of your file should be
“homework3.py”. Please use the programming languages mentioned above for this homework.
– Most likely (but no guarantee) we will create 13 BFS, 13 UCS, and 14 A* grading cases for grading your agents. These cases are called “Grading Cases” because they are reserved for the grading purposes only. During your development, there would be some “test cases” for you to use to test, debug, and improve your agents. But in general, you are responsible for testing your agents thoroughly using any test cases you would like.
– Your program will be killed after some time if it appears stuck on a given test case, to allow us to grade the whole class in a reasonable amount of time. We will make sure that the time limit for a given test or grading case (or class) is sufficient and long enough for solving the case for a correct algorithm implementation. These time limits are typically determined by a standard algorithm implementation that has been tested thoroughly in solving the given 3D mazes, and we ensure that these time limits are typically very generous.
– The time limit is the total combined CPU time as measured by the Unix time command. This command measures pure computation time used by your program, and discards time taken by the operating system, disk I/O, program loading, etc. Beware that it cumulates time spent in any threads spawned by your agent (so if you run 4 threads and use 400% CPU for 10 seconds, this will count as using 40 seconds of allocated time).
– If several optimal solutions exist, then any of them will count as correct.
– Please submit your homework code through Vocareum (https://labs.vocareum.com /) under the assignment HW1. Your username is your email address (DEN username). Click “forgot password” for the first-time login. You should have been enrolled in this course on Vocareum. If not, please post a private question with your email address and USC ID on Piazza (under “hw1” folder) so that we will invite you again.
6. Sample Inputs and Outputs
Example 1 (BFS):
=======input.txt=============
BFS
10 10 10
1 3 1
5 3 4
12
1 3 1 5
1 3 2 1 11
2 3 3 16
2 4 2 11
2 3 2 5 11
3 3 3 17 18
3 2 2 3
3 3 2 5
3 2 4 7
4 3 4 1 11
5 3 4 2
5 3 5 6
===========================
=======output.txt============
6
7
1 3 1 0
1 3 2 1
2 3 2 1
3 3 3 1
3 2 4 1
4 3 4 1
5 3 4 1
============================
Example 2 (UCS):
=======input.txt=============
UCS
10 10 10
7 0 1
5 2 3
9
5 2 3 1
5 1 3 3
5 2 2 5 17
6 1 2 9 3
6 1 1 5 15
7 1 1 9
6 2 1 4
8 0 1 9
7 0 1 9 1
===========================
=======output.txt============
48
5
7 0 1 0
6 1 1 14
6 1 2 10
5 2 2 14
5 2 3 10
===========================
Example 3 (A*):
=======input.txt=============
A*
5 5 5
1 0 4
3 1 2
8
1 0 1 2
1 0 4 3 16
1 1 4 6 12
2 1 3 2
1 1 3 3 12 16
1 2 3 9
2 1 2 1 12
3 1 1 5
===========================
=======output.txt=============
38
4
1 0 4 0
1 1 3 14
2 1 2 14
3 1 2 10
============================
Example 4 (BFS with no solution):
=======input.txt=============
BFS
4 4 4
0 0 0
2 3 1
6
0 0 0 7 11
1 1 0 7
1 0 1 7
2 1 1 15
2 2 0 5
2 2 2 3
===========================
=======output.txt=============
FAIL
============================

![[SOLVED] Csci561 homework 1](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[SOLVED] Cmsc330 project 2](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.