Write cpp pthreads program to discover shortest path in maze

Assignment Help C/C++ Programming
Reference no: EM13963363

Assignment

Aim

The objective of this assignment is to apply the concepts of threading by developing a simple C++ Pthreads program to discover the surroundings and the shortest path in a 2D maze.

Background

This assignment requires you to write a multi-threaded C/C++ "Pathfinder" program to discover the surroundings of a jungle maze. Each [x, y] location in the maze represents a ‘grid area' of the jungle terrain. A particular gird area could be :

• "impassable" (rep. by ‘#' barrier) ,
• contains danger (rep. by ‘X' danger area)
• clear, (i.e. allows you to travel)

An example of the jungle maze will be provided to you (see Appendix A, ‘mazedata.txt').

Your objective is to explore as much of the jungle maze terrain as possible, and mark the discovered area as barrier (‘#'), or danger (‘X') accordingly.

When your program terminate, it should output a map of the explored jungle maze, as well as 1 ‘safe' path, to traverse from Start to End locations.

Task Requirements

A) At startup, your program should read in the 2D maze configuration ("mazedata.txt") which stores the information about the maze dimensions, barriers, start and end locations. Please refer to Appendix A for an example.

B) For the purposes of testing your program, a sample of what information should be output is shown in Appendix B.

C) Before you start developing your program, you should take some time to review the output, and analyze the requirements of the Pathfinder program.

D) Your program should have at least 2 threads, each thread attempting to explore surrounding locations to discover whether it contains a barrier (‘#') or danger (‘X').

E) Impt 1 : your program should maintain a global Maze resource or variable, holding information about all the barriers or danger areas uncovered by your exploring threads!

F) Impt 2 : when a particular thread has encountered a barrier (‘#') or danger (‘X'), it should ...

• Record the path (history of point locations) it has traversed, since the Start Location, to reach the barrier / danger areas, and locations of barrier / danger should be marked on your ‘global Maze resource'

• The thread ‘loses its life' (i.e. should be destroyed) if it has encountered a danger area (‘X') !!

G) Whenever a thread is destroyed, your program should create another replacement thread, to traverse the jungle maze beginning from the Start Location again. But this time, it should access the ‘global Maze resource' to learn and avoid the barriers and danger areas discovered by its predecessor threads!

H) In this way, the ‘sacrifice' of the destroyed threads are not in vain, as its knowledge (of locations of the barriers / danger areas) have been recorded in the ‘global Maze resource' that can be accessed by future generations of created threads to aid their survival in order to discover a path to End Location!

I) As you probably guess by now, the access to the ‘global Maze resource' should be protected via usage of mutex locks. Whether a thread is:

• Updating its discovery of the path to barrier / danger areas OR
• Accessing the ‘global Maze resource' to learn about the discovered locations of the barriers / danger areas

Only 1 thread can access it at any one time!

J) Once the program is completed and tested to be working successfully, you are highly encouraged to add on "new features" to the program that you feel are applicable to the task of finding the shortest path thru a maze. Additional marks may be awarded subject to the relevancy and correctness of the new functionalities.

K) Your program should be written in C++, and using the library functions available in header file ‘pthread.h', to handle all aspects of thread creation, management and synchronization.

L) To encourage good program design, you should consider using different *.cpp class files to encapsulate groups of related methods/functions.

Attachment:- files.zip

Reference no: EM13963363

Questions Cloud

Explain what evidence you observe in your neighborhood : On walkscore.com find the score for your neighborhood. In 200 words explain what evidence you observe in your neighborhood to justify that score
Create an algorithm that asks user for price of an item : Create an algorithm for a program that asks the user for the price of an item. The program then must display the given price, calculate and display the tax based on a 6% rate.
Ernesto purchased a laptop computer : Assume that Ernesto purchased a laptop computer on July 10 of year 1 for $3,000. In year 1, 80 percent of his computer usage was for his business and 20 percent was for computer gaming with his friends
Calculate the average kinetic energy of the n2 molecules : What ratio of temperatures for the two samples would produce the same root mean square velocity?
Write cpp pthreads program to discover shortest path in maze : The objective of this assignment is to apply the concepts of threading by developing a simple C++ Pthreads program to discover the surroundings and the shortest path in a 2D maze.
Explains the role of the traditional healer : Write a 1,050- to 1,400-word paper that explains the role of the traditional healer and the church in Latin America. Summarize relevant literature. Identify at least one economic, one religious, and one social explanation for the use of traditional ..
Calculate the quantity of gas taken out of the cylinder : calculate the quantity of gas taken out of the cylinder if the final pressure is 2.5 * 10^6 N / m^2.
What do you know about this given topic : Documentary - BBC How Art Made The World 1 - More Human Than Human. Answers to the questions over the video you watched- What do you know about this topic? In terms of formal analysis, what does this video provide

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create a calling module name and parameters

Create a calling module name and parameters for the following. (Remember that the asterisk before the parameter name indicates a call-by-reference parameter.

  Search the maximum number from a list of numbers

Write a function to search the maximum number from a list of numbers:

  What are the advantages of using an ordered array

What are the inefficiencies associated with using an unordered array if duplicates are not allowed? What are the advantages of using an ordered array? When would using an unordered array be preferred over using an ordered array

  You are to create a text adventure game that uses pointers

you are to create a text adventure game that uses pointers. you have a rich eccentric uncle billy who is soon to be

  What is difference between while statement and do statement

What is the relationship between an event-listener interface and an event-adapter class? What is the difference between a while statement and a do statement?

  Given the integer variables yearswithcompany and department

Given the integer variables yearsWithCompany and department , write an expression that evaluates to true if yearsWithCompany is less than 5 and department is not equal to 99 .

  Program to count the number of heart beat

If a human heart beats on the average of once a second, how many times does the heart beat in a lifetime of n years? (Use 365.25 for days in a year). Write a program to count the number of heart beat.

  Write a student class in java that implements the interface

A public int compareTo(Object object) that will compare two Student objects based on their student Ids.

  Write a program that inputs a dollar amount to be printed

Write a program that inputs a dollar amount to be printed on a check and then prints the amount in check-protected format with leading asterisks if necessary

  Create the appropriate constructor, getters and setters

Create the appropriate constructor, getters and setters for the class. Create an instance of Student for each of the students listed above from array. Construct the instance with lastname, firstname, and job.

  Implement c code for drawing filled triangles

Calculate the size of a rectangle that is just large enough to contain the triangle. The bx, by, bw, and bh fields of the triangle data structure should be initialized with the appropriate values.

  Program that asks the user for two integers and a character

Write a program that asks the user for two integers and a character, 'A', 'S', or 'M'. Call one of three functions that adds, substracts, or multiplies the user's integers, based on the character input.

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