programming assignment, C/C++ Programming

Assignment Help:
Introduction. In this assignment you are required to simulate a maze traversal using so called recursive backtracking (the algorithm is given below).
The grid of #s and 0s in the following Figure is a two-dimensional array representation of a maze. The #s represent the walls of the maze, and the zeros represent locations in the possible paths through the maze. In the maze, you can move one step at a time in the following four directions: up, down, right, left, no “diagonal” moves are allowed. A move can be made only to a location in the array that contains a zero.
# # # # # # # # # # # #
# 0 0 0 # 0 0 0 0 0 0 #
0 0 # 0 # 0 # # # # 0 #
# # # 0 # 0 0 0 0 # 0 #
# 0 0 0 0 # # # 0 # 0 0
# # # # 0 # 0 # 0 # 0 #
# 0 0 # 0 # 0 # 0 # 0 #
# # 0 # 0 # 0 # 0 # 0 #
# 0 0 0 0 0 0 0 0 # 0 #
# # # # # # 0 # # # 0 #
# 0 0 0 0 0 0 # 0 0 0 #
# # # # # # # # # # # #
Write a recursive function called mazeTraversal, to walk through a maze like the one shown above.
The function mazeTraversal should attempt to locate the exit, it should also place the character ''x'' in each square in the path.
In mazeTraversal you are required to implement the following recursive algorithm:
ITECH 7603
Advanced Programming
School of Science, Information Technology and
Engineering
• From the current location in the maze, try to move one space in one of the four directions (down, right, up or left).
• If it is possible to move in at least one direction, call mazeTraversal recursively, passing the new location in the maze as the current location.
• If it is not possible to go in any direction, return to the previous location in the maze and try a new direction from that location
This recursive algorithm finds the exit (assuming there is an exit). If there is no exit, you will arrive at the starting location again.
Program the function to display the maze after each move so that the user can see how the maze is solved. The final output of the maze should display the path that solves the maze.
1. Class Maze. The Maze class should have:
A) Two private instance variables – int size, char **maze;
B) Constructor “Maze(char **c, int size)” – takes as an argument an n-by-n two-dimensional character array that contains only #s and 0s.
C) Public function void mazeTraversal(int a, int b)” – tries to “solve” the maze. Parameters a, b represent the entry point to the maze. Recursive algorithm for the mazeTraversal is described in the previous section.
D) friend ostream &operator<<(ostream &stream, Maze &m) – to print maze m in a tabular format.
E) Private function void mazeGenerator()” – randomly creates an n-by-n (3010==n) Maze object which has an entry point on the left side. The algorithm for mazeGenerator should be as follows:
• You start with 2-dimensional n-by-n array maze containing only #s, and then you “dig” your way through it until reaching a border, marking the visited cells with 0s.
• The entry point is maze[n/2][0]
• First move is to the right, after that you chose randomly any of four possible directions to move.
• The function stops when it reaches a border.
ITECH 7603
Advanced Programming
School of Science, Information Technology and
Engineering
F) Default constructor Maze() – calls the mazeGenerator.
2. main() function.
In the main function you should create three Maze objects:
• One on the figure in the section 0.
• A 12-by-12 maze that has an entry point but does not have an exit. You should design it yourself.
• A randomly generated maze object
Then the mazeTraversal function should be called on each of the created objects.

Related Discussions:- programming assignment

Inheritance, example of program to add two number

example of program to add two number

Pos console cpp unit testing, Pos Console CPP Unit Testing Project Descr...

Pos Console CPP Unit Testing Project Description: Do the CPPUnit Testing for the project. Have all the functions done. Skills required are Android, C Programming, C++ Prog

Define the modulo division operator in c language, Define the Modulo Divisi...

Define the Modulo Division Operator in c language? The C provides one more arithmetic operator % called as modulo division operator and this operator yields the remainder of an

Polishing game, Byteland county is very famous for luminous jewels. Luminou...

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Change to palindrome, A palindrome is a string that reads the same from bot...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

#superASC2 SRTING COST, A string S is said to be "Super ASCII", if it conta...

A string S is said to be "Super ASCII", if it contains the character frequency equal to their ascii values. String will contain only lower case alphabets (''a''-''z'') and the asci

Explain about the integer constants in c language, Explain about the Intege...

Explain about the Integer constants in c language? An integer constant is the integer valued number and it refers to a sequence of digits. A decimal integer constant includes o

Array, Write a program to count the prime number in array

Write a program to count the prime number in array

Computer, Is computer an intelligent machine?

Is computer an intelligent machine?

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd