prodo56 / Uninformed-Search-Algorithms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uninformed-Search-Algorithms Breadth-First search, Depth-First Search, Uniform-cost Search, and A* Search

Project description

The Los Angeles Lakers are playing against their rivals the Boston Celtics tonight. Lakers star Jordan Clarkson wants to arrive earlier today to prepare himself for the game, and he is leaving from his mansion at Newport Coast to Staples Center. As everyone knows, Los Angeles is notorious for its traffic. Driving his 2016 Lamborghini Aventador, Jordan definitely does not want to be stuck in traffic. Please help Jordan find a route to get him to Staples Center as fast as possible.

To accomplish this, you will be given a list of freeway or road intersections (i.e., locations) and the time it would take to travel from there to other freeway or road intersections. You will be required to create a program that finds the fastest route Jordan must travel to get to Staples Center.

Program will be given live traffic information in the input.txt file, which is an arbitrarily large list of current traveling times between intersections/locations. An example live traffic data would be a list of intersections to intersections with traveling time (in minutes), in the following format (see below for the full specification of input.txt):

JordanHome CA73/NewportCoastDr 5
CA73/NewportCoastDr I405/CA73 10
I405/CA73 I110/I405 25
I110/I405 I10/I110 20
I10/I110 I110/I405 30
I10/I110 I10/I405 9
I105/I110 I10/I110 7
I10/I110 StaplesCenter 3

Traveling time may not be the same for both directions. For example, in the above:

 I110/I405 I10/I110 20

indicates that it takes 20 minutes to travel from I110/I405 to I10/I110 (northbound as you follow the 110 freeway), but

 I10/I110 I110/I405 30

indicates that it takes 30 minutes in the other direction (southbound).

Beside live traffic information, Jordan also has an idea of how long it takes on a traffic-free Sunday from each intersection/location to StaplesCenter. Hence, the input.txt file will also contain Jordan's Sunday traffic estimate of traveling time from each location listed in the file to his destination, which is also an arbitrarily large list of intersections/locations with estimated traveling time (in minutes) from there to StaplesCenter on a traffic-free Sunday:

JordanHome 55
CA73/NewportCoastDr 50
I405/CA73 40
I110/I405 28
I10/I110 8
I10/I405 39
I105/I110 23
StaplesCenter 0

Program will write the output in output.txt the list of intersections/locations traveled over in your solution path, including the starting and finishing locations and the accumulated time from start to that intersection/location, in order of travel, for example:

JordanHome 0
CA73/NewportCoastDr 5
I405/CA73 15
I110/I405 40
I10/I110 60
StaplesCenter 63

Full specification for input.txt:

<ALGO>
<START STATE>
<GOAL STATE>
<NUMBER OF LIVE TRAFFIC LINES>
<... LIVE TRAFFIC LINES ...>
<NUMBER OF SUNDAY TRAFFIC LINES>
<... SUNDAY TRAFFIC LINES ...>

where:

<ALGO> is the algorithm to use and will be one of: “BFS”, “DFS”, “UCS”, “A*”.
<START STATE> is a string with the name of the start location (e.g., JordanHome).
<GOAL STATE> is a string with the name of the goal location (e.g., StaplesCenter).
<NUMBER OF LIVE TRAFFIC LINES> is the number of lines of live traffic information that follow.
<... LIVE TRAFFIC LINES ...> are lines of live traffic information in the format described above, i.e., <STATE1> <STATE2>     <TRAVEL TIME FROM STATE1 TO STATE2>
<NUMBER OF SUNDAY TRAFFIC LINES> is the number of lines of Sunday traffic estimates that follow.
<... SUNDAY TRAFFIC LINES ...> are lines of sunday traffic information in the format described above, i.e., <STATE>       <ESTIMATED TIME FROM STATE TO GOAL>

Full specification for output.txt: Any number of lines with the following format for each:

<STATE> <ACCUMULATED TRAVEL TIME FROM START TO HERE>

Example 1: Consider this input.txt:

BFS
A
D
4 
A B 5 
A C 3 
B D 1 
C D 2
4
A 4 
B 1 
C 1 
D 0

Would yield the following output.txt:

A 0 
B 1 
D 2

About


Languages

Language:Java 100.0%