This is a program I wrote in Java for my "Data Structures and Algorithms" (CS2210) class at Western university.
The purpose of this assignment was to get experience working with graphs and various graph algorithms.
This a program I wrote that discovers an exit to a labyrinth if such an exit exists.
The program will receive as input a file with a description of the labyrinth, and it will produce as output a path from the entrance to the exit, if any exists.
Think of the labyrinth as a set of rooms connected by corridors, some of which could be closed by walls.
There are 3 types of walls: normal brick walls (displayed by the program in red), thick brick walls (displayed by the program in blue), and metal walls.
The labyrinth might not have a path to the exit; in that case the program will attempt to break some of the walls to try to reach the exit.
The program is given two types of bombs to break walls: brick bombs and acid bombs.
A brick bomb can break a normal brick wall, but not a metal wall; a thick brick wall needs 2 brick bombs to be broken.
An acid bomb can break a metal wall, but not a brick wall.
The program will be given k1 brick bombs and k2 acid bombs, where k1 and k1 are specified in the input file.
Internally, the labyrinth is stored as an undirected graph.
Every node of the graph corresponds to a room, and every edge corresponds to either a hall that can be used to go from one room to the other or to a wall that the program might decide to break.
There are two special nodes in this graph corresponding to the entrance and the exit.
In order to run this program you have to run the Solve.Java file with the first argument being the labyrinth file you want to solve (lab1-lab8).
You can also include a second argument which is the speed the program will show solving the labyrinth, the larger the number the slower it will go.
The classes I wrote for the project are the Node, Edge, GraphException, LabyrinthException, Graph, and Labyrinth class.
All other files and classes were provided to me.
To see a demonstration of the code running please click the link below.