Author: Petr Benda
Translation: Radek Píbil
Edit: Tibor Strašrybka
This tutorial assumes a basic knowledge of Java and NetBeans IDE.
Implement BFS and DFS algorithms for state-space search. If you implement them using the OPEN and CLOSED sets (lists), the difference between them is minimal.
The output of the algorithm is meant to be the first path between start and target state found. Use the provided libraries for the GUI. In case of matlab or c/c++ either use comprehensive text output, or create a simple GUI yourself.
BFS.java source in NetBeans IDE. Your implementation goes in there.
bfs for NB. bfs directx is provided in case you cannot use OpenGL.
noVisio argument (see runBFS_novisio.bat), which may be useful for debugging.
BFS.java.
node.isTarget() methods return true if a node is the target.
expand() method.
kui.Node interface have hashCode() and equals() correctly implemented. It is not possible to create a node class not implementing kui.Node interface.
findWay() method.
Application.main class as the main class and the name of your class (fully qualified) as a parameter. This method is also being used by the provided batch files (runBFS.bat).
try { Thread.sleep(10); // 10 ms } catch (InterruptedException ex) { ex.printStackTrace(); }
Setting the start and target node can be done using the left mouse button. Zooming in and out can be done with the mouse wheel. A region can be enlarged using ctrl+left mouse button and drag selecting the desired region. The right mouse button can be used to scroll around the map. The color of an expanded edge corresponds with the time at which the expansion took place. The oldest edges are green, followed by blue, purple, red and yellow for the newest.
Entering a new search path is possible after pressing r key.
Implement the A* algorithm. The result is going to be the shortest path between the starting a target node specified by the user. Design and use a heuristic function. Use the provided GUI libraries (if applicable). The state-space is specified by a planar graph.
AStar.java source file in the project. This class implements the InformedSearchingAlgorithm interface. In contrast with the previous task, findWay() receives both the starting and target node.
astar (hit the arrow next to the combo box with <default config> and choose astar).
Do not create any other files, put all the necessary code into the AStar.java source file.
BFS.java and AStar.java source files in kui directory. One file is ok as well, for a partial automatic test, but it is necessary for you to submit both files in the end. Including other files or differently named files is not admissible.
| algorithm | code presentation | auto-evaluation on the server | bonus |
|---|---|---|---|
| BFS/DFS | 2 pts | 2 pts | 1 pt |
| A* | 4 pts | 2 pts | 1 pt |
| Total: | 12 pts | ||